-2
The students in my high school computer science class were asked to write the game of nim for a simple project. Most of them found it very easy and finished quickly. However, one student came up with this solution. I'll probably make them redo it anyway, but I'm wondering if anyone can understand what's going on.
enum $ {
$$;
static int _, $_$, $_, _0_;
{
{
{
{
_$ $_ = _$.__;
}
}
}
}
enum _$ {
__(new byte[][]{
"\nNumber of stones: \0\nPlayer one move: \0Computer takes \0\nComputer wins!\n\0\nPlayer wins!\n".getBytes(),
new byte[]{(byte) (_ = (int) (Math.random() * (_ = ((_ = -~_) * (_ << -~-~_) + -~-~-~_ + -~ ~ ~-~_)) + _))}},
null);
java.io.Console ___ = System.console();
_$(byte[] _$_[], String $[]) {
for ($ = new String(_$_[$_$]).split(Character.toString((char) $_$)); _ > 0;) {
___.printf($[$_$] + _);
do _0_ = ___.readLine($[-~$_$]).getBytes()[$_$] - 060;
while (_0_ > -~-~-~$_$ || _0_ > _);
_ -= $_$ + _0_ >> $_$;
if (((!(!(((!((!((_) < -~($_ = $_$))))))))))) break;
_ -= $_ = Math.min((int) (Math.random() * -~-~-~$_$ + -~$_$), _);
___.printf($[-~-~$_$] + $_);
}
___.printf(($_$ = -~-~-~$_$) > _ ? $[$_ > 0 ? -~$_$ : $_$] : $[2]);}}};
`
See http://stackoverflow.com/questions/7906483/what-causes-noclassdeffounderror-on-a-main-class/7906484#7906484 The rest is just obfuscating variable names. And it has a bug, because it allows the player to take 0.
– Peter Taylor – 2011-11-24T18:05:00.510PS This isn't actually on topic for this site. It's essentially a duplicate of the linked post, so I would suggest that you flag it for closing; otherwise, I'm not sure where it would fit. – Peter Taylor – 2011-11-24T18:06:00.260