Project Euler #206: Concealed Square

  • + 0 comments

    Yeah can't get past the 16th case (python3) :(

    import math
    
    def replacements(c):
        allRepl = []
        pot = (10)**c
        for i in range(0, pot):
            allRepl.append(str(i).zfill(c))
        return allRepl
    
    def allNums(s, r):
        for i in r:
            strin = ""
            count = 0
            strin += s[count]
            for letter in i:
                count += 1
                strin += letter
                strin += s[count]
            if(math.sqrt(int(strin)) == int(math.sqrt(int(strin)))):
                return int(math.sqrt(int(strin)))
        
    knownNums = input()
    numsString = input().rstrip().split()
    
    c = int(knownNums)-1
    print(allNums(numsString, replacements(c)))