R. Alan Monroe wrote: > I wrote a lame, but working script to solve this in a few minutes. A > fun puzzle. > > http://weblogs.asp.net/jgalloway/archive/2006/11/08/Code-Puzzle-_2300_1-_2D00_-What-numbers-under-one-million-are-divisible-by-their-reverse_3F00_.aspx > >
Fun! for x in xrange(1, 1000000): if x%10 == 0: continue reverse = int( str( x )[::-1] ) if reverse == x or reverse > x: continue if not x%reverse: print x 8712 9801 87912 98901 879912 989901 I thought I'd do it in a single list comprehension, but in order to do that I had to calculate the reverse multiple times. > Alan > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor