[Solved] Competition Problem: Finding numbers containing “2020” from 1 to N which is a multiple of 2020 faster than O(N/2020) [closed]


If you get stuck here’s a solution

import math


baseInt = 2020 #This is the int you want to find within the other int
randomInt = 1012020  #This is the int you're going to count up to



def checkBaseInt(baseInt, theIteratorInt): 
    theNumString = str(theIteratorInt) #Converting to strings to find the substring
    baseIntString = str(baseInt)

    if(theNumString.find(baseIntString) == 0): #Found the substring of the baseInt into the randomint which is the iterator
        return theNumString  #Return the iterator which includes the baseInt


for i in range(baseInt, randomInt): #From your base int up to your final int
    if (checkBaseInt(baseInt, i) != None):  #If it found the desired integer within your final integer
        print(checkBaseInt(baseInt, i)) #Print the iterating integer which includes 2020, or your baseInt

solved Competition Problem: Finding numbers containing “2020” from 1 to N which is a multiple of 2020 faster than O(N/2020) [closed]