26
\$\begingroup\$

You are an employee of Microteque, a leading Silicon Valley startup creating smart microwave ovens for all kinds of strange places. Your customers can get their microwaves printed with patterns to match their kitchens, campers, man caves; even the kitchens of large nation-state facilities have shiny new branded microwave ovens.

Due to the cutting-edge nature of your microwave control board technology, you've ended up having to use the programming language MicrowaveX* and you're working out how to program the time counter. Your counter looks like this:

seven segment display showing 88:88

Your goal is to write a program that takes the input time and translates it into the number of seconds that the microwave needs to run.

As input, the function must take a string in the format ##:## (including the colon at position 3) and return an integer.

Please note that it should also be able to handle more than 60 seconds in the seconds slot.

Finally, due to some pesky regulations, you cannot have your microwave oven run for more than 100 minutes (6,000 seconds)

Sample inputs and outputs:

01:30 --> 90 seconds

00:66 --> 66 seconds

01:99 --> 159 seconds

02:39 --> 159 seconds

99:99 --> 6,000 seconds (capped at 100 minutes due to aforementioned regulations)

*: MicrowaveX happens to be identical to your programming language of choice, but Microteque has rebranded it to sound more appealing to their investors.

\$\endgroup\$
8
  • 6
    \$\begingroup\$ What's the scoring criteria? Code Golf? \$\endgroup\$ May 19, 2020 at 15:41
  • 2
    \$\begingroup\$ 99:99 = 99 min 99 sec is 100 min 39 sec. 100 minutes exactly is 99:60. Is this test case 99:99 intentional or not? (I see it says it would be capped to 100min due to regulations.) \$\endgroup\$ May 19, 2020 at 20:47
  • 3
    \$\begingroup\$ I'd love to program in MicrowaveX for this challenge. Care to link to the website of the language? \$\endgroup\$
    – user92069
    May 20, 2020 at 8:27
  • 1
    \$\begingroup\$ @ Λ̸̸ I think this might be it... scratch.mit.edu \$\endgroup\$
    – AJFaraday
    Jun 3, 2020 at 22:21
  • 1
    \$\begingroup\$ I once had a microwave that, if you entered 00:60 instead of 01:00, it would say "Error" instead of actually starting the timer. I have no idea why, and I've never seen another one like that since. \$\endgroup\$
    – Bbrk24
    Aug 8 at 19:55

53 Answers 53

18
\$\begingroup\$

Bash + GNU utilities, 33 bytes

dc<<<[6000]sL${1/:/ 60*}+dlLx\<Lp

Try it online!

Or try the test suite.

The input string is passed as an argument, and the output is on stdout.


How it works

First bash expands ${1/:/ 60*} by taking argument 1 and replacing the : with 60* (there's a space before the 60 that StackExchange isn't displaying here). For example, if the input is 01:30, the expansion is 01 60*30.

Also, \< gets used as the character < without its special meaning in the shell.

So what happens is that dc is run with

[6000]sLminutes60*seconds+dlLx<Lp

as its program (where "minutes" and "seconds" refer to the actual two-digit numbers).

This carries out the following operations:

[6000]               Definition of a macro which pushes 6000 on the stack.
sL                   Save the macro in register L.
minutes 60*seconds+  Compute minutes*60+seconds,
                        which is the total number of seconds.
d                    Duplicate the total number of seconds on the stack.
lLx                  Run macro L, which pushes 6000 on the stack.
                     The stack now looks like:
                        #seconds #seconds 6000
                        (top of stack on the right).
<L                   Pop 6000 and #seconds from the stack;
                        if 6000 < #seconds,
                          then run macro L to push 6000 on the stack again.
                     At this point, the item at the top of the stack is:
                        #seconds, if #seconds <= 6000,
                        6000, if #seconds > 6000.
p                    Print the top of the stack.
\$\endgroup\$
3
  • 1
    \$\begingroup\$ I'd love to see an explanation \$\endgroup\$
    – Jonah
    May 20, 2020 at 13:16
  • 1
    \$\begingroup\$ @Jonah Explanation posted! \$\endgroup\$ May 20, 2020 at 17:12
  • 1
    \$\begingroup\$ ${1/:/ 60*} Devilish use of parameter expansion <3 \$\endgroup\$
    – Jonah
    May 20, 2020 at 17:22
11
\$\begingroup\$

Python 2, 42 bytes

lambda t:min(int(t[:2])*60+int(t[3:]),6e3)

Try it online!

\$\endgroup\$
2
  • 2
    \$\begingroup\$ I think the first one doesn't work for anything with 08 or 09 because of octal interpretation. \$\endgroup\$
    – Jason
    May 20, 2020 at 17:46
  • \$\begingroup\$ @Jason You are right :) \$\endgroup\$ May 20, 2020 at 17:51
10
\$\begingroup\$

Retina 0.8.2, 27 24 bytes

\d+
$*
+`1:
:60$*
6000`1

Try it online!

Explanation

I'll use the input 01:30 as an example.

\d+
$*

Convert minutes and seconds to unary. For example, 01:30 would become 1:111111111111111111111111111111.

+`1:
:60$*

Loop over each digit preceding the :, move it to the right of the :, and repeat the digit 60 times. The 01:30 example would now be :1111111111111111111... (90 ones)

6000`1

Count the first 6000 ones.

\$\endgroup\$
9
\$\begingroup\$

JavaScript (ES6), 42 bytes

s=>Math.min(6e3,+([m]=s.split`:`)[1]+m*60)

Try it online!

Commented

s =>               // s = input string
  Math.min(        // return the minimum of ...
    6e3,           //   ... 6000 and the following result ...
    +(             //   coerce to integer:
      [m] =        //     store into m the number of minutes
        s.split`:` //     which is the first term of the array obtained
                   //     by splitting s on ':'
    )[1] +         //   yield the seconds (2nd term of the above array)
    m * 60         //   and add the seconds multiplied by 60
  )                // end of Math.min()
\$\endgroup\$
9
\$\begingroup\$

Google Sheets, 32 16 bytes

Saved 16 bytes thanks to Chronocidal straight up commenting a better answer.

=240*MIN(25,6*A1

Sheets will automatically add two trailing parentheses when you exit the cell. Input is in A1.


This could also be written as Min(6000,86400*TimeValue("0:"&A1)) if we wanted to fully expand it and be precise. As it is, we take advantage of the fact that Sheets will interpret a string that looks like a time to be in the format hh:mm by default and treat it as a number of days. For instance, =1*"12:00" would return 0.5 and =1*"6:00" would return 0.25. We can then divide by 60 to convert from hh:mm to mm:ss. If that's the only simplification we used, it would look like this:

=Min(6000,1440*A1

Dividing both 6000 and 1440 by 240 saves us 5 bytes inside the Min() function at a cost of only 4 bytes outside of it.

enter image description here

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Would treating it as "HH:MM" and multiplying by 1440 be better than treating it as "MM:SS" and multiplying by 86400? i.e. =240*MIN(6*A1,25 \$\endgroup\$ Jun 16, 2020 at 13:48
  • \$\begingroup\$ I mean, yeah, by a lot! Great idea. \$\endgroup\$ Jun 16, 2020 at 15:43
8
\$\begingroup\$

J, 21 19 bytes

6e3<.60#.[:".' '2}]

Try it online!

  • [:".' '2}] Convert the : to a space, then evaluate the string as a list of numbers.
  • 60#. Interpret result in base 60.
  • 6e3<. Minimum of that and 6000.
\$\endgroup\$
8
\$\begingroup\$

C (gcc), 61 50 bytes

Saved a whopping 11 bytes thanks to dingledooper!!!

s;f(char*t){s=atoi(t)*60+atoi(t+3);s=s<6e3?s:6e3;}

Try it online!

\$\endgroup\$
0
7
\$\begingroup\$

perl -MList::Util=min -plF: -E, 25 bytes

$_=min 60*$F[0]+$F[1],6E3

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Nice! You can save a few bytes using $_ instead of $F[0] (since Perl will ignore the content after the non-numeric character when treating as a number) and if you split on -F/\d\d:/ you can just use "@F" so save another byte vs. $F[1]. Also, $= is pre-initialised to 60 so you can avoid the space using that too! \$\endgroup\$ May 19, 2020 at 18:34
  • \$\begingroup\$ Try it online! \$\endgroup\$ May 19, 2020 at 18:34
7
\$\begingroup\$

Batch, 55 bytes

@set/ps=
@cmd/cset/a"(s=%s::=*60+%)+(s-=6000)*(-s>>13)

Takes input on STDIN. Explanation: %s::=*60+% substitutes *60+ for the : in the input, resulting in an arithmetic expression that converts the time into seconds. Since Batch has no minimum function, I then have to compute this via right-shifting the the difference which results in 0 or -1 which is then used to adjust the seconds, which are then automatically output thanks to the use of cmd/c.

\$\endgroup\$
2
  • \$\begingroup\$ What's the lone double quote for? \$\endgroup\$ May 20, 2020 at 15:10
  • \$\begingroup\$ @SomethingDark Batch doesn't require the trailing quote. The string needs to be quoted because it contains >> which would otherwise be interpreted as output redirection. \$\endgroup\$
    – Neil
    May 20, 2020 at 16:07
7
\$\begingroup\$

Python 3, 82 72 62 61 57 bytes

def f(s):x,y=map(int,s.split(":"));return min(x*60+y,6e3)

Try it online!

  • -10 bytes by using min().
  • -10 bytes from Arnauld!
  • -1 byte from nope!
  • -4 bytes from Chas Brown!
\$\endgroup\$
3
  • 1
    \$\begingroup\$ 62 bytes \$\endgroup\$
    – Arnauld
    May 19, 2020 at 16:49
  • \$\begingroup\$ 61 bytes \$\endgroup\$
    – nope
    May 19, 2020 at 20:17
  • \$\begingroup\$ 57 bytes \$\endgroup\$
    – Chas Brown
    May 19, 2020 at 23:08
6
\$\begingroup\$

Japt, 12 bytes

Feel like I'm missing a trick here ...

q': ì60 m6e3

Try it

q': ì60 m6e3     :Implicit input of string
q':              :Split on ":"
    ì60          :Convert to integer from base-60 digit array
        m6e3     :Minimum with 6000
\$\endgroup\$
6
\$\begingroup\$

MathGolf, 14 bytes

2<i╟*l2>i+6♪*╓

Try it online.

Explanation:

                #  i.e. input = "99:80"
2<              # Take the first two characters of the (implicit) input-string
                #  STACK: ["99"]
  i             # Convert it from string to integer
                #  STACK: [99]
   ╟*           # Multiply it by 60
                #  STACK: [5940]
     l          # Push the input-string again
                #  STACK: [5940,"99:80"]
      2>i       # Leave its last two characters, and also cast it to an integer
                #  STACK: [5940,80]
         +      # Add them together
                #  STACK: [6020]
          6♪*   # Push 6*1000: 6000
                #  STACK: [6020,6000]
             ╓  # Only leave the smallest value of the top two values on the stack
                #  STACK: [6000]
                # (after which the entire stack joined together is output implicitly)
\$\endgroup\$
1
  • 1
    \$\begingroup\$ I found another 14-byter, I noticed that you could extract both parts of the clock using 2‼><, but it didn't save me any bytes in the end. \$\endgroup\$
    – maxb
    May 25, 2020 at 8:45
6
\$\begingroup\$

Whitespace, 167 bytes

[S S S T    S T T   T   S T T   T   S S S S N
_Push_6000][S N
S _Duplicate_6000][S N
S _Duplicate_6000][S N
S _Duplicate_6000][T    N
T   S _Read_STDIN_as_char][T    T   T   _Retrieve][S S S T  T   S S S S N
_Push_48][T S S T   _Subtract][S S S T  S S T   S T T   S S S N
_Push_600][T    S S N
_Multiply][S N
S _Duplicate][S N
S _Duplicate][T N
T   S _Read_STDIN_as_character][T   T   T   _Retrieve][S S S T  T   S S S S N
_Push_48][T S S T   _Subtract][S S S T  T   T   T   S S N
_Push_60][T S S N
_Multiply][T    S S S _Add][S N
S _Duplicate][T N
T   S _Read_STDIN_as_character][S N
S _Duplicate][S N
S _Duplicate][T N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve][T    S S S _Add][S N
T   _Swap_top_two][T    S S T   _Subtract][S N
S _Duplicate][N
T   T   N
_If_negative_jump_to_Label_PRINT][S N
S _Duplicate][T S S T   _Subtract][N
S S N
_Create_Label_PRINT][T  S S S _Add][T   N
S T _Print_as_integer]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online (with raw spaces, tabs and new-lines only).

Explanation in pseudo-code:

Unfortunately Whitespace is unable to read an integer when there is anything other than a newline (or nothing) behind it. Because of this, the minute-digits has to be read loose as characters, and seconds can be read as an integer..

Integer m1 = Read STDIN as character
m1 = m1 - 48
m1 = m1 * 600
Integer m2 = Read STDIN as character
m2 = m2 - 48
m2 = m2 * 60
Integer m = m1 + m2
Read STDIN as character (the ':', which we simply ignore)
Integer s = Read STDIN as integer
Integer total_seconds = m + s
If(total_seconds - 6000 < 0):
  Print total_seconds as integer to STDOUT
Else:
  Print 6000 as integer to STDOUT
\$\endgroup\$
4
\$\begingroup\$

Befunge-93, 35 bytes

&~$"<"*&+:v
v!`*"<""d"<
_"d""<"*.@.

Try it online!

Reads a number, read a character (:) and discard it, multiply the read number with 60 (ASCII character 60 equals "<"), read the second number, and add it to the product (this gives the number of seconds). Dub the number of seconds; push 6000 (6000 = 60 * 100 = "<" * "d") on the stack and compare. If 6000 is less than the number of seconds, push another 6000 on the stack and print it. Else, print the number of seconds (which is now the top of the stack).

\$\endgroup\$
2
4
\$\begingroup\$

Jelly, 10 bytes

ṣ”:Vḅ60«6ȷ

A monadic Link accepting a list of characters which yields an integer.

Try it online!

How?

ṣ”:Vḅ60«6ȷ - Link: list of characters, T
 ”:        - character ':'
ṣ          - split T at ':'
   V       - evaluate as Jelly code -> [m,s]
     60    - sixty
    ḅ      - convert from base -> 60*m+s
        6ȷ - 6*10^3 = 6000
       «   - minimum
\$\endgroup\$
4
\$\begingroup\$

Ruby, 41 bytes

->i{[i[0,2].to_i*60+i[3,2].to_i,6e3].min}

Try it online!

16 bytes saved thanks to math-junkie

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You can save quite a few bytes using slicing instead of split and inject: Try it online! \$\endgroup\$ May 20, 2020 at 21:16
  • \$\begingroup\$ Thanks, I was looking for something way too complicated! \$\endgroup\$ May 20, 2020 at 21:31
4
\$\begingroup\$

C++ (gcc), 92 bytes

#import<iostream>
main(){int m,s;char x;std::cin>>m>>x>>s;std::cout<<std::min(m*60+s,6000);}

Try it online!

Special Thanks to math junkie.

Special Thanks to ceilingcat for the educative suggestion.

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Hello and welcome to CGCC! You actually need to include your imports and usings in your byte count. It looks like your answer has quite a bit of unnecessary whitespace as well. Here is a version of your code with whitespace removed, endl removed, and a shorter import :) \$\endgroup\$ May 20, 2020 at 16:30
  • \$\begingroup\$ Thank you, math junkie, for the correction :) \$\endgroup\$ May 20, 2020 at 17:37
  • \$\begingroup\$ Thank you ceilingcat, I have made the change :) \$\endgroup\$ May 21, 2020 at 13:42
4
\$\begingroup\$

x86-16 machine code, 30 bytes

Binary:

00000000: 33d2 e806 00b2 3cf6 e292 acad 2d30 3086  3.....<.....-00.
00000010: c4d5 0a03 c2ba 7017 3bc2 7e01 92c3       ......p.;.~...

Listing:

33 D2           XOR  DX, DX         ; zero DX 
E8 0006         CALL CONV           ; get minutes into AX 
B2 3C           MOV  DL, 60         ; multiplier 60 sec/min  
F6 E2           MUL  DL             ; AX = AL * 60 
92              XCHG AX, DX         ; save seconds in DX 
AC              LODSB               ; skip ':' char 
            CONV:  
AD              LODSW               ; load next two ASCII chars into AX 
2D 3030         SUB  AX, '00'       ; ASCII convert 
86 C4           XCHG AL, AH         ; endian convert 
D5 0A           AAD                 ; BCD to byte convert
03 C2           ADD  AX, DX         ; add minutes to seconds
BA 1770         MOV  DX, 6000       ; set up max comparison
3B C2           CMP  AX, DX         ; is result > 6000?
7E 01           JLE  DONE           ; if not, return current value
92              XCHG AX, DX         ; otherwise 6000
            DONE:  
C3              RET                 ; return to caller

Input string in [SI], output number of seconds in AX.

Sample I/O using test program:

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ Should it be E8 0006 in the inline disassembly? \$\endgroup\$
    – anatolyg
    Jun 28, 2020 at 15:20
  • \$\begingroup\$ @anatolyg - indeed is does. Good eye! \$\endgroup\$
    – 640KB
    Jun 28, 2020 at 15:23
3
\$\begingroup\$

Charcoal, 13 bytes

I⌊⟦↨I⪪S:⁶⁰×⁶φ

Try it online! Link is to verbose version of code. Explanation:

      S         Input string
     ⪪ :        Split on literal `:`
    I           Cast each part to integer
   ↨    ⁶⁰      Convert from base 60
           ⁶    Literal 6
          ×     Multiplied by
            φ   Predefined variable 1000
 ⌊⟦             Take the minimum
I               Cast to string
                Implicitly print
\$\endgroup\$
3
\$\begingroup\$

Perl 5 with -plF/((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((\d+)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))):(\d+)/ -MList::Util+sum,min, 16 bytes

Not competing with @Abigail's answer which is not 'cheaty' like this one.

$_=min 6e3,sum@F

Try it online!

Explanation

Using the -F flag, the left part of the input is replicated 60 times and the right part is extracted once, into @F. These are summed to yield the number of seconds and we use min to ensure it's not over 6000.

\$\endgroup\$
3
\$\begingroup\$

Tcl, 54 bytes

proc f {a} {scan $a %d:%d a b
expr min(60*$a+$b,6000)}

Try it online!

Explanation

Sadly, the times with leading zeroes mess up string interpolation directly into expr (using ternaries) because Tcl thinks they are octal, so I had to settle for using scan to force interpretation as decimal. Also, if 6000.0 is allowed as output, I can save 1 byte.

\$\endgroup\$
2
3
\$\begingroup\$

05AB1E, 11 bytes

':¡60β6₄*)W

Try it online!

Coincidental port of most answers.

Explained

':¡60β6₄*)W

min(lhs: base10(number: split(string: input, character: ":"), from: 60), rhs: times(lhs: 6, rhs: 1000))

':  | Push the character ":"
¡   | Split the input upon ":"s -> [mins, seconds]
60β | Convert the list from base 60 to base 10
6₄* | Push the number `6000`
)W  | Wrap the converted input and 6000 into a list and find the smallest.
\$\endgroup\$
3
\$\begingroup\$

Rust, 82 bytes

|s:&str|6000.min(60*s[..2].parse::<u32>().unwrap()+s[3..].parse::<u32>().unwrap())

Try it online!

Unfortunately type inference for parse is very restricted and the turbofish must be used every time.

I also made some versions using fold instead of parse, but they are longer:

With a tuple accumulator and a closure to combine minutes and seconds:

|s:&[u8]|6000.min((|(a,b)|60*a+b)(s.iter().fold((0,0),|(a,b),x|match x{58=>(b,0),_=>(a,10*b+*x as i32-48)})))

Using a [i32;2] accumulator and .iter().sum()

|s:&[u8]|6000.min(s.iter().fold([0,0],|[a,b],x|match x{58=>[60*b,0],_=>[a,10*b+*x as i32-48]}).iter().sum())

And then there's this ungodly abomination using std::ops::Range<i32> as an accumulator, with -60*minutes as the start and seconds as the end. Eww.

|s:&[u8]|6000.min(s.iter().fold(0..0,|a,x|match x{58=>-60*a.end..0,_=>a.start..10*a.end+*x as i32-48}).len())
\$\endgroup\$
2
\$\begingroup\$

APL+WIN, 20 bytes

Prompts for time as string:

6E3⌊60⊥(⍎2↑n),⍎3↓n←⎕

Try it online! Courtesy of Dyalog Classic

\$\endgroup\$
2
\$\begingroup\$

Burlesque, 19 bytes

ps1RAp^60.*.+6000<.

Try it online!

Explanation:

ps                  # Parses input string as block: mm:ss => { mm ":" ss }
  1RA               # Removes element at index 1 from block: { mm ss }
     p^             # Splits block to stack
       60.*         # Multiply top element by 60
           .+       # Sum both elements
             6000<. # Return the minimum of the calculated value or 6000
\$\endgroup\$
2
\$\begingroup\$

Husk, 13 bytes

y6000B60mrx":

Try it online!

Explanation

          x":    Split on colons
        mr       Convert from string form
     B60         Interpret in base 60
y6000            Minimum with 6000
\$\endgroup\$
2
\$\begingroup\$

CJam, 17 bytes

q':/:i~\60*+6e3e<

Try it online!

q':/:i~\60*+6e3e<  e# Whole program
q                  e# Read input          [e.g "99:98"]
 ':/               e# Split on :          [e.g ["99" "98"]]
    :i             e# Convert to integers [e.g [99 98]]
      ~\           e# Dump and swap       [e.g 98 99]
        60*        e# Multiply by 60      [e.g 98 5940]
           +       e# Add                 [e.g 6038]
            6e3e<  e# Get minimum to 6000 [e.g 6000]
                   e# Implicit output
\$\endgroup\$
2
\$\begingroup\$

Befunge-93 (FBBI), 25 bytes

"<|`*"<d":+&*&
@.<
*"<d@.

Try it online!

Explanation:

The program consists of three parts (lines), the first one processes the input:

"<|`*"<d":+&*&    Stack                              IP direction

                  empty                              east
"<|`*"          push everything between the two quotes
                  42, 96, 124, 60                    east
      <         turn west
                  42, 96, 124, 60                    west
"<|`*"          push everything between the two quotes
                  60, 124, 96, 42, 42, 96, 124, 60   west
            *&  take an integer (minutes), convert to seconds
                  60*m, 124, ...                     west
          +&    take the next int, add to the total
                  60*m+s, 124, ...                   west
         :      duplicate TOS
                  60*m+s, 60*m+s, ...                west
    *"<d"       push 60*100 = 1000
                  6000, 60*m+s, 60*m+s, ...          west
   `            is greater than?
                  6000 > 60*m+s, 60*m+s, ...         west
  |             north-south if
                  60*m+s, ...                        north / south

If the total number of seconds is smaller or equal to 6000, the IP moves south and enters the second line:

@.<               Stack                              IP direction

                  60*m+s, ...                        south
  <             turn west
                  60*m+s, ...                        west
 .              print integer
                  124, ...                           west
@               Stop

If the number of second is greater than 6000, the IP moves north and enters the last line:

*"<d@.            Stack                              IP direction

                  60*m+s, ...                        north
  <             turn west
                  60*m+s, ...                        west
*"              push everything up to the next quote ...
 "<d@.          ... which is actually the same one.
                  60, 100, 64, ...                   west
*               Stop
                  6000, 64, ...                      west
     .          print 6000
                  64, ...                            west
    @           Stop
\$\endgroup\$
2
\$\begingroup\$

Pyth, 16 15 bytes

hS,6000ivcQ\:60

Try it online!

hS,6000ivcQ\:60   Implicit: Q=input()
         cQ\:     Split Q on ":"
        v         Convert each from string to integer
       i     60   Convert from base 60
  ,6000           Pair with 6000
 S                Sort
h                 Take the first element (i.e. smallest)
                  Implicit print

Edit: Previous version: hS,6000isMcQ\:60

\$\endgroup\$
2
\$\begingroup\$

Julia 54 53 52 bytes

f(x)=((i,j)=parse.(Int,split(x,":"));min(60i+j,6e3))

try it online

A single line solution for Julia.

A couple neat tricks here, we use f(x)=, a generic function declaration so we don't have to use the return end or function keywords.

We then use a compound expression like this (code;code;...).

Unfortunately, when using tuple destructuring i,j=, the tuple here must be wrapped in parenthesis for some reason, which adds two bytes.

Edits:

  • 1 byte improvement using 60i instead of 60*i
  • 1 byte improvement by removing trailing whitespace
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.