Steven D'Aprano wrote: > On Mon, 26 Dec 2005 13:33:42 -0700, Tim Hochberg wrote: > > >>Claudio Grondi wrote: > > >>>I am currently at 39 bytes following the requirements and the principle >>>given above (my module passes the test). Anyone able to beat that? >> >>Wow! It'll be interesting to see how to do that. The obvious way gives >>53 bytes. Hmmm, I'll have to see what can be done... > > > OBVIOUS???
Your misinterpreting me here. I meant the obvious way to cheat as Claudio describes above. I don't actually think that kind of cheating will work, since it relies on test_vectors.py being present and it assumes that the test vectors used for checking the program are the same as those in test_vectors.py. The documentation suggests that the later at least is not likely. I still haven't figured out how he manages to get his cheating one so short though, the smallest I can get is 43 characters and it looks like this: import test;seven_seg=test.test_vectors.get This works if you run test. It fails if you try to run it standalone since the import order is wrong. > > The only algorithm obvious to me came to two lines and about 300 > characters with all the pruning I could come up with. Changing algorithms > made it longer. I am finding it hard enough to credit that half a dozen > people are claiming lengths of around 130-180 characters -- 39 or 53 bytes > just seems physically impossible to me, especially given that nine of > those bytes are the name of the function! In the 130's is definately possible, but I haven't heard of anyone doing better than that. > > The identity function seven_seg=lambda s:s takes 20 bytes and does > nothing. That leaves NINETEEN bytes to implement the functionality. In the > immortal words of Bill and Ted: "No way dude!" > > You excellent dudes are righteously bodacious! Nah. -tim > > -- http://mail.python.org/mailman/listinfo/python-list