CCC '13 S1 - From 1987 to 2013

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2013 Stage 1, Junior #3, Senior #1

You might be surprised to know that 2013 is the first year since 1987 with distinct digits. The years 2014, 2015, 2016, 2017, 2018, 2019 each have distinct digits. 2012 does not have distinct digits, since the digit 2 is repeated.

Given a year, what is the next year with distinct digits?

Input Specification

The input consists of one integer Y (0 \le Y \le 10\,000), representing the starting year.

Output Specification

The output will be the single integer D, which is the next year after Y with distinct digits.

Sample Input 1

1987

Output for Sample Input 1

2013

Sample Input 2

999

Output for Sample Input 2

1023

Comments


  • -13
    superduperoffensive  commented on Oct. 24, 2025, 3:03 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • 1
      idklolXD3  commented on Nov. 1, 2025, 3:56 p.m.

      ew disgusting they aren't even good games


      • 1
        happybearybear  commented on Nov. 4, 2025, 8:53 p.m. edited

        I think they are actual roblox games, so if you play roblox, you can confirm they exist, and that superduperoffensive did not make them up. ( he made up the monsters though, i think)


    • -4
      Chris_Shang  commented on Oct. 28, 2025, 8:49 p.m. edited

      get out


  • 3
    dmitri_p86  commented on June 14, 2024, 6:54 p.m.

    A distinct year will have the length of its digits array/list equal to the length of the set of its digits.


  • -12
    AlexOldest  commented on May 24, 2024, 3:52 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • 3
    akhballett  commented on Jan. 31, 2024, 7:29 p.m.

    This one is kinda hard. :)


    • -5
      Abyss_123  commented on Dec. 20, 2024, 3:11 p.m.

      This comment is hidden due to too much negative feedback. Show it anyway.


    • 2
      eprohappy  commented on Dec. 16, 2024, 3:41 a.m. edited

      hi i was advised not to send my orignal post


    • 0
      shafin008  commented on Feb. 24, 2024, 7:00 a.m.

      Create a function to check duplicate which outputs True if there's a duplicate. In that function input is the given string, then loop over the string and create 2 lists to check for duplicate. After that just run a while loop where you increment the year until the duplicate function finds the duplicate. Cheers!


    • 0
      MrWoon2010  commented on Feb. 9, 2024, 6:48 a.m.

      I think you need to do substring comparison of the input. Or convert the input into a list and do element comparison.


      • 1
        longcow  commented on Feb. 10, 2024, 12:21 a.m.

        bruteforce worked for me, i just incremented by 1 and checked if that year had distinct numbers by converting it into a hashset and comparing the size and the length