Project Euler #104: Pandigital Fibonacci ends

Sort by

recency

|

9 Discussions

|

  • + 0 comments

    I think the key here is try to avoid bigint, passed all test cases in python3.

  • + 0 comments

    a, b, k = int(input()), int(input()), int(input()) n = 2 sum1 = a + b while n < 2 * (10 ** 6): n += 1 q = list(str(sum1))

    isthere=True
    if (len(q) >= k):
    
        for i in range(1, k+1):
    
            if (((str(i) not in q[0:k])) or ((str(i) not in q[-k:]))):
                isthere=False
    
                break
        if(isthere):
    
            print(n)
            break
    
    
    a = b
    b = sum1
    sum1 += a
    

    if (n == 2 * (10 ** 6) - 1): print("no solution")

  • + 1 comment

    run time error LOL a, b, k = int(input()), int(input()), int(input()) n = 2 sum1 = a + b while n < 2 * (10 ** 6): n += 1 q = list(str(sum1))

    isthere=True
    if (len(q) >= k):
    
        for i in range(1, k+1):
    
            if (((str(i) not in q[0:k])) or ((str(i) not in q[-k:]))):
                isthere=False
    
                break
        if(isthere):
    
            print(n)
            break
    
    
    a = b
    b = sum1
    sum1 += a
    

    if (n == 2 * (10 ** 6) - 1): print("no solution")

    • + 0 comments

      you use n just for counting then 2 * (10 6) - 1 is evaluating every time

      for improve that: you can directly start with that big num & decrees it value, up to 2

      or shift that range 2 bit, so only need to check is >0 or not. is this python so, only if n: print("")

      it not give you that much less time, but consume little less than yours

  • + 0 comments

    anyone done using python?

  • + 1 comment

    How do I view the output of the testing?

    • Asked to answer
      + 0 comments

      there is a check box at the left of run button if you want to use your own test input. In this contest you can't buy input output testcases. Try your own