{}
CODE VISUALIZER
Master DSA, Python and C with step-by-step code visualization.
See it in action
CODE VISUALIZER
Master DSA, Python and C with step-by-step code visualization.
See it in action
run-icon
main.py
def happyChecker(year): yearUsed = str(year) numberArray = [] for i in range(len(yearUsed)): if yearUsed[i] in numberArray: return False, 0 numberArray.append(yearUsed[i]) return True, yearUsed def happyYear(year): theHappyYear = 0 yearBeingChecked = year happiness = False while happiness == False: yearBeingChecked = yearBeingChecked + 1 happiness, theHappyYear = happyChecker(yearBeingChecked) print(theHappyYear) happyYear(2017) # output = 2018 happyYear(1990) # output = 2013 happyYear(2021) # output = 2031
Output