lunes, abril 05, 2010

python: ping pong

[actualizado] en una sola linea:

while 1: print str('d' not in globals() and globals().__setitem__('d', [__import__('random').randint(1,8),6,1,1]))[0:0] + "\n".join(['-'*12] + ['|' + ''.join([((x,y) == (d[0], d[1])) and '#' or ' ' for x in xrange(10)]) + '|' for y in xrange(10)] + ['-'*12]) + str((lambda: (d.__setitem__(0, d[0]+d[2]), d.__setitem__(1, d[1]+d[3]), d[0] not in range(1,9) and d.__setitem__(2, d[2] * -1), d[1] not in range(1,9) and d.__setitem__(3, d[3] * -1)))())[0:0] + str(__import__('time').sleep(0.2))[0:0]

1 comentario:

Promoción ´08 -Héroes del chaco (Pocitos) dijo...

muy bueno, pero le falto un corte de control, en el while..