# 最低唯一出价拍卖

22

## 输入项

``````10 4 12 11 12 4 7 3 3
1 2 9 15 1 15 15 9 3
3 21 6 4 3 8 6 13 1
``````

``````./test1 '1 2
3 4
5 6
1 2'
``````

## 记分员计划

``````#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define NUMROUNDS 10
#define NUMBOTS 4
#define MAXINPUTSIZE 10000
#define MAXFILENAMESIZE 100

int main()
{
int i,j,a,b,winner;
FILE *fp;
char bots[NUMBOTS][MAXFILENAMESIZE]={"onesconfident","random100","random20","random5"};
char openstring[MAXFILENAMESIZE+MAXINPUTSIZE+3];
char input[MAXINPUTSIZE];
char buff[5];
int shuffle[NUMBOTS],auction[100],lowestbid[NUMBOTS]={[0 ... NUMBOTS-1]=101};
static int guesses[NUMBOTS][NUMROUNDS];
static int scores[NUMBOTS],totalwinbids[NUMBOTS];

srand(time(NULL));

for(i=0;i<NUMROUNDS;i++)
{
/*blank the auction bids for the next round */
for(a=0;a<100;a++)
{
auction[a]=9999;
}

/*loop through the bots sending the input and storing their output */
for(j=0;j<NUMBOTS;j++)
{
/*Fisher-Yates shuffle */
for(b=0;b<NUMBOTS;b++)
{
shuffle[b]=(b+j)%NUMBOTS;/*put current bot at index 0 */
}
for(b=NUMBOTS-1;b>1;b--)
{
int z=rand()%(b-1)+1;/*make sure shuffle leaves index 0 alone */
int t=shuffle[b];
shuffle[b]=shuffle[z];
shuffle[z]=t;
}

/*generate the input for the bots */
strcpy(input,"'");
if(i==0)
{
for(b=0;b<NUMBOTS;b++)
{
if(b!=0)
sprintf(input,"%s 0",input);
else
sprintf(input,"%s0",input);
}
}
else
{
for(a=0;a<i;a++)
{
for(b=0;b<NUMBOTS;b++)
{
if(b!=0)
sprintf(input,"%s %d",input,guesses[shuffle[b]][a]);
else
sprintf(input,"%s%d",input,guesses[shuffle[b]][a]);
}
if(a!=i-1)
strcat(input,"\n");
}
}
strcat(input,"'");

sprintf(openstring,"%s %s",bots[j],input);
fp=popen(openstring,"r");

fgets(buff,3,fp);
fflush(NULL);
pclose(fp);
guesses[j][i]=atoi(buff);

/*add the bid to the auction, eliminating any duplicates */
if(auction[atoi(buff)-1]!=9999)
auction[atoi(buff)-1]=9998;
else
auction[atoi(buff)-1]=j;
}

winner=9999;
/*add one to the score of the winning bot */
for(a=0;a<100;a++)
{
if(auction[a]!=9998 && auction[a]!=9999)
{
winner=auction[a];
scores[winner]+=1;
totalwinbids[winner]+=guesses[winner][i];
if(guesses[winner][i]<lowestbid[winner])
lowestbid[winner]=guesses[winner][i];
break;
}
}

/*output this round's bids and the winning bot's name */
strcpy(input,"");
for(b=0;b<NUMBOTS;b++)
{
if(strcmp(input,"")!=0)
sprintf(input,"%s %d",input,guesses[b][i]);
else
sprintf(input,"%d",guesses[b][i]);
}
if(winner!=9999)
printf("%s %s\n",input,bots[winner]);
else
printf("%s No winner\n",input);
}

/*output final scores */
printf("\nResults:\n");
printf("Bot\tScore\tTotal\tLowest\n");
for(a=0;a<NUMBOTS;a++)
{
printf("%s\t%d\t%d\t%d\n",bots[a],scores[a],totalwinbids[a],lowestbid[a]);
}

return 0;
}
``````

## 测试玩家

``````#include <stdio.h>

int main()
{
printf("1");
return 0;
}
``````

``````#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
srand(getpid());
printf("%d",rand()%100+1);
return 0;
}
``````

``````#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
srand(getpid());
printf("%d",rand()%20+1);
return 0;
}
``````

``````#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
srand(getpid());
printf("%d",rand()%5+1);
return 0;
}
``````

``````1 38 5 2 onesconfident
1 66 13 5 onesconfident
1 94 1 3 random5
1 22 9 1 random20
1 50 17 4 onesconfident
1 78 5 2 onesconfident
1 6 13 5 onesconfident
1 34 1 3 random5
1 62 9 1 random20
1 90 17 4 onesconfident

Results:
Bot Score   Total   Lowest
onesconfident   6   6   1
random100   0   0   101
random20    2   18  9
random5 2   6   3
``````

## 优胜者

``````1 9 3 2 1 6 4 3 6 8 7 10 26 6 10 5 26 2 5 8 8 5 7 6 42 1 ./phinotpi2
1 11 4 2 1 4 9 20 6 8 7 6 26 4 8 4 26 2 5 8 8 5 7 7 42 1 ./phinotpi2
1 7 9 2 1 4 3 20 6 8 7 6 7 4 8 9 26 2 5 8 8 5 4 9 42 3 node minitech1.js
1 13 20 2 1 3 3 20 6 8 7 7 9 6 8 20 26 2 5 8 8 5 9 9 42 3 ./dirichlet
1 12 13 2 1 1 3 20 6 8 7 7 9 6 9 13 26 2 5 8 8 5 20 9 42 3 ./dirichlet
1 2 4 2 1 1 3 20 6 8 7 7 9 6 9 12 26 2 5 8 8 5 13 9 42 3 python blazer1.py
1 11 4 2 1 4 3 20 6 8 7 6 7 4 8 4 26 2 5 8 8 5 12 9 42 3 ./celtschk
1 3 4 2 1 1 3 20 6 8 7 6 7 4 8 9 26 2 5 8 8 5 4 9 42 3 node minitech1.js
1 7 4 2 1 1 3 20 6 8 7 9 26 6 7 20 26 2 5 8 8 5 9 9 42 10 ./phinotpi2
1 9 9 2 1 3 4 20 6 8 7 6 7 3 9 3 26 2 5 8 8 5 20 9 42 10 ./phinotpi2
1 13 4 2 1 3 9 20 6 8 7 4 6 3 8 4 26 2 5 8 8 5 3 9 42 10 scala Schwarzenbeck
1 12 20 2 1 1 3 20 6 8 7 6 20 4 8 7 26 2 5 8 8 5 4 9 42 10 ./phinotpi2
1 10 3 2 1 2 4 20 6 8 7 6 9 3 9 3 26 2 5 8 8 5 7 9 42 10 ./phinotpi2
1 6 9 2 1 4 9 20 6 8 7 4 6 3 8 4 26 2 5 8 8 5 3 9 42 10 scala Schwarzenbeck
1 8 4 2 1 3 3 20 6 8 7 6 20 4 8 7 26 2 5 8 8 5 4 9 42 10 ./celtschk
1 2 13 2 1 3 3 20 6 8 7 9 20 6 8 9 26 2 5 8 8 5 7 9 42 10 ruby1.9 strategist.rb
1 2 4 2 1 3 3 20 6 8 7 7 10 6 9 10 26 2 5 8 8 5 9 9 42 10 python blazer1.py
1 3 13 2 1 4 3 20 6 8 7 6 7 4 8 4 26 2 5 8 8 5 10 9 42 10 ./celtschk
1 4 4 2 1 3 3 20 6 8 7 6 7 4 8 9 26 2 5 8 8 5 4 9 42 10 ruby1.9 strategist.rb
1 4 9 2 1 4 3 20 6 8 7 7 9 6 8 10 26 2 5 8 8 5 9 9 42 10 ./phinotpi2
1 11 7 2 1 1 4 20 6 8 7 6 7 3 8 3 26 2 5 8 8 5 10 9 42 10 ./phinotpi2
1 6 4 2 1 3 9 20 6 8 7 4 6 3 8 4 26 2 5 8 8 5 3 9 42 10 scala Schwarzenbeck
1 13 7 2 1 1 3 20 6 8 7 6 20 4 8 7 26 2 5 8 8 5 4 9 42 10 ./phinotpi2
1 7 4 2 1 4 4 20 6 8 7 6 20 3 8 3 26 2 5 8 8 5 7 9 42 10 ./celtschk
1 13 3 2 1 1 4 20 6 8 7 6 7 3 8 9 26 2 5 8 8 5 3 9 42 10 ./phinotpi2
1 3 4 2 1 3 3 20 6 8 7 6 7 4 8 4 26 2 5 8 8 5 9 9 42 10 ruby1.9 strategist.rb
1 5 4 2 1 2 3 20 6 8 7 6 7 4 8 10 26 2 5 8 8 5 4 9 42 10 ./phinotpi2
1 6 3 2 1 3 4 20 6 8 7 6 7 3 8 3 26 2 5 8 8 5 10 9 42 10 ./phinotpi2
1 10 20 2 1 1 9 20 6 8 7 4 6 3 8 4 26 2 5 8 8 5 3 9 42 10 scala Schwarzenbeck
1 10 3 2 1 4 3 20 6 8 7 6 20 4 8 7 26 2 5 8 8 5 4 9 42 10 ./celtschk
1 12 4 2 1 1 3 20 6 8 7 9 20 6 8 9 26 2 5 8 8 5 7 9 42 10 ./phinotpi2
1 5 3 2 1 1 4 20 6 8 7 6 7 3 9 3 26 2 5 8 8 5 9 9 42 10 ./phinotpi2
1 13 3 2 1 4 9 20 6 8 7 4 6 3 8 4 26 2 5 8 8 5 3 9 42 10 scala Schwarzenbeck
1 6 9 2 1 4 3 20 6 8 7 6 20 4 8 7 26 2 5 8 8 5 4 9 42 10 ./phinotpi2
1 5 4 2 1 2 4 20 6 8 7 6 20 3 8 3 26 2 5 8 8 5 7 9 42 10 ./celtschk
1 12 3 2 1 3 4 20 6 8 7 6 7 3 8 9 26 2 5 8 8 5 3 9 42 10 ./phinotpi2
1 10 7 2 1 2 3 20 6 8 7 6 7 4 8 4 26 2 5 8 8 5 9 9 42 10 ./phinotpi2
1 9 10 2 1 4 9 20 6 8 7 4 6 3 8 3 26 2 5 8 8 5 4 9 42 10 scala Schwarzenbeck
1 9 20 2 1 4 4 20 6 8 7 6 20 3 8 7 26 2 5 8 8 5 3 9 42 10 ruby1.9 strategist.rb
1 6 3 2 1 3 3 20 6 8 7 9 10 6 9 10 26 2 5 8 8 5 7 9 42 10 node minitech1.js
1 13 3 2 1 3 3 20 6 8 7 7 10 6 8 20 26 2 5 8 8 5 10 9 42 11 ./celtschk
1 3 3 2 1 1 3 20 6 8 7 7 26 6 9 9 26 2 5 8 8 5 20 9 42 11 ruby1.9 strategist.rb
1 5 20 2 1 2 3 20 6 8 7 7 11 6 9 11 26 2 5 8 8 5 9 9 42 11 ./phinotpi2
1 7 3 2 1 4 4 20 6 8 7 6 7 3 9 3 26 2 5 8 8 5 11 9 42 11 node minitech1.js
1 7 3 2 1 1 4 20 6 8 7 6 7 3 8 20 26 2 5 8 8 5 3 9 42 10 ./phinotpi2
1 8 4 2 1 4 3 20 6 8 7 6 7 4 8 4 26 2 5 8 8 5 20 9 42 10 ./phinotpi2
1 2 3 2 1 3 9 20 6 8 7 4 6 3 8 3 26 2 5 8 8 5 4 9 42 10 scala Schwarzenbeck
1 4 13 2 1 3 4 20 6 8 7 6 20 3 7 7 26 2 5 8 8 5 3 9 42 10 ./celtschk
1 8 3 2 1 3 3 20 6 8 7 9 20 6 8 9 26 2 5 8 8 5 7 9 42 10 ruby1.9 strategist.rb
1 9 10 2 1 2 3 20 6 8 7 7 10 6 9 10 26 2 5 8 8 5 9 9 42 10 ./phinotpi2
1 10 20 2 1 1 4 20 6 8 7 6 7 3 9 3 26 2 5 8 8 5 10 9 42 10 ./phinotpi2
1 9 4 2 1 1 9 20 6 8 7 4 6 3 8 4 26 2 5 8 8 5 3 9 42 10 scala Schwarzenbeck
1 11 20 2 1 4 3 20 6 8 7 6 20 4 8 7 26 2 5 8 8 5 4 9 42 10 ./phinotpi2
1 4 9 2 1 3 4 20 6 8 7 6 9 3 9 3 26 2 5 8 8 5 7 9 42 10 ruby1.9 strategist.rb
1 5 3 2 1 4 4 20 6 8 7 6 7 3 8 10 26 2 5 8 8 5 3 9 42 10 ./celtschk
1 7 4 2 1 3 3 20 6 8 7 7 9 6 8 9 26 2 5 8 8 5 10 9 42 10 python blazer1.py
1 4 9 2 1 1 3 20 6 8 7 6 7 4 8 4 26 2 5 8 8 5 9 9 42 10 ./phinotpi2
1 8 4 2 1 3 9 20 6 8 7 4 6 3 8 3 26 2 5 8 8 5 4 9 42 10 scala Schwarzenbeck
1 10 9 2 1 3 4 20 6 8 7 6 20 3 8 7 26 2 5 8 8 5 3 9 42 10 ./phinotpi2
1 4 20 2 1 1 3 20 6 8 7 6 20 4 8 4 26 2 5 8 8 5 7 9 42 10 ./phinotpi2
1 5 3 2 1 2 9 20 6 8 7 4 6 3 9 3 26 2 5 8 8 5 4 9 42 10 scala Schwarzenbeck
1 2 4 2 1 1 4 20 6 8 7 6 20 3 8 7 26 2 5 8 8 5 3 9 42 10 ./celtschk
1 10 12 2 1 1 3 20 6 8 7 9 20 6 8 9 26 2 5 8 8 5 7 9 42 10 ./phinotpi2
1 9 4 2 1 4 4 20 6 8 7 6 7 3 9 3 26 2 5 8 8 5 9 9 42 10 ruby1.9 strategist.rb
1 11 3 2 1 3 4 20 6 8 7 6 7 3 8 10 26 2 5 8 8 5 3 9 42 10 ./phinotpi2
1 8 4 2 1 1 3 20 6 8 7 6 7 4 8 4 26 2 5 8 8 5 10 9 42 10 ./phinotpi2
1 13 9 2 1 4 9 20 6 8 7 4 6 3 8 3 26 2 5 8 8 5 4 9 42 10 scala Schwarzenbeck
1 2 9 2 1 3 4 20 6 8 7 6 20 3 8 7 26 2 5 8 8 5 3 9 42 10 ./phinotpi2
1 8 3 2 1 2 3 20 6 8 7 6 20 4 8 4 26 2 5 8 8 5 7 9 42 10 ./celtschk
1 3 3 2 1 4 3 20 6 8 7 6 7 4 8 9 26 2 5 8 8 5 4 9 42 10 ruby1.9 strategist.rb
1 10 4 2 1 1 3 20 6 8 7 7 9 6 8 10 26 2 5 8 8 5 9 9 42 10 ./phinotpi2
1 3 9 2 1 4 4 20 6 8 7 6 7 3 8 3 26 2 5 8 8 5 10 9 42 10 node minitech1.js
1 7 11 2 1 4 4 20 6 8 7 6 7 3 8 20 26 2 5 8 8 5 3 9 42 10 ./celtschk
1 8 3 2 1 2 3 20 6 8 7 7 9 6 8 9 26 2 5 8 8 5 20 9 42 10 ruby1.9 strategist.rb
1 3 10 2 1 3 3 20 6 8 7 7 10 6 9 10 26 2 5 8 8 5 9 9 42 10 node minitech1.js
1 8 4 2 1 1 3 20 6 8 7 7 10 6 8 20 26 2 5 8 8 5 10 9 42 11 ./phinotpi2
1 2 4 2 1 2 4 20 6 8 7 6 7 3 9 3 26 2 5 8 8 5 20 9 42 11 ruby1.9 strategist.rb
1 4 9 2 1 4 4 20 6 8 7 6 7 3 8 11 26 2 5 8 8 5 3 9 42 11 node minitech1.js
1 4 9 2 1 1 3 20 6 8 7 7 11 6 8 20 26 2 5 8 8 5 11 9 42 10 ./phinotpi2
1 2 7 2 1 1 4 20 6 8 7 6 7 3 9 3 26 2 5 8 8 5 20 9 42 10 ./phinotpi2
1 9 3 2 1 1 9 20 6 8 7 4 6 3 8 4 26 2 5 8 8 5 3 9 42 10 scala Schwarzenbeck
1 3 9 2 1 2 3 20 6 8 7 6 20 4 8 7 26 2 5 8 8 5 4 9 42 10 ruby1.9 strategist.rb
1 5 7 2 1 3 3 20 6 8 7 10 20 6 8 10 26 2 5 8 8 5 7 9 42 10 ./celtschk
1 8 10 2 1 4 3 20 6 8 7 7 10 6 9 9 26 2 5 8 8 5 10 9 42 10 ./phinotpi2
1 5 4 2 1 4 4 20 6 8 7 6 7 3 9 3 26 2 5 8 8 5 9 9 42 10 ruby1.9 strategist.rb
1 5 20 2 1 3 4 20 6 8 7 6 7 3 8 10 26 2 5 8 8 5 3 9 42 10 ./phinotpi2
1 11 20 2 1 2 3 20 6 8 7 6 7 4 8 4 26 2 5 8 8 5 10 9 42 10 ./phinotpi2
1 12 10 2 1 1 9 20 6 8 7 4 6 3 9 3 26 2 5 8 8 5 4 9 42 10 scala Schwarzenbeck
1 10 3 2 1 1 4 20 6 8 7 6 20 3 8 7 26 2 5 8 8 5 3 9 42 10 ./phinotpi2
1 9 4 2 1 4 3 20 6 8 7 6 20 4 8 4 26 2 5 8 8 5 7 9 42 10 ./phinotpi2
1 5 3 2 1 1 9 20 6 8 7 4 6 3 8 3 26 2 5 8 8 5 4 9 42 10 scala Schwarzenbeck
1 7 4 2 1 1 4 20 6 8 7 6 20 3 7 7 26 2 5 8 8 5 3 9 42 10 ./celtschk
1 11 7 2 1 3 3 20 6 8 7 9 20 6 8 9 26 2 5 8 8 5 7 9 42 10 ruby1.9 strategist.rb
1 13 10 2 1 1 3 20 6 8 7 7 10 6 9 10 26 2 5 8 8 5 9 9 42 10 ./phinotpi2
1 9 9 2 1 1 4 20 6 8 7 6 7 3 9 3 26 2 5 8 8 5 10 9 42 10 ./phinotpi2
1 7 9 2 1 3 9 20 6 8 7 4 6 3 8 4 26 2 5 8 8 5 3 9 42 10 ruby1.9 strategist.rb
1 13 7 2 1 4 3 20 6 8 7 6 7 4 8 10 26 2 5 8 8 5 4 9 42 10 ./phinotpi2
1 8 7 2 1 1 4 20 6 8 7 6 7 3 8 3 26 2 5 8 8 5 10 9 42 10 ./phinotpi2
1 12 3 2 1 1 9 20 6 8 7 4 6 3 8 4 26 2 5 8 8 5 3 9 42 10 scala Schwarzenbeck
1 13 7 2 1 2 3 20 6 8 7 6 20 4 8 7 26 2 5 8 8 5 4 9 42 10 ./phinotpi2

Results:
Bot                 Score   Total   Lowest
perl phinotpi1.pl           0   0   101
./dirichlet                 2   25  12
python blazer1.py           3   12  4
perl chef.pl ilmari2.chef   0   0   101
./brainfuck ilmari1.bf      0   0   101
./christophe1               0   0   101
./phinotpi2                 44  156 3
node minitech1.js           7   140 20
scala Mueller               0   0   101
scala Beckenbauer           0   0   101
scala Schwarzenbeck         15  105 7
./alice                     0   0   101
./bob                       0   0   101
./eve                       0   0   101
python joe.py               0   0   101
python copycat.py           0   0   101
python totalbots.py         0   0   101
perl healthinspector.pl     0   0   101
./mellamokb1                0   0   101
./mellamokb2                0   0   101
php eightscancel.php        0   0   101
php fivescancel.php         0   0   101
python copycat2.py          0   0   101
./celtschk                  14  126 9
./deepthought               0   0   101
ruby1.9 strategist.rb       15  152 10
``````

1

Ilmari Karonen

1

@IlmariKaronen是的，您可以。但是我相信人们不会那样做。我可以限制每个人的参赛人数，但我认为只有在出现破坏者的情况下，我才求助于此。

@userunknown我试图阐明拍卖的工作方式。
Gareth 2012年

1
@PhiNotPi：不要感到内。您在规则范围内获胜。
Steven Rumbalski

Answers:

9

## 佩尔

``````    sub prob{
\$_[0]+\$_[1]-\$_[0]*\$_[1]
}

\$_=<>;
INPUT:{

tr/ /,/;
@in = eval;
for(1..\$#in){
\$bids[\$rnum][\$in[\$_]]++
}
for(0..\$#in){
\$tbids[\$rnum][\$in[\$_]]++
}
\$rnum++;
\$_=<>;
if(\$_ ne"\n"){redo INPUT}
}

for(0..100){\$pre[\$_]=0}

dirichlet: for(2..\$#in/2+2){    #rough approximation,
\$pre[\$_]=prob(\$pre[\$_], 1/int(\$#in/2+1))
}

CDP:{
@cdps1=(1,1,1,2,2,3,3,4);
@cdps2=(-2,-1,0,1,1,2,2,3,3);
for(\$a=0;\$a<8;\$a++){
for(\$b=0;\$b<9;\$b++){
\$sum=\$cdps1[\$a]+\$cdps2[\$b];
if(\$sum<1){\$sum=1};
\$pre[\$sum] = prob(\$pre[\$sum], 1/72);
}
}
}

blazer: {
for(\$r=1;\$r<\$rnum;\$r++){
winner: for(\$pnt=1;\$pnt<101;\$pnt++){
if(\$tbids[\$r][\$pnt] == 1){
if(\$pnt > 2){
\$winnum[\$pnt]++;
\$wins++;
}
last winner
}
}
}
if(\$wins==0){
\$pre[3]=prob(\$pre[3], 1);last blazer
}
for(1..100){
\$pre[\$_]=prob(\$pre[\$_], \$winnum[\$_]/\$wins);
}
}

CC1: for(\$pnt=1;\$pnt<101;\$pnt++){
if(\$tbids[\$rnum-1][\$pnt] == 1){
\$pre[\$pnt] = prob(\$pre[\$pnt], 1);last CC1
}
if(\$pnt==100){
for(\$pnt2=1;\$pnt2<100;\$pnt2++){
\$pre[\$pnt2] = prob(\$pre[\$pnt2], \$tbids[\$rnum-1][\$pnt2]/(\$#in+1));
}
}
}

CC2: for(\$pnt=1;\$pnt<101;\$pnt++){
if(\$rnum-2<0){\$pre[7] = prob(\$pre[7], 1);last CC2}
if(\$tbids[\$rnum-2][\$pnt] == 1){
\$pre[\$pnt] = prob(\$pre[\$pnt], 1);last CC2
}
if(\$pnt==100){
\$pre[7] = prob(\$pre[7], 1);last CC2
}
}

one: {
\$pre[1] = prob(\$pre[1], 1);
}

two: {
\$pre[2] = prob(\$pre[2], 1);
}

five: {
\$pre[5] = prob(\$pre[5], 1);
}

eight: {
\$pre[8] = prob(\$pre[8], 1);
}

fortytwo: {
\$pre[42] = prob(\$pre[42], 1);
}

mueller: {
\$a=(\$#in+2)/4;
\$pre[int\$a]=prob(\$pre[int\$a], 1)
}

schwarzenbeck: {
\$a=(\$#in+2)/4+1;
\$pre[int\$a]=prob(\$pre[int\$a], 1)
}

beckenbauer: {
\$a=(\$#in+2)/4+2;
\$pre[int\$a]=prob(\$pre[int\$a], 1)
}

totalbots: {
\$pre[\$#in+1]=prob(\$pre[\$#in+1], 1)
}

joe: {
\$sum=0;
for(1..100){
\$sum+=\$tbids[\$rnum-1][\$_];
}
\$average=\$sum/(\$#in+1);
if(\$average==0){\$average=10};
\$pre[\$average]=prob(\$pre[\$average], 1);
}

node: {
\$max=0;\$maxloc=0;
for(1..100){
if(\$tbids[\$rnum-1][\$_]>\$max){\$max=\$tbids[\$rnum-1][\$_];\$maxloc=\$_}
}
\$maxloc--;
#if(\$maxloc==0){
\$maxloc=20;
#}
if(\$rnum==1){\$maxloc=3}
\$pre[\$maxloc]=prob(\$pre[\$maxloc], 1);
}
#print"\n@pre\n\n";

decide: for(1..100){if(\$pre[\$_]<0.5){print; last decide}}
``````

``````perl PhiNotPi2.plx
1 2 3 3 2
2 1 3 1 3
2 1 1 1 3
[empty line]
``````

@petertaylor我太过分了吗？我应该恢复到原来的状态吗？
PhiNotPi 2012年

2

PhiNotPi 2012年

8

## 厨师

``````Shirred Eggs.

This recipe prints the number 2 and, in doing so, yields two delicious
shirred eggs.

Ingredients.
2 eggs

Cooking time: 12 minutes.

Pre-heat oven to 175 degrees Celsius.

Method.
Put eggs into mixing bowl. Pour contents of the mixing bowl into the
baking dish. Shirr the eggs. Bake the eggs until shirred.

Serves 1.
``````

msh210

Ilmari Karonen'2

msh210

2

1

4

## 巨蟒（2.6）

``````import sys, random
try:
s = sys.stdin.readlines()[-2]
m = min(int(x) for x in s.split())
except IndexError:
m = random.choice([1,1,1,2,2,3,3,4])
a = random.choice([-2,-1,0,1,1,2,2,3,3])
print max(m + a, 1)
``````

1
`m = random.choice(1,2,2,3,3,3)`应该`m = random.choice([1,2,2,3,3,3])`吗？

Blazer表示可能会出错。我在方括号中进行了测试，它似乎奏效了。
Gareth

@Blazer：是的，绝对（我的打字错误）。感谢您的通知。
ChristopheD

4

## Python（西装外套）

``````python bidding.py bidding.txt
``````

``````10 4 12 11 12 4 7 3 3
1 2 9 15 1 15 15 9 3
3 21 6 4 3 8 6 13 1
``````

--

``````import random
import sys

winning = [] # record the winning numbers

content = sys.argv[1].split('\n')
for each in content:
x = map(int, each.split())
if len(x)+sum(x) == 0:
continue

y = []
for each in x:
if x.count(each) == 1:
y.append(each)
if len(y) > 0:
if min(y) not in [1,2]:  #never choose 1 or 2
winning.append(min(y))

# choose an output
if len(winning) == 0:
print 3
else:
print random.choice(winning)
``````

edit2：忘记了min（）

edit3：更改输入以适合问题的输入需求

Gareth 2012年

@Gareth，将其包装在bash脚本中。`echo "\$@" | python bidding.py`应该做的工作。

Gareth

@Blazer我不确定那是问题所在。我使用示例调用从命令行亲自调用程序，并得到了上面给出的错误。那里有与Python 2.6.1不兼容的东西吗？
Gareth

3

### Schwarzenbeck（斯卡拉）

``````object Schwarzenbeck extends App {
println ((args(0).split('\n')(0).split(' ').length+1)/4+1)
}
``````

Schwarzenbeck不应进球。他是为贝肯鲍尔（Beckenbauer）进行的清理工作，随后将进行清理。:)

``````scalac Schwarzenbeck.scala
``````

``````scala Schwarzenbeck 'your ar-
gu-
ment'
``````

1

celtschk 2012年

3

``````require 'Matrix'
def winner guesses
g=guesses.sort
while g[0]&&g[0]==g[1]
g.shift while g[0]==g[1]
g.shift
end
g[0]
end

def prob g
prob=[0]*100;best=0;n=g.size*(g[0].size-1)
g.each{|r|r[1..-1].each{|v|prob[v-1]+=1.0/n}};
prob.map!{|v|v/n}
end

def regression x, y, degree
return y if x.size==1
x_data = x.map {|xi| (0..degree).map{|pow| (xi**pow.to_f) }}
mx = Matrix[*x_data]
my = Matrix.column_vector y
begin
r = ((mx.t * mx).inv * mx.t * my).transpose.to_a[0]
rescue Exception => e
r=[0]*degree;r[-1]=y[-1].to_f/(x[-1]**degree)
end
r
end

brains=((1..50).map{|w|[proc{|g|w},
proc{|g|best=0;(p=prob g).each_with_index{|v,i|
best=i if(v+i/100.0/w)<p[best]};best+1}]}+
(1..7).map{|w|[proc{|g|p=1; if (g[1]) then h=g[1..-1];x=(1..h.size).to_a
p=0;regression(x,h.map{|r|winner r},w).each_with_index{|v,i|
p+=v*(g.size**i)};end;p.to_i},
proc{|g|b=g[0].size/4;if g[1] then pred=[];h=g[1..-1]
x=(1..h.size).to_a;h[0].size.times{|i|p=0
regression(x,h.map{|r|r[i]},w).each_with_index{|v,i|p+=v*((x[-1]+1)**i)}
pred<<[[p.to_i,1].max,100].min}
(1..100).each{|i|if !pred.include?(i) then b=i;break;end};end;b}]}+
(-1..1).map{|w|[proc{|g|r=g[0].size; if g.size>1 then
f=g[1..-1].flatten;r=(f.inject{|s,v|s+v}/f.size.to_f+w).to_i;end;r},
proc{|g|r=g[0].size/2; if g.size>1 then
r=(g[1..-1].inject(0){|s,v|s+winner(v)}/(g.size.to_f-1)+w).to_i;end;r},
proc{|g|(winner(g[-1])||9)+w}  ]}+
[proc{|g|b=0;(p=prob g).each_with_index{|v,i|b=i if v<p[b]};b+1}]).flatten

games = ARGV[0].split("\n").map{|l|l.split.map{|v|v.to_i}}
winpct=[0]*brains.size
(games.size-1).times{|round|
entries=games[round+1].dup
brains.each_with_index{|b,i|
entries[0]=pick=[b[games[0..round]],1].max
winpct[i]+= 1.0/games.size if winner(entries)==pick
}
}
best=0;
winpct.each_index{|i|best = i if (winpct[i]>winpct[best])}
puts brains[best][games]
``````

Gareth '02

Gareth 2012年

Gareth 2012年

AShelly 2012年

2

## 佩尔

``````print 1
``````

Blazer

PhiNotPi 2012年

@Peter：不用担心，我已经照顾好了。:)
Ilmari Karonen'2

2

## JavaScript（node.js）

``````var lastRound = /[^\n]+\$/.exec(process.argv[2]);
var numbers = {};
var re = /\d+/g;
var match;

while(match = re.exec(lastRound)) {
numbers[match] = numbers[match] >>> 0 + 1;
}

var maxKey = -1;

for(var i in numbers) {
if(maxKey === -1 || numbers[i] > numbers[maxKey]) {
maxKey = i;
}
}

if(maxKey == 0) {
// First round. Bid 3.
console.log(3);
} else if(maxKey == 1) {
// Bid 20.
console.log(20);
} else {
// Bid one less.
console.log(maxKey - 1);
}
``````

``````node script.js 'the argument'
``````

1
@PeterTaylor我想知道这是否是第一个`for`循环吗？如果`if(i in numbers)``if(matches[i] in numbers)`你觉得呢？
Gareth

@minitech经过一番摸索之后，它看起来正则表达式只匹配输入的一个数字-对javascript或Nodejs的了解不够，无法说出原因。另外，您是否需要在换行符上拆分输入以获取最后一轮？
Gareth '02

@加雷斯：的确是。更新，尽管如果它本来表现更好，那么我不介意:)
Ry

Gareth

2

## Python（CopyCat）

``````content = sys.argv[1].split('\n')
x = map(int, content[-1].split())
y = []
for each in x:
if x.count(each) == 1:
y.append(each)
print min(y) if sum(y) > 0 else random.choice(x) if sum(x) > 0 else 5
``````

2

## Python（乔）

``````content = sys.argv[1].split('\n')
x = map(int, content[-1].split())
print sum(x)/len(x) if sum(x) != 0 else 10
``````

2

## Python（TotalBots）

``````content = sys.argv[1].split('\n')
print len(content[-1].split())
``````

2

## Perl（健康检查员）

``````print ((((((2)**(2))*((2)**(2)))/((((2)**(2))*(2))*(2)))+((((2)**(2))*(2))/((2)+((2)*(((((2)**(2))+((2)*(2)))+(((2)*(2))/((2)**(2))))**(((2)/(2))/(2)))))))+((((2)-(2))/((((2)**(2))+(2))*((2)+(2))))*(rand(2))))
``````

2

# C ++（受过教育的猜测）

``````#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <cstdlib>
#include <ctime>
#include <exception>
#include <stdexcept>

typedef std::vector<int> botvec;
typedef std::vector<botvec> scorevec;

// read all the scores from the given string
// note that this only does minimal error checking
// the result is a vector of vector, each entry of which
// represents one round. That is, the vectors in the vector
// correspond to the lines of the command line argument.
scorevec read_past_scores(char const* scoretext)
{
scorevec past_scores;

std::istringstream is(scoretext);
std::string line;

scorevec::size_type size = 0;

while (std::getline(is, line))
{
past_scores.push_back(botvec());

std::istringstream ils(line);
int i;
while (ils >> i)
past_scores.back().push_back(i);
if (size == 0)
size = past_scores.back().size();
else if (past_scores.back().size() != size)
throw std::runtime_error("invalid score format");
}
return past_scores;
}

struct counts { int count[100]; };
struct prob { double p[100]; };

int generate_answer(scorevec& past_scores)
{
int const number_of_players = past_scores.front().size();
if (past_scores.front().front() == 0) // initial round
past_scores.pop_back();

// Pre-fill the counts to get reasonable probabilities also for
// insufficient statistics (and the statistics *will* be
// insufficient!). Bias in favour of small numbers.
counts initial;
for (int i = 0; i < 100; ++i)
initial.count[i] =
i < number_of_players? 100*(number_of_players-i) : 1;

std::deque<counts> playercounts(number_of_players, initial);

// add the actual guesses (with a high factor, to give them high
// weight against the initial counts)
for (int i = 0; i < past_scores.size(); ++i)
for (int j = 0; j < number_of_players; ++j)
playercounts[j].count[past_scores[i][j]-1]+=5000;

// drop the own guesses
playercounts.pop_front();

// calculate the probabilities corresponding to the counts
std::vector<prob> playerprobabilities(playercounts.size());
for (int i = 0; i < playercounts.size(); ++i)
{
double sum = 0;
for (int k = 0; k < 100; ++k)
sum += playercounts[i].count[k];
for (int k = 0; k < 100; ++k)
playerprobabilities[i].p[k] = playercounts[i].count[k]/sum;
}

// for each selection, estimate the expected number of other players
// who will bet on it. Return the first one with an expectation
// below 1.5.
for (int i = 0; i < 100; ++i)
{
double estimate = 0;
for (int j = 0; j < number_of_players; ++j)
estimate += playerprobabilities[j].p[i];
if (estimate < 1.5)
return i+1;
}

// in the unlikely case that such a choice doesn't exist (meaning
// there are far more than 100 players), just return 100.
return 100;
}

int main(int argc, char* argv[])
{
if (argc < 2)
{
std::cerr << "Missing score argument!\n";
return EXIT_FAILURE;
}

try
{
scorevec past_scores = read_past_scores(argv[1]);

std::srand(std::time(0));

std::cout << generate_answer(past_scores) << std::endl;

return EXIT_SUCCESS;
}
catch(std::exception& e)
{
std::cerr << e.what() << "\n";
return EXIT_FAILURE;
}
catch(...)
{
std::cerr << "Unknown error\n";
return EXIT_FAILURE;
}
}``````

2

## Perl（鲍勃）

``````\$_=<>;
INPUT:{

tr/ /,/;
@in = eval;
for(1..\$#in){
\$bids[\$rnum][\$in[\$_]]++
}
for(0..\$#in){
\$tbids[\$rnum][\$in[\$_]]++
}
\$rnum++;
\$_=<>;
if(\$_ ne"\n"){redo INPUT}
}

for(0..100){\$pre[\$_]=0}

blazer: {
for(\$r=1;\$r<\$rnum;\$r++){
winner: for(\$pnt=1;\$pnt<101;\$pnt++){
if(\$tbids[\$r][\$pnt] == 1){
if(\$pnt > 2){
\$winnum[\$pnt]++;
\$wins++;
}
last winner
}
}
}
if(\$wins==0){
\$pre[3]++;last blazer
}
}

CC1: for(\$pnt=1;\$pnt<101;\$pnt++){
if(\$tbids[\$rnum-1][\$pnt] == 1){
\$pre[\$pnt]++;last CC1
}
}

CC2: for(\$pnt=1;\$pnt<101;\$pnt++){
if(\$rnum-2<0){\$pre[7]++;last CC2}
if(\$tbids[\$rnum-2][\$pnt] == 1){
\$pre[\$pnt]++;last CC2
}
if(\$pnt==100){
\$pre[7]++;last CC2
}
}

one: {
\$pre[1]+=2;
}

two: {
\$pre[2]+=2;
}

five: {
\$pre[5]+=2;
}

eight: {
\$pre[8]+=2;
}

fortytwo: {
\$pre[42]++;
}

mueller: {
\$a=(\$#in+2)/4;
\$pre[int\$a]++;
}

schwarzenbeck: {
\$a=(\$#in+2)/4+1;
\$pre[int\$a]++;
}

beckenbauer: {
\$a=(\$#in+2)/4+2;
\$pre[int\$a]++;
}

totalbots: {
\$pre[\$#in+1]++;
}

joe: {
\$sum=0;
for(1..100){
\$sum+=\$_*\$tbids[\$rnum-1][\$_];
}
\$average=\$sum/(\$#in+1);
if(\$average==0){\$average=10};
\$pre[\$average]++;
}

node: {
\$max=0;\$maxloc=0;
for(1..100){
if(\$tbids[\$rnum-1][\$_]>\$max){\$max=\$tbids[\$rnum-1][\$_];\$maxloc=\$_}
}
\$maxloc--;
#if(\$maxloc==0){
\$maxloc=20;
#}
if(\$rnum==1){\$maxloc=3}
\$pre[\$maxloc]++;
}
choice: for(1..100){
if(\$pre[\$_]==1){
\$count++;
if(\$count==3){print; last choice}
}
if(\$_==100){print"98"}
}
``````

Gareth

PhiNotPi'2

2

## Perl（爱丽丝）

``````\$_=<>;
INPUT:{

tr/ /,/;
@in = eval;
for(1..\$#in){
\$bids[\$rnum][\$in[\$_]]++
}
for(0..\$#in){
\$tbids[\$rnum][\$in[\$_]]++
}
\$rnum++;
\$_=<>;
if(\$_ ne"\n"){redo INPUT}
}

for(0..100){\$pre[\$_]=0}

blazer: {
for(\$r=1;\$r<\$rnum;\$r++){
winner: for(\$pnt=1;\$pnt<101;\$pnt++){
if(\$tbids[\$r][\$pnt] == 1){
if(\$pnt > 2){
\$winnum[\$pnt]++;
\$wins++;
}
last winner
}
}
}
if(\$wins==0){
\$pre[3]++;last blazer
}
}

CC1: for(\$pnt=1;\$pnt<101;\$pnt++){
if(\$tbids[\$rnum-1][\$pnt] == 1){
\$pre[\$pnt]++;last CC1
}
}

CC2: for(\$pnt=1;\$pnt<101;\$pnt++){
if(\$rnum-2<0){\$pre[7]++;last CC2}
if(\$tbids[\$rnum-2][\$pnt] == 1){
\$pre[\$pnt]++;last CC2
}
if(\$pnt==100){
\$pre[7]++;last CC2
}
}

one: {
\$pre[1]+=2;
}

two: {
\$pre[2]+=2;
}

five: {
\$pre[5]+=2;
}

eight: {
\$pre[8]+=2;
}

fortytwo: {
\$pre[42]++;
}

mueller: {
\$a=(\$#in+2)/4;
\$pre[int\$a]++;
}

schwarzenbeck: {
\$a=(\$#in+2)/4+1;
\$pre[int\$a]++;
}

beckenbauer: {
\$a=(\$#in+2)/4+2;
\$pre[int\$a]++;
}

totalbots: {
\$pre[\$#in+1]++;
}

joe: {
\$sum=0;
for(1..100){
\$sum+=\$_*\$tbids[\$rnum-1][\$_];
}
\$average=\$sum/(\$#in+1);
if(\$average==0){\$average=10};
\$pre[\$average]++;
}

node: {
\$max=0;\$maxloc=0;
for(1..100){
if(\$tbids[\$rnum-1][\$_]>\$max){\$max=\$tbids[\$rnum-1][\$_];\$maxloc=\$_}
}
\$maxloc--;
#if(\$maxloc==0){
\$maxloc=20;
#}
if(\$rnum==1){\$maxloc=3}
\$pre[\$maxloc]++;
}
choice: for(1..100){
if(\$pre[\$_]==1){
\$count++;
if(\$count==2){print; last choice}
}
if(\$_==100){print"99"}
}
``````

``````perl Alice.plx
1 4 3 12
3 2 4 11
[blank line]
``````

2

## Perl（夏娃）

``````\$_=<>;
INPUT:{

tr/ /,/;
@in = eval;
for(1..\$#in){
\$bids[\$rnum][\$in[\$_]]++
}
for(0..\$#in){
\$tbids[\$rnum][\$in[\$_]]++
}
\$rnum++;
\$_=<>;
if(\$_ ne"\n"){redo INPUT}
}

for(0..100){\$pre[\$_]=0}

blazer: {
for(\$r=1;\$r<\$rnum;\$r++){
winner: for(\$pnt=1;\$pnt<101;\$pnt++){
if(\$tbids[\$r][\$pnt] == 1){
if(\$pnt > 2){
\$winnum[\$pnt]++;
\$wins++;
}
last winner
}
}
}
if(\$wins==0){
\$pre[3]++;last blazer
}
}

CC1: for(\$pnt=1;\$pnt<101;\$pnt++){
if(\$tbids[\$rnum-1][\$pnt] == 1){
\$pre[\$pnt]++;last CC1
}
}

CC2: for(\$pnt=1;\$pnt<101;\$pnt++){
if(\$rnum-2<0){\$pre[7]++;last CC2}
if(\$tbids[\$rnum-2][\$pnt] == 1){
\$pre[\$pnt]++;last CC2
}
if(\$pnt==100){
\$pre[7]++;last CC2
}
}

one: {
\$pre[1]+=2;
}

two: {
\$pre[2]+=2;
}

five: {
\$pre[5]+=2;
}

eight: {
\$pre[8]+=2;
}

fortytwo: {
\$pre[42]++;
}

mueller: {
\$a=(\$#in+2)/4;
\$pre[int\$a]++;
}

schwarzenbeck: {
\$a=(\$#in+2)/4+1;
\$pre[int\$a]++;
}

beckenbauer: {
\$a=(\$#in+2)/4+2;
\$pre[int\$a]++;
}

totalbots: {
\$pre[\$#in+1]++;
}

joe: {
\$sum=0;
for(1..100){
\$sum+=\$_*\$tbids[\$rnum-1][\$_];
}
\$average=\$sum/(\$#in+1);
if(\$average==0){\$average=10};
\$pre[\$average]++;
}

node: {
\$max=0;\$maxloc=0;
for(1..100){
if(\$tbids[\$rnum-1][\$_]>\$max){\$max=\$tbids[\$rnum-1][\$_];\$maxloc=\$_}
}
\$maxloc--;
#if(\$maxloc==0){
\$maxloc=20;
#}
if(\$rnum==1){\$maxloc=3}
\$pre[\$maxloc]++;
}
choice: for(1..100){
if(\$pre[\$_]==1){
\$count++;
if(\$count==1){print; last choice}
}
if(\$_==100){print"100"}
}
``````

1

## 脑干

“您可以根据需要输入任意数量的漫游器，因此，如果有人输入仅猜测的漫游器，则`1`可以输入另一个相同的漫游器以使其失效。”

``````+++[->++++<]>[-<++++>]<+.
``````

Gareth

Gareth

@加雷斯：好的，我将答案分为两部分。至于条目的合理性，您自己建议，如果有人要提交“自信”，则其他人也可以这样做。当然，在那一点上，提交“ twosconfident”与提交“ onesconfident”一样有意义，所以……
Ilmari Karonen 2012年

1

PhiNotPi 2012年

1
@Peter：你为什么这么认为？鉴于我和PhiNotPi的程序都在比赛中，因此没有其他人可以提交曾经下注1 的程序（如果他们希望该程序获胜，那就是）。
Ilmari Karonen'2

1

### 穆勒（斯卡拉）

``````object Mueller extends App {
println ((args(0).split('\n')(0).split(' ').length+1)/4)
}
``````

1

### 贝肯鲍尔（斯卡拉）

``````object Beckenbauer extends App {
println ((args(0).split('\n')(0).split(' ').length+1)/4+2)
}
``````

1

## 批处理脚本

``````echo 5
``````

1

``````echo 8
``````

1

## FivesCancel（PHP）

``````5
``````

1

## ThreesCancel（PHP）

``````8
``````

mellamokb

1

## Python 2.7-Copycat2

``````import sys
content = sys.argv[1].split('\n')
x = map(int, content[-2].split()) if len(content) > 1 else [7]
y = []
for each in x:
if x.count(each) == 1:
y.append(each)
print min(y) if sum(y) > 0 else random.choice(x) if sum(x) > 0 else 7
``````

1

# Shell脚本（深入思考）

``````echo 42
``````

1

## Dirichlet.c

``````#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>

main(int argc, char* argv[])
{
int handle;
char *str;
int32_t bits, val, n = 0;

if (argc) {
for (str = argv[1]; *str; str++)
if (*str == 32) n++;
else if (*str == 10) break;
}

n /= 2;
if (n > 99) n = 99;

handle = open("/dev/urandom", O_RDONLY);
do {
read(handle, &bits, sizeof bits);
bits &= 0x7fffffff;
val = bits % n;
} while (bits - val + (n-1) < 0);
close(handle);

printf("%d", 2 + val);
}
``````

### 基本原理

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.