python coding contest
theller at python.net
Fri Dec 30 11:52:26 CET 2005
Shane Hathaway <shane at hathawaymix.org> writes:
> Andrew Durdin wrote:
>> On 12/28/05, Shane Hathaway <shane at hathawaymix.org> wrote:
>>>I just found a 125 character solution. It's actually faster and more
>>>readable than the 133 character solution (though it's still obscure.)
>> Having spent a good deal of time and effort, and not getting below
>> characters, I am now very eager to see how these shorter versions
>> work, particularly the 6 120-character solutions. I also expect that
>> someone (I'll certainly give it a try) will produce a yet shorter
>> version after the contest closes, based on the knowledge from the
>> winning solutions.
> Roberto Alsina fully documented his 120 byte solution here:
> My 120 byte solution is equivalent. Many others probably did the same
> thing. Python's philosophy of one way to do it seems to be leading us
> all down the same road.
Here's a different way: it generates the output column-wise, then uses
zip to assemble line-wise. The additional loop around zip's result
probably kills it, for easier redability it's 163 bytes, but a few bytes
could easily be spared.
X=' _ _ _ | _| _ |_|_ '
seven_seg=lambda n:j(j(c)+"\n"for c in zip(*[X[Y>>m+int(d)*9&7::8]for d in n for m in(6,3,0)]))
More information about the Python-list