5 ms·
Ask HN: A date conundrum
I heard this on the radio tonight but didnt catch the answer - it is bugging our whole house like crazy and we cant figure out the answer.... So. Help?
Question is: what is the next 8-digit date containing all unique numbers (i.e. no duplicates).
We came up with 17/06/2345 (UK format, 06/17/2345 in US format). But apparently that is wrong (we texted in and they listed us as "wrong")
Our logic is that the year 2345 is the earliest it can be because you need at least 2 out of 0, 1 or 2 to manage unique day/month combo's. As 2 is well wrapped up for the next 100 years 2345 is the first we can think of that gives us the 0 and 1 free). Am I wrong?
Any ideas?
- ars 17y ago4/5/2013 (Apr 5, 2013) Are the days supposed to be two digits?
- deleted 17y ago[deleted]
- jibiki 17y agoPretty sure you're right. Maybe you just texted in the wrong format or something.
- notaddicted 17y agoI am pretty sure you're right too, because I wrote a program to brute force the calculation http://codepad.org/G9RLrsku http://codepad.org/G9RLrsku
- ErrantX 17y agoThanks everyone to reply - I guess the texter might have typed it wrong then damn :D We literally spent hrs going "wtf...? it must be that" Thanks for the sanity check
- profquail 17y agoI bet they said it's wrong because they are counting "06" as "6". If you consider that each value (day/month/year) has to be at least 10, then the month must be 10 or 12 (not 11, because of the duplicate "1"). Then, your day value must be somewhere in [23, 29] for October, or in [30] for December. After that, just look at the remaining 6 digits and order them in ascending order. Example: If you choose October (10), you could pick 27 as the day, which leaves [3,6] U [8, 9] for the year digits, so you'd get 10/27/3456 (US format). EDIT: In fact, I think that example may be the best answer, because choosing a day less than 27 makes the year value larger, so using 27, 28, or 29 should minimize the year. Since you want the earliest date, 10/27/3456 should be it.