Amazon Interview Question
Software Engineer / DevelopersCountry: India
Interview Type: In-Person
What if 5 shows up on 1st die and 8 on the 2nd die. How will just justify 58 or 85 as a month date ?
It is not like you have to toss the dices....you just should be able to show all the dates from 01 to 31 using these two dices.
So, 58 or 85 wont be shown..... e.g. if you are told like "show me 25".... then you should show 25 using these two dices.
This was a hint Lightyear ... I am not asking you, but, I am giving hint that you should reuse one or more numbers. Get this hint and you are done :)
I was also not able to do it at first, but Hiring manager gave this hint and within 5 seconds I got that hint. So it is just tricky, try to get it. Else I'll tell the solution.
I think the following combination also works:
012348
012567
We flip 6 as 9. This works well for all dates from 01-31.
I didn't see anything that indicated that BOTH die needed to be roled... just an implied assumption, if they both were.
Die 1: 0, 1, 2, 2, 3, 3 (something like - statistically there are probably more 2's & 1's... one'd have to verify)
Die 2: 4, 5, 6, 7, 8, 9
To get the 13th - roll die 1 twice, etc.
I saw nothing in req. that would preclude this - an upside number is just that.
Needed to be accurate across both dice, not that both are rolled... Just a thought
Just struck me !
i can show 9 instead of 09
First dice : 0,1,2,3,4,5
Second dice : 1,2,6,7,8,9
Then I dont think its possible , you ll invariably leave one digit out of the two dices and you wont get three dates
1st dice 0 1 2 3 4 5
- Anonymous November 14, 20122nd dice 0 1 2 6 7 8
'6' can be inverted to get '9'