21
How long's left?
Recently, I was making pizza using a 5-minute timer on my phone. When someone walked in and asked me how long was left, I was confused for a moment at first as to how to answer the question. You see, if the timer at the current moment was at 3:47, by the time I had read out 'Three minutes and forty seven seconds' aloud, the time would have changed. Therefore, I need to find a time that the timer would reach just as I finish reading it out.
This is your challenge: to automate this process. Given a time in any appropriate format (":" delimited, or as a minute and second argument), output the earliest time from that current moment which would take an equal amount of time to read out as it would take for the timer to get to. We're assuming that each syllable takes 1 second to read out.
Further rules
- You must count 'minutes' and 'seconds' as two of the syllables each, as well as an 'and' between them.
- The pizza will never take more than 59:59 to cook.
- '11 minutes and 0 seconds' is not 10 syllables: you must simplify to '11 minutes' (i.e 5 syllables). Same goes with minutes: '0 minutes and 7 seconds' is also only counted as 4 syllables.
- Your program can give the output in any format: an array of
[minutes, seconds]
, or even as<minutes> minutes and <seconds> seconds
(normal text written out). - Standard loopholes apply.
- This is code-golf, so shortest answer in bytes wins.
Test cases
All inputs as (minutes, seconds)
(4, 47) = (4, 38) (Four MiNutes And ThirTy Eight SeConds - 9 syllables/seconds)
(1, 1) = (0, 56) (FifTy-Six SeConds - 5 syllables/seconds)
(59, 57) = (59, 46) (FifTy Nine Minutes And Forty Six SeConds - 11 syllables/seconds)
(0, 10) = null/error/0 (no positive answer)
Syllable count reference
For reference, here are the number of syllables in each number up to 59.
0,0 (does not need to be counted)
1,1
2,1
3,1
4,1
5,1
6,1
7,2
8,1
9,1
10,1
11,3
12,1
13,2
14,2
15,2
16,2
17,3
18,2
19,2
20,2
21,3
22,3
23,3
24,3
25,3
26,3
27,4
28,3
29,3
30,2
31,3
32,3
33,3
34,3
35,3
36,3
37,4
38,3
39,3
40,2
41,3
42,3
43,3
44,3
45,3
46,3
47,4
48,3
49,3
50,2
51,3
52,3
53,3
54,3
55,3
56,3
57,4
58,3
59,3
For your first test case, would 4:37 also be a valid output, since that would take 10 syllable's to say? – Quinn – 2019-07-12T19:48:43.760
1@Quinn, the spec states that we should output the earliest time. – Shaggy – 2019-07-12T19:58:45.027
1@Shaggy whoops, so it does thanks - by the time I sort my answer out I think my pizza will be burnt – Quinn – 2019-07-12T20:00:39.583
Are we allowed to assume the input can be padded, i.e. 4 minutes and 43 seconds could be inputted as "04:43"? – Vedvart1 – 2019-07-12T20:16:35.397
1@Vedvart1 OK, that's fine – Geza Kerecsenyi – 2019-07-12T20:36:58.820
Can I return a Datetime object with the two numbers in the minutes and seconds property? – Embodiment of Ignorance – 2019-07-13T07:56:37.023
@JoKing fixed now. – Geza Kerecsenyi – 2019-07-13T08:15:58.123
@EmbodimentofIgnorance of course - like I said, you can output in any (appropriate) format. – Geza Kerecsenyi – 2019-07-13T08:16:50.590
Is 0:00 a valid input? – Daniil Tutubalin – 2019-07-13T18:28:55.870
@DaniilTutubalin Yes, but there are no possible outputs. – Geza Kerecsenyi – 2019-07-13T18:44:18.337