רצ"ב תרגום לג'אווה
public
class Riddle {
static int b,p,w;
static char g(int d, int l)
{
int []wa = {1<<1,1<<26,1<<3,1<<24,1<<9,1<<18};
char[]sol= {'e','w','s','n','d','u'};
int []ca = {0111111111,0444444444,0007007007,0700700700,0000000777,0777000000};
do ww+2)%6; while ((d–&1)!=0); if (++d!=0) w^=1;
do {pint)(((long)(p)*wa[ w])%((1<<27)-1)); if ((p&(b|ca[ w]))!=0) return(0); b ^= p;} while (l–!=0);
return(sol[ w]);
}
public static void main(String[] args) {
int s,i,l=0x1298f; //b10010100110001111;
char[] sol=new char[17];
for (s=1; s<3; s++)
for (long d=0; d<(long)1<<34; d+long)1<<(0<<1)) {
b; p; w=0;
for (i=16; i>=0; –i)
if (0==(sol[ i]=g((int)((d>>(i<<1))&3),(l>>i)&1))) break;
if (i<0){for (i=17;i!=0;) System.out.print(sol); System.out.println();}
}
}
}