← Back to challenges

Next Happy Year

PythonHardalgorithmsnumbersloopslogic

Instructions

Mubashir needs your help to find out the next happy year.

A Happy Year is the year with only distinct digits. Create a function that takes an integer year and returns the next happy year.

Examples

happy_year(2017) ➞ 2018
# 2018 has all distinct digits

happy_year(1990) ➞ 2013

happy_year(2021) ➞ 2031

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Club Entry