##C++, The Scientist This one tries to, with the history of what the majority chose per round in `wave` (`analyse()` gives the majority's choice on a round), fit a wave to the data, of period `2*period`. Thus, given `1,1,1,0,1,0,1,1,1,0,0` it definitely selects `period=3`: its scores become `5 1 9 -1 1 1 3 5 7 5 3`. It tries to get a maximum, for a `1,0,1,0`-style wave, or a minimum, for a `0,1,0,1`-style wave. The biggest of `abs(max)` and `abs(min)` determines which wave it's going to take. It then extrapolates that wave to the next round and takes the other one. #include <iostream> #include <utility> #include <cstdlib> #include <cstring> using namespace std; pair<int,int> analyse(const char *round){ int p=0,a=0,b=0; while(true){ if(round[p]=='1')a++; else if(round[p]=='0')b++; else break; p++; } return pair<int,int>(a,b); } int main(int argc,char **argv){ if(argc==1){ cout<<(rand()%2?"good":"evil")<<endl; return 0; } int nump,numr; nump=strchr(argv[1],',')-argv[1]; numr=(strlen(argv[1])+1)/(nump+1); int period,r; pair<int,int> an; int *wave=new int[numr]; cerr<<"wave: "; for(r=0;r<numr;r++){ an=analyse(argv[1]+r*(nump+1)); if(an.first>an.second)wave[r]=1; else if(an.first<an.second)wave[r]=2; else wave[r]=0; cerr<<wave[r]<<" "; } cerr<<endl; int *scores=new int[numr]; int max=-1e6,maxat=-1,min=1e6,minat=-1; cerr<<"scores: "; for(period=1;period<=numr;period++){ scores[period-1]=0; for(r=0;r<numr;r++){ if(wave[r]==1+r%(2*period)/period)scores[period-1]++; else if(wave[r]==2-r%(2*period)/period)scores[period-1]--; } if(scores[period-1]>max){ max=scores[period-1]; maxat=period; } if(scores[period-1]<min){ min=scores[period-1]; minat=period; } cerr<<scores[period-1]<<" "; } cerr<<"(max="<<max<<" at "<<maxat<<") (min="<<min<<" at "<<minat<<")"<<endl; if(max>=-min){ cerr<<" max: "<<numr<<"%(2*"<<maxat<<")/"<<maxat<<"=="<<(numr%(2*maxat)/maxat)<<endl; if(numr%(2*maxat)/maxat==0)cout<<"evil"<<endl; else cout<<"good"<<endl; } else { cerr<<" min: "<<numr<<"%(2*"<<minat<<")/"<<minat<<"=="<<(numr%(2*minat)/minat)<<endl; if(numr%(2*minat)/minat==0)cout<<"good"<<endl; else cout<<"evil"<<endl; } delete[] wave; delete[] scores; return 0; } Compile with `g++ -O2 -o Scientist Scientist.cpp` (you don't need warnings) and run with `Scientist.exe` (possibly including the argument of course). If you ask really nicely I can provide you with a Windows executable.