Python, 108 chars
Python was not made for this challenge. Wanna print
? That's reserved. Well, how about we use stdout
? Well, that's gonna cost an import
... you guessed it, reserved. Well... I'm on unix, so I can open up the file descriptor 1, which happens to be stdout. Hack!
Man, and iteration? Nothing but eval
. No loops, of course, but we can't even define a function with def
or lambda
. And to add insult to injury, we can't even use list comprehension! I always look for an excuse to use things like map(p.__mod__,...)
in code golf... comprehension is always better. Until now, that is.
p=1
eval(compile("p+=1;open('/dev/fd/1','w').write('%s '%p*all(map(p.__mod__,range(2,p))));"*720,'','exec'))
Now, you might complain that exec
is a keyword, even though I didn't use the keyword (I didn't even eval
an exec
). Well, here's a 117-character solution which doesn't use 'exec'
.
p=2
s="eval('('+s*(p<720)+')',open('/dev/fd/1','w').write('%s '%p*all(map(p.__mod__,range(2,p)))),{'p':p+1})";eval(s)
1Unfortunately for me, Tcl has no reserved words. – Johannes Kuhn – 2013-11-10T23:04:16.230