[python-nl] PyContest

Rob Hooft rob at hooft.net
Tue Dec 27 22:08:07 CET 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Guyon Morée wrote:
> Het kortste (en lelijkste) waar ik op kom is:
> 
> c=' _ | ||_|     |  | _  _||_  _  _| _|   |_|  | _ |_  _| _ |_ |_| _  
> |  | _ |_||_| _ |_| _|'
> def seven_seg(x): return
> '\n'.join([''.join([c[int(d)*9+p:int(d)*9+p+3] for d in x]) for p in
> (0,3,6)]+[''])

Volgens mij is dit 5 bytes korter, en misschien wel minder lelijk.

f=" _     _  _     _  _  _  _  _ ","| |  | _| _||_||_ |_   ||_||_|",
"|_|  ||_  _|  | _||_|  ||_| _|"
def seven_seg(x): return '\n'.join([''.join([l[d*3:d*3+3] for d in
map(int,x)]) for l in f])+'\n'

Rob

- --
Rob W.W. Hooft  ||  rob at hooft.net  ||  http://www.hooft.net/people/rob/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDsa03H7J/Cv8rb3QRAl1jAJ97q5l2CHhojiT4gNB2HnUkJGO2iACglq8k
9k9Cl04yOW6Qc0pgVN3TPLI=
=0tyS
-----END PGP SIGNATURE-----


More information about the Python-nl mailing list