A challenge from the Mensa Puzzle Calendar

news.verizon.net vze4rx4y at verizon.net
Thu Oct 3 17:04:30 EDT 2002


> I'm a puzzle kind of guy, so I thought some of you might be, too.
> I'd be very curious to see the kind of solutions people come up with.
> My solution ended up being a total of 19 lines of code, including a
> print statement to give me a nice formatted output for each solution,
> resembling the initial problem from the calendar.
>
> OK, folks.  The gauntlet is down.  Have at it!

for a in range(700,800):
    for b in range(100):
        digits = list('%d%d%d' % (a, b, a*b))
        digits.sort()
        if digits == list('0123456789'):
            print '%5d\n%5d\n-----\n%5d' % (a, b, a*b)


Raymond Hettinger





More information about the Python-list mailing list