DiYane

Next Happy Year

Sep 18th, 2023
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. input_year = int(input())
  2. next_year = input_year + 1
  3. next_happy_year = ""
  4. brake_first_loop = False
  5. while True:
  6.     str_next_year = str(next_year)
  7.     next_happy_year = str_next_year[0]
  8.     for i in range(1, len(str_next_year)):
  9.         for j in range(0, i):
  10.             if str_next_year[i] == next_happy_year[j]:
  11.                 brake_first_loop = True
  12.                 break
  13.         if brake_first_loop:
  14.             break
  15.         else:
  16.             next_happy_year = next_happy_year + str_next_year[i]
  17.     if len(next_happy_year) == len(str_next_year):
  18.         break
  19.     next_happy_year = ""
  20.     brake_first_loop = False
  21.     next_year += 1
  22. print(next_happy_year)
Tags: python
Add Comment
Please, Sign In to add comment