Project Euler #40: Champernowne's constant

  • + 1 comment

    My python solution was timing out for the last two, but when I was testing it on my own computer it passed 10^5 cases in less than 2 seconds. It was reading the input that was taking too long. This made the difference:

    import sys

    input = sys.stdin.readline

    • + 0 comments

      Reading the Input is the main problem making TLE on test cases. First Read the input and store it. Then only try to work on the values. It would be best in general programming to avoid these cases.