News for hackers. Stuff that matters.
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.

    def bar(baz):
        baz()
        baz()

    bar(bar(bar(bar(foo)))) and bar(bar(foo)) and foo()
for N=21, for example. Actually, you can make it two lines if your goal is really to minimize LOC:

    def bar(baz): baz() and baz()

    bar(bar(bar(bar(foo)))) and bar(bar(foo)) and foo()
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.

Re:Printing 1 to 1000 without loop or conditionals by endtime on Wednesday January 05, 2011 @03:56AM (#2070415)
s/commands/commas/g