# Doing a little trolling with the microwave timer

Related

Sometimes when I use my microwave, I do a little trolling and enter times such as 2:90 instead of 3:30 because they end up being the same time anyway. The microwave happily accepts this and starts counting down from 2:90, displaying times like 2:86 and 2:69 until it gets back to a stage where it can count down like a normal timer. Y'all's task today is to simulate this behaviour by returning a list of all times displayed by the microwave when given a starting time.

## An Example

Say I input 2:90 into the microwave. It starts at 2:90 and then shows 2:89, 2:88, 2:87, 2:86, ..., 2:60, 2:59, 2:58, 2:57, ..., 2:00, 1:59, 1:58, 1:57, ..., 0:05, 0:04, 0:03, 0:02, 0:01, END. As you can see, where the seconds are less than 60, it acts as normal. But where the seconds are greater than 60, it decrements the seconds without impacting the minute count.

## Rules

• Input can be taken in any convienient and reasonable format, including, but not limited to:

• [minutes, seconds]
• [seconds, minutes]
• minutes on one line, seconds on the next
• seconds on one line, minutes on the next
• a single integer which is a [minutes, seconds] pair divmod 100 (e.g 130 represents 1:30).
• Output can be given in any convienient and reasonable format, including, but not limited to:

• [[minute, second], [minute, second], [minute, second], ...]
• ["minute second", "minute second", "minute second", ...]
• minute second\n minute second\n ...
• [[second, minute], [second, minute], [second, minute], ...]
• The outputted times can be returned in any order - they don't need to be sorted.

• The seconds will never be greater than 99.

• Including [0, 0] or 0:00 is optional.

Make sure to include how you're outputting the times in your answer.

## Sample IO

Input here is given as [minutes, seconds]. Output is given as a list of [minute, seconds]

[0, 90] => [[0, 90], [0, 89], [0, 88], [0, 87], [0, 86], [0, 85], [0, 84], [0, 83], [0, 82], [0, 81], [0, 80], [0, 79], [0, 78], [0, 77], [0, 76], [0, 75], [0, 74], [0, 73], [0, 72], [0, 71], [0, 70], [0, 69], [0, 68], [0, 67], [0, 66], [0, 65], [0, 64], [0, 63], [0, 62], [0, 61], [0, 60], [0, 59], [0, 58], [0, 57], [0, 56], [0, 55], [0, 54], [0, 53], [0, 52], [0, 51], [0, 50], [0, 49], [0, 48], [0, 47], [0, 46], [0, 45], [0, 44], [0, 43], [0, 42], [0, 41], [0, 40], [0, 39], [0, 38], [0, 37], [0, 36], [0, 35], [0, 34], [0, 33], [0, 32], [0, 31], [0, 30], [0, 29], [0, 28], [0, 27], [0, 26], [0, 25], [0, 24], [0, 23], [0, 22], [0, 21], [0, 20], [0, 19], [0, 18], [0, 17], [0, 16], [0, 15], [0, 14], [0, 13], [0, 12], [0, 11], [0, 10], [0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1], [0, 0]]
[1, 20] => [[1, 20], [1, 19], [1, 18], [1, 17], [1, 16], [1, 15], [1, 14], [1, 13], [1, 12], [1, 11], [1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1], [1, 0], [0, 59], [0, 58], [0, 57], [0, 56], [0, 55], [0, 54], [0, 53], [0, 52], [0, 51], [0, 50], [0, 49], [0, 48], [0, 47], [0, 46], [0, 45], [0, 44], [0, 43], [0, 42], [0, 41], [0, 40], [0, 39], [0, 38], [0, 37], [0, 36], [0, 35], [0, 34], [0, 33], [0, 32], [0, 31], [0, 30], [0, 29], [0, 28], [0, 27], [0, 26], [0, 25], [0, 24], [0, 23], [0, 22], [0, 21], [0, 20], [0, 19], [0, 18], [0, 17], [0, 16], [0, 15], [0, 14], [0, 13], [0, 12], [0, 11], [0, 10], [0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1], [0, 0]]
[2, 90] => [[2, 90], [2, 89], [2, 88], [2, 87], [2, 86], [2, 85], [2, 84], [2, 83], [2, 82], [2, 81], [2, 80], [2, 79], [2, 78], [2, 77], [2, 76], [2, 75], [2, 74], [2, 73], [2, 72], [2, 71], [2, 70], [2, 69], [2, 68], [2, 67], [2, 66], [2, 65], [2, 64], [2, 63], [2, 62], [2, 61], [2, 60], [2, 59], [2, 58], [2, 57], [2, 56], [2, 55], [2, 54], [2, 53], [2, 52], [2, 51], [2, 50], [2, 49], [2, 48], [2, 47], [2, 46], [2, 45], [2, 44], [2, 43], [2, 42], [2, 41], [2, 40], [2, 39], [2, 38], [2, 37], [2, 36], [2, 35], [2, 34], [2, 33], [2, 32], [2, 31], [2, 30], [2, 29], [2, 28], [2, 27], [2, 26], [2, 25], [2, 24], [2, 23], [2, 22], [2, 21], [2, 20], [2, 19], [2, 18], [2, 17], [2, 16], [2, 15], [2, 14], [2, 13], [2, 12], [2, 11], [2, 10], [2, 9], [2, 8], [2, 7], [2, 6], [2, 5], [2, 4], [2, 3], [2, 2], [2, 1], [2, 0], [1, 59], [1, 58], [1, 57], [1, 56], [1, 55], [1, 54], [1, 53], [1, 52], [1, 51], [1, 50], [1, 49], [1, 48], [1, 47], [1, 46], [1, 45], [1, 44], [1, 43], [1, 42], [1, 41], [1, 40], [1, 39], [1, 38], [1, 37], [1, 36], [1, 35], [1, 34], [1, 33], [1, 32], [1, 31], [1, 30], [1, 29], [1, 28], [1, 27], [1, 26], [1, 25], [1, 24], [1, 23], [1, 22], [1, 21], [1, 20], [1, 19], [1, 18], [1, 17], [1, 16], [1, 15], [1, 14], [1, 13], [1, 12], [1, 11], [1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1], [1, 0], [0, 59], [0, 58], [0, 57], [0, 56], [0, 55], [0, 54], [0, 53], [0, 52], [0, 51], [0, 50], [0, 49], [0, 48], [0, 47], [0, 46], [0, 45], [0, 44], [0, 43], [0, 42], [0, 41], [0, 40], [0, 39], [0, 38], [0, 37], [0, 36], [0, 35], [0, 34], [0, 33], [0, 32], [0, 31], [0, 30], [0, 29], [0, 28], [0, 27], [0, 26], [0, 25], [0, 24], [0, 23], [0, 22], [0, 21], [0, 20], [0, 19], [0, 18], [0, 17], [0, 16], [0, 15], [0, 14], [0, 13], [0, 12], [0, 11], [0, 10], [0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1], [0, 0]]


As this is , the aim of the game is to get your byte count as low as possible

• Is it ok to ommit the first value? I.e. the one that is equal to the input. So for [0, 90] the sequence would start at [0, 89]? Jun 27 at 13:46
• @mousetail I'm going to say no to that. The microwave shows the time you input in the sequence it displays, so it should be in the output list Jun 27 at 13:48
• My microwave timer and a direct-entry free-standing timer I have both have fixed two-digit fields allowing entries limited to 99 or less. Some answers here work with values greater than 99. Should answers instead be limited to 99? Jun 30 at 14:42

Doesn't output 0:0

0?0=[]
n?0=(n,0):(n-1)?59
n?m=(n,m):n?(m-1)


Try it online!

This is very simple. Decrements the second hand unless it's zero, in which case it decrements the minute unless it's zero in which case it ends.

Outputs 0:0

n?m=(n,m):[n?(m-1),[(n-1)?59|n>0]>>=id]!!(0^m)


Try it online!

This one is a bit more complicated than the last. It employs two special tricks for cheaper branching.

To check the second hand m. We do 0^m which gives $$\1\$$ when m is $$\0\$$ and $$\0\$$ otherwise. We can use this to index a list to switch between the two options.

To check the minute hand n. We use a list comprehension trick. [(n-1)?59|n>0] is empty when n is zero and [(n-1)?59] otherwise. We use >>=id to concat away the wrapping list and then we get (n-1)?59 when n>0 and [] otherwise.

• It looks like combining your two solutions gives 42 bytes without 0:0
– xnor
Jun 29 at 11:46
• 39 bytes with -XTupleSections (the code in my deleted comment was wrong)
– xnor
Jun 29 at 11:55
• @xnor That (still) can be converted to an 41 byte answer without -XTupleSections. Jun 29 at 12:02

# R, 41 bytes

f=\(m,s,~=rbind)t(m~s:0)~if(m)f(m-1,59)

Attempt This Online!

Makes a 2-column matrix of the minutes and seconds...zero. Then, if the minutes are non-zero, appends the matrix from a recursive call to itself with m-1 minutes and 59 seconds.

# C (gcc), 43 bytes

f(n){printf("%d ",n);n&&f(n%100?n-1:n-41);}


Try it online!

# Jelly, 1312 11 bytes

ȷ2ḍ41*ạµ¹Ð¿


Try it online!

-1 thanks to Zion mycelia adamancy, and another -1 with inspiration from their suggestion

Uses flat integer I/O.

Could almost be 10 (ạ41$’ọ?Ƭȷ2), but that fails for inputs under 41.  µ¹Ð¿ Collect results to (and through) 0 from: 41* raise 41 to the power of ȷ2ḍ if the number is divisible by 100, ạ and take its absolute difference with that.  • Can you save a byte by subtracting 40 "divisible by 100" times, then decrementing? Or, potentially, subtract by 40 * "divisible by 100", then decrement? Jun 28 at 1:17 • 12 bytes with a few tweaks - ȷ2ḍ×40‘ạµ¹Ð¿ Jun 28 at 1:25 • @JonathanAllan That's what I'm already writing in verbatim ;) Jun 28 at 1:26 • 10 with link I/O Jun 28 at 1:57 • @emanresuA I think that this "Link I/O" when using ³ to get at $100$ (or similar) is probably not acceptable. While it is a reusable function that can be called with its argument, it cannot be used inside any program that accepts command-line arguments, but it is also not a full program by itself (it could be by reading from STDIN, but that would cost bytes). Jun 28 at 10:36 # Python 3, 52 bytes f=lambda m,s:m+1and[[m,s]]+f(m-0**s,(s or 60)-1)or[]  Try it online! # K (ngn/k), 24 bytes (|/){x-$[*|x;!2;1 -59]}\


Try it online!

-1 byte thanks to @dzaima! -3 bytes thanks to @coltim!

## Explanation

Input is l.

• (|/){...}\ while l is not 0 0 (keeping intermediate results)...
• x-... decrement the timer by...
• $[*|x;...;...] if seconds > 0... • !2 equivalent to 0 1, so [x[0]-0, x[1]-1] • 1 -59 otherwise reset seconds, so [x[0]-1, x[1]-(-59)] • There may be some further golfs but I was able to get to 24 bytes with: (|/){x-$[*|x;!2;1 -59]}\  Jun 29 at 12:39
• @coltim wow thanks! was stumped on how to get around that pesky x y stuff Jun 29 at 13:25

# Vyxal, 12 bytes

⁽⌊λ₁Ḋ40*›-;ŀ


Try it Online!

Port of Jelly answer. Takes single integer and outputs list of ints.

• Oh yes, you're right, and sorry, I didn't spot that bit in the question. Jun 27 at 17:14

# C (GCC), 78 bytes

main(h,m){for(scanf("%d%d",&h,&m);h+m;m?--m:--h&(m=59))printf("%d %d\n",h,m);}

Attempt This Online!

# Rust, 113 100 bytes

|t:(u8,u8)|(0..t.0*60+t.1).scan(t,|t,_|Some((*t,*t=match t{(n,0)=>(*n-1,59),(m,s)=>(*m,*s-1)}).0));


Had to increase it to follow rules more strictly. Skips the (0,0) at the end.

# Brainfuck, 36 bytes

,+>,+<[->[-<.>.]>----[<+>----]<---<]


Try it online!

There are no separators and output is just hours minutes hours minutes ... in form of bytes.

Separator -1 can be added at the cost of 7 bytes (totaling 43 bytes):

->,+>,+<[->[-<.>.<<.>>]>----[<+>----]<---<]


Explanation:

,+                    load hours
<[-                   loop through all hours
>[-                 loop through all minutes
<.>.              print hours and minutes
]
>----[<+>----]<---< set minutes to 60; constant is take from esolangs wiki
]


# HBL, 15.5 bytes

1'.(?,('?.(-,)).('?(-.)(-'-*))?


Takes the minutes and seconds as separate arguments to the main program; outputs a list of two-number lists. Try it here!

### Explanation

1'.(?,('?.(-,)).('?(-.)(-'-*))?
1                                Cons
'.                              the argument list
to:
(?                             If
,                            the second argument (is nonzero):
('?     )                    Recursive call
.                         with the same first argument
(-,)                     and a decremented second argument
Else if
.                  the first argument (is nonzero):
('?          )     Recursive call
(-.)            with a decremented first argument
and a second argument of
(-   )      the difference between
'-        64
*       and 5
Else:
?    Empty list

• Unless you find a way to store half a byte, I believe this must be rounded up to 16. Jul 2 at 0:44
• @Makonede That was the rule, but we've come to a new consensus on fractional bytes. Jul 2 at 3:07

# JavaScript (ES6),  42  41 bytes

Expects (m)(s). Returns a list of [minutes, seconds] pairs.

m=>g=s=>~m?[[m,s],...g(s?s-1:m--&&59)]:[]


Try it online!

# Javascript, 49 bytes

let g=a=>([b,c]=a,(b+c)?[g([b-!c,c?c-1:59]),a]:a)


A recursive function that takes in an array like [minutes, seconds], and repeatedly appends it to the array that contains the next values.

• Welcome to Code Golf, and nice first answer! Be sure to check out our Tips for golfing in Javascript page for ways you can golf your program Jun 28 at 0:51
• Thanks! I'll go check it out. Jun 28 at 0:58
• I'm not sure if this is allowed, because it seems to repeatedly nest like [[[[0,0],[0,1]],[0,2]],[0,3]]. However, here's 47 bytes that works corectly Jun 28 at 1:11

n#m=(n,r m)?(r$n-1,r 59) r n=anyOf[0..n]  Try it online! This is a non-deterministic function whose return values are the all the ouputs. # 05AB1E, 12 bytes [=Ð_#тÖ40*>-  I/O as integers. Outputs everything on a separated line to save bytes. Explanation: [ # Loop indefinitely: = # Print the current number with newline (without popping) # (which will be the implicit input-integer in the first iteration) Ð # Triplicate the value _ # Pop one, and if it's 0: # # Stop the infinite loop тÖ # (Else) Pop another, and check if it's divisible by 100 40* # Multiply that by 40 > # Increase that by 1 - # Decrease the value by this  # K (ngn/k), 18 bytes {(x,'!y+1),+!x,60}  Try it online! Uses the fact that outputted times can be returned in any order. Using the descending order would costs 2 bytes: {(x,'|!y+1),|+!x,60}. # Husk, 12 bytes ↑Σ¡?-41←¦100  Try it online! Port of unrelated string's answer: upvote that. Inputs & outputs as simple integers (so, no separator between minutes & seconds). ↑Σ¡?-41←¦100 ¡ # apply function repeatedly, collect values in infinite list: ? # if: ¦100 # it's divisible by 100 -41 # then: subtract 41 ← # else: decrement ↑ # finally, get longest prefix where function gives truthy result: Σ # sum (of secs, mins)  Previous approach: # Husk, 15 bytes ↑Σ¡?ż-ḋ2ȯe59←→←  Try it online! Outputs as [[secs,mins]...], omitting [0,0] at the end.  ¡ # apply function repeatedly, collect values in infinite list: ? # if: ← # the first element is nonzero ż-ḋ2 # then: zip-subtract 1,0 (binary digits of 2) ȯe59 # else: make a 2-element list of 59 and ←→ # the last element, decremented ↑ # finally, get longest prefix where function gives truthy result: Σ # sum (of secs, mins)  # J, 25 24 bytes (,.i.,])(,,/)60,"0/&i.~[  Try it online! # Retina 0.8.2, 79 74 bytes \d+$*
\G1
1$'¶ 1>:.* :59$*
%(r1\G
¶$1 O^ (1*):(1{10})*(1*)$.1:$#2$.3


Try it online! Takes input in m:ss format. Output includes both start and end times. Explanation:

\d+
$*  Convert to unary. \G1 1$'¶


Count down to 0 minutes.

1>:.*
:59$*  Subsequent minutes count down from 59. %(  Apply the rest of the script to each minute individually. r1\G ¶$1
O^


Count down to 0 seconds.

(1*):(1{10})*(1*)
$.1:$#2$.3  Convert to decimal. # Rust, 67 bytes |mut h,mut m,f:fn(u8,u8)|while h+m>0{f(h,m);if m<1{h-=1;m=60};m-=1}  This one takes a function pointer, and outputs by calling that function. Playground link (without gist), for which I ruthlessly plagiarised mousetale's test harness. Without that, I probably wouldn't've written this answer. There's a shorter (60 byte) version, if you replace the while h+m>0 with loop. That only works in debug mode, though – in which it exits the loop by panicking – so I don't know that it counts. # Zsh, 46 bytes m=({$1..0})
echo $m[1]:{$2..0} ${^m:1}:{59..0}  Try it online! The ^ flag sets the RC_EXPAND_PARAM flag for that expansion. The list is needed because {a..b} never expands to zero arguments, while ${^foo} does.

# *><>, 64 bytes

c5*&       1+\
/!?)0:C31-1  <
\r:?!;1-r~&:&/
>r:r:{ao\
R no" "n/


Try it online!

I'd like to believe this could be golfed more, mostly in the output section, but this is as good as I could get it.

Using the -i flag, the stack is initialize with [<minutes>, <seconds>]. Throughout the program, the "canon" seconds can be considered to be at the top of the stack, and minutes right below that.

Main loop:
c5*&            Push 60 onto the stack, and then pop it into a register
1+   Add 1 to the seconds, this way our starting time is printed correctly
\  Mirror the IP down

<  Change IP direction to the left
-1     Subtract one from our seconds
C31       Go to the print function
:          Duplicate our seconds
0           Push 0 onto the stack
)            Check if the seconds is greater than 0
!?             If it is, IP continues left, wrapping back to our < instruction
/               Else, mirror the IP down

\               Mirror the IP to the right
r:             Put the minutes on top of the stack and duplicate it
?!;          If the minutes and the seconds are 0, end execution
1-        Else, subtract one from the minutes
r       Put the seconds back on top of the stack
~      Remove the seconds
&:&    Take 60 out of the register, duplicate it, and pop that duplicate back into the register
/   Mirror the IP up into the < on line 2

Print function:
>               Change the IP direction to the right
r:             Reverse the stack, and duplicate the top value
r:           Repeat
{          Shift the stack to the left. Stack should look like [m, s, s, m]
ao        Print a newline
\       mirror the IP down
/       Mirror the IP to the left
n        Pop the top of the stack, print it as a number
o" "         Print a space
n             Pop the top of the stack, print it as a number
R               Return the IP to where it was, maintaining current direction


# Factor + math.unicode pair-rocket, 60 bytes

[ [ .s dup last 0 = 1 => -59 "\0"? v- dup Σ 0 > ] loop . ]


Try it online!

Outputs times to standard output in the format { minutes seconds }, one per line, in the order they would be seen on the microwave display.

# Charcoal, 17 bytes

ＩＥ⊕θＥ⎇‹ιＩθ⁶⁰⊕η⟦ιλ


Try it online! Link is to verbose version of code. Takes minutes and seconds as separate input and outputs a list of lists of lists of minute and second pairs in ascending order. Explanation:

   θ                First input
⊕                 Incremented
Ｅ                  Map minutes over implicit range
ι            Current minute
‹             Is less than
θ          First input
Ｉ           Cast to integer
⎇              If true then
⁶⁰        Literal integer 60 else
η      Second input
⊕       Incremented
Ｅ               Map seconds over implicit range
⟦ιλ   Minute and second as a list
Ｉ                   Cast to string
Implicitly print


# Perl 5-a, 43 bytes

do{say"@F";@F=(--$_,59)if!$F[1]--}until\$_<0


Try it online!

Minutes and seconds are space separated in both input and output.

# Julia, 39 bytes

m>s=show((m,s))~s<1 ? -1<m-1>60 : m>s-1


Try it online!

Takes input as two arguments (1>90), prints the values as tuples and ends with an error

# Pyth, 18 bytes

WsQQ=?eAQ,GtH,tG59


Try it online!

Doesn't include [0,0]

WsQQ=?eAQ,GtH,tG59
(Q implicitly initialized as the input)
WsQ                 While sum(Q) > 0:
Q                 Output Q
AQ            Set [G,H] = Q (minutes and seconds, respectively)
=                Update Q to the following:
?e Q             If (seconds) > 0:
,GtH          [(minutes), (seconds) - 1]
Else:
,tG59     [(minutes) - 1, 59]


If single-integer output is allowed:

### Pyth, 15 bytes

WQQ=-Q^41!%Q100
`

Try it online!