Re:Printing 1 to 1000 without loop or conditionals
by endtime on Monday January 03, 2011 @10:30AM
(#2063370)
I think the final output of a simple solution to your last question can always be just four lines.
for N=21, for example. Actually, you can make it two lines if your goal is really to minimize LOC:
[ Parent
| on HN ]
Re:Printing 1 to 1000 without loop or conditionals
by endtime on Monday January 03, 2011 @03:32PM
(#2064568)
Whoops, `baz() and baz()` actually doesn't work, because foo may not return a truthy value (and bar definitely doesn't). One fix, which actually makes it even shorter, is just `baz(), baz()`.
Same goes for `bar(bar(...)) and bar()`; all the `and`s should be commands instead in my solution above. Of course, this is Python-specific.