def testResult(self): current = map(lambda x: int(x), str("0123456789")) for n in range(1000000 - 1): current = next_number(current) as_number = reduce(lambda r, x: r * 10 + x, current) self.assertEqual(as_number, 2783915460)
#~ 120 #~ 210 #~ #~ 0123 swap #~ 0132 #~ 0213 swap #~ 0231 #~ 0312 #~ 0321 try: import euler_tools except ImportError: print "Hacked!" import sys, os sys.path.append( os.path.join( os.getcwd(), '..' ) ) from euler_tools.permutation import next_number def as_string(sequence): return reduce(lambda x, y: x + str(y), sequence, "") start_digits = map(lambda x: int(x), str("0123456789")) print "start_digits:\t%s" % as_string(start_digits) current = start_digits for n in range(1000000 - 1): current = next_number(current) print "current:\t%s" % as_string(current)