Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0,Det tog bara 7454 iterationer att brute forcea denna.
where each “_” is a single digit.
#!/usr/bin/env python
from math import sqrt
def match(a):
  i = 10
  while (a > 0):
    a, i = a / 100, i - 1
    if a % 10 != i:
      return False
  return True
n = int(sqrt(1929394959697989999)) + 1
while not match(n * n):
  n = n - 1
print "Answer is", n 
2 kommentarer:
he he den var ju busenkel...
Tack for intressant blogg
Skicka en kommentar