fork download
  1. import time
  2. start_time = time.time()
  3.  
  4. count, ans = 100, ""
  5. for a in range( 1, 10 ):
  6. for b in range( 1, 10 ):
  7. for c in range( 1, 10 ):
  8. for d in range( 1, 10 ):
  9. for e in range( 1, 10 ):
  10. res = str( (10000 * a) + ( 1000 * (2 * b) ) + ( 100 * (3 * c) ) + ( 10 * (4 * d) ) + (5 * e) )
  11. if ( len( res ) == 5 ) and ( sorted( [ a, b, c, d, e, int( res[0] ), int( res[1] ), int( res[2] ), int( res[3] ), int( res[4] ) ] ) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ) and ( (a + b + c + d + e) < count ):
  12. count = a + b + c + d + e
  13. ans = str( a ) + str( b ) + str( c ) + str( d ) + str( e ) + res
  14. print ans
  15. print time.time() - start_time
Success #stdin #stdout 0.46s 7856KB
stdin
Standard input is empty
stdout
3817246590
0.447651863098