| Bytes | Lang | Time | Link |
|---|---|---|---|
| 031 | Raku Perl 6 rakudo | 240720T003625Z | bb94 |
| 089 | Go 1.21+ | 230808T194649Z | bigyihsu |
| 057 | Swift | 240301T182831Z | macOSist |
| nan | AWK | 240302T220211Z | cnamejj |
| 1575 | Nibbles | 240303T035526Z | Mike Buf |
| 059 | PARI/GP | 240302T105854Z | 138 Aspe |
| 043 | YASEPL | 240226T183740Z | madeforl |
| 015 | Itr | 230813T183348Z | bsoelch |
| 031 | ARBLE | 230816T053009Z | ATaco |
| 043 | Desmos | 230816T051341Z | fwoosh |
| 095 | Python | 230813T172445Z | user1190 |
| 035 | Pure Bash | 230813T182644Z | F. Hauri |
| 010 | Thunno 2 | 230718T101403Z | The Thon |
| 061 | Scala | 200801T155656Z | user |
| 018 | V vim | 210414T113420Z | Razetime |
| 082 | Rust | 200801T094754Z | madlaina |
| 067 | Java JDK | 200520T100413Z | Olivier |
| 076 | C# .NET Core | 200703T144948Z | EQ Code |
| 047 | JavaScript V8 | 200702T183334Z | Lebster |
| 077 | C# .NET Core | 200701T152423Z | Ben Abbo |
| 048 | PowerShell | 200630T051542Z | Veskah |
| 030 | x8616 machine code | 200527T202806Z | 640KB |
| 014 | K ngn/k | 200617T125517Z | mkst |
| 052 | Julia | 200617T104744Z | OhB00 |
| 016 | Google Sheets | 200522T142149Z | Engineer |
| 015 | Pyth | 200616T134847Z | Sok |
| 087 | C# .NET Core | 200616T130609Z | OhB00 |
| 028 | Golfscript | 200603T183657Z | LCU00 |
| 042 | JavaScript ES6 | 200519T164514Z | Arnauld |
| 056 | Python 3.8 prerelease | 200521T221909Z | Ellis Wr |
| nan | 200521T003839Z | Sean Per | |
| 071 | Julia | 200521T150033Z | MorrisMo |
| 092 | C++ gcc | 200520T151044Z | Jubayer |
| 050 | C gcc | 200520T120017Z | Noodle9 |
| 011 | 05AB1E | 200520T055419Z | lyxal |
| 041 | Ruby | 200520T210958Z | Armand F |
| 025 | Befunge93 FBBI | 200520T172747Z | ovs |
| 042 | Python 2 | 200519T165518Z | dingledo |
| 054 | Tcl | 200520T174125Z | Jason |
| 033 | Bash + GNU utilities | 200520T031553Z | Mitchell |
| 024 | Retina 0.8.2 | 200519T172447Z | math jun |
| 167 | Whitespace | 200520T160053Z | Kevin Cr |
| 088 | Dart | 200520T151430Z | Elcan |
| 046 | R | 200520T143159Z | Giuseppe |
| 057 | Python 3 | 200519T155742Z | bigyihsu |
| 017 | CJam | 200520T140739Z | lolad |
| 013 | Husk | 200520T091625Z | user9206 |
| 052 | Io | 200520T091022Z | user9206 |
| 019 | Burlesque | 200520T085409Z | Mintable |
| 020 | APL+WIN | 200520T064834Z | Graham |
| 014 | MathGolf | 200520T063809Z | Kevin Cr |
| 016 | Perl 5 with plF/\d+\d+/ MListUtil+sum | 200520T062808Z | Dom Hast |
| 010 | Jelly | 200519T230102Z | Jonathan |
| 035 | Befunge93 | 200519T213006Z | Abigail |
| 012 | Japt | 200519T163445Z | Shaggy |
| 055 | Batch | 200519T195221Z | Neil |
| 013 | Charcoal | 200519T194311Z | Neil |
| 025 | perl MListUtil=min plF E | 200519T174705Z | Abigail |
| 2119 | J | 200519T173620Z | Jonah |
Go 1.21+, 93 92 89 bytes
import."fmt"
func f(t string)int{m,s:=0,0
Sscanf(t,"%d:%d",&m,&s)
return min(6e3,m*60+s)}
- -3 by using
:=instead ofvar.
Swift, 63 57 bytes
{min(Int(($0+"").prefix(2))!*60+Int($0.suffix(2))!,6000)}
Assign this closure to something and call it with the time in "##:##" format (or just call it directly).
Since a Swift
Stringcan't be indexed using anInt(blame Unicode support, though you'd be surprised just how rareStringindexing is in well-written, real-life code), I had to use theprefix(_:)andsuffix(_:)methods instead.
AWK, 30 bytes (27 bytes + 3 penalty for -F:)
$0=6000<(a=$1*60+$2)?6000:a
Pretty straightforward one... Relies on -F: to shorten the code needed to access mins/secs components of the input.
a=$1*60+$2 - temp variable w/ simple calc of time
$0=6000<( )?6000:a - ternary to cap limit at 6000
Nibbles, 15 nibbles (7.5 bytes)
[6000+*60$;$
Explanation
*60$ # multiply first part of input by 60
+ ;$ # add second part of input
[6000 # return lesser of sum and 6000
YASEPL, 43 bytes
=s=1'±colon!¥0,1*60=m¥1,1!+m}2,6000$6000`1<
explanation:
=s=1'±colon!¥0,1*60=m¥1,1!+m}2,6000$6000`1< packed
=s set total time in seconds (S)
=1' get user input and set it to var1
±colon split it by ":"
!¥0,1*60 set S to var1[0] (minutes) and multiply it by 60
=m¥1,1!+m set M to var1[1] (seconds) and add it to S
}2,6000$6000`1 if S > 6000, set it to 6000
< print S once done
Itr, 15 bytes
ê©àé2+à©·+6000m
Explanation
ê©àé2+à©·+6000m ; implicit input
ê ; split input into two parts '##:' and '##'
© ; evaluate the second part to get the number of seconds
à ; swap
é ; split of the last character ':'
2+ ; add 2 to ':' (ascii 58) giving 60
à ; swap
© ; evaluate the number of minutes
· ; multiply minutes by 60
+ ; add seconds
6000 ; literal 6000
m ; minimum
; implicit output
Desmos, 43 bytes
Takes input in the form of a ASCII code array. Use this to convert testcases to ASCII codes.
f(S)=min(total([600,60,0,10,1](S-48)),6000)
Python, 95 Bytes
lambda i: f"Lower"if(int(i[0:2])*60)+int(int(i[3:5]))>6000else(int(i[0:2])*60)+int(int(i[3:5]))
Example Input:
76:92 # String input
Example Output:
4652 # Number of seconds
Note: You do have to call the function and print it separately
Pure Bash, 35 bytes
echo $[s=${1/:/*60+},s>6000?6000:s]
Pure Bash, 36 bytes
echo $[(r=${1/:/*60+})>(b=6000)?b:r]
Thunno 2, 10 bytes
':/60ḋ«ç⁷Ọ
Explanation
':/60ḋ«ç⁷Ọ '# Implicit input
':/ '# Split it on ":"
60ḋ # Convert from base 60
«ç⁷ # Push 6000
Ọ # Dyadic minimum
# Implicit output
Scala, 66 61 bytes
For those who like to live dangerously and assume things beyond a method's contract...
io.StdIn.readLine split ":"map(_.toInt)reduce(_*60+_)min 6000
reduce is not guaranteed to work from left to right, but it seems to do so by default.
Rust, 82 bytes
|s:&str|6000.min(60*s[..2].parse::<u32>().unwrap()+s[3..].parse::<u32>().unwrap())
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())
Java (JDK), 67 bytes
t->Math.min(6e3,new Long((t=t[0].split(":"))[0])*60+new Long(t[1]))
Credits
- -4 bytes thanks to Kevin Cruijssen by changing the input type to an array of Strings.
C# (.NET Core), 76 bytes
s=>Math.Min(s.Split(':').Select(int.Parse).Aggregate((e,i)=>(e*60+i)),6000);
JavaScript (V8), 47 bytes
i=>Math.min(6e3,(i[0]+i[1]-0)*60+(i[3]+i[4]-0))
Call the function with the input string
C# (.NET Core) 77 bytes
s=>Math.Min(60*int.Parse(s.Substring(0,2))+int.Parse(s.Substring(3,2)),6000);
It assumes that the position of the colon is always 3
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:
K (ngn/k), 14 bytes
Solution:
6000&60/.'":"\
Explanation:
6000&60/.'":"\ / the solution
":"\ / split string on ":"
.' / value (convert "12" => 12)
60/ / from base-60
6000& / min of result and 6000
Julia 54 53 52 bytes
f(x)=((i,j)=parse.(Int,split(x,":"));min(60i+j,6e3))
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
60iinstead of60*i - 1 byte improvement by removing trailing whitespace
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.
Pyth, 16 15 bytes
hS,6000ivcQ\:60
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
C# (.NET Core) 88 87 bytes
s=>{var x=s.Split(':').Select(int.Parse).ToList();return Math.Min(60*x[0]+x[1],6000);};
Removed trailing newline for 1 byte saving
JavaScript (ES6), 42 bytes
s=>Math.min(6e3,+([m]=s.split`:`)[1]+m*60)
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()
Python 3.8 (pre-release), 56 bytes
lambda x:min(int((k:=x.split(":"))[1])+60*int(k[0]),6e3)
The types and the unwrap make this longer than it could be otherwise.
Rust, 121 bytes
use std::cmp::min;fn f(s:&str)->i32{let x:i32=s[..2].parse().unwrap();let y:i32=s[3..].parse().unwrap();min(x*60+y,6000)}
Explanation:
6000 had to be used because 6e3 is considered a float. 6e3 as i32 is longer than simply using 6000. In production code I would have written it 6_000 but saving the character is the game.
min is not imported by default. So we have to pay for that import.
parse does the work of other languages type casting. But since it could fail we also need the unwrap. String to int conversions are costly in golf for Rust. Using ? operator could in theory save us the unwrap but then the type for the return needs to be much longer:
Result<i32, std::num::ParseError>. That also means the collect has to know about the Result too. We also have to wrap the final return in Ok(). So not much gain there.
I looked at using split but it ends up being longer due to working to get the tuple back out of the resulting iterator.
Julia, 71 bytes
function f(x)
m,s=parse.(Int,split(x,":"))
return min(m*60+s,6e3)
end
The part which was most interesting to me here, is the parse.() which parses each element in the array. Note the dot operator before the parentheses.
Could have knocked off one more byte by putting show() in the function instead of return. But, the footer or output box, on tio, wind up a bit of a mess due to the lack of new lines from show.
function f(x)
m,s=parse.(Int,split(x,":"))
show(min(m*60+s,6e3))
end
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);}
Special Thanks to math junkie.
Special Thanks to ceilingcat for the educative suggestion.
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;}
05AB1E, 11 bytes
':¡60β6₄*)W
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.
Befunge-93 (FBBI), 25 bytes
"<|`*"<d":+&*&
@.<
*"<d@.
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
Tcl, 54 bytes
proc f {a} {scan $a %d:%d a b
expr min(60*$a+$b,6000)}
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.
Bash + GNU utilities, 33 bytes
dc<<<[6000]sL${1/:/ 60*}+dlLx\<Lp
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.
Retina 0.8.2, 27 24 bytes
\d+
$*
+`1:
:60$*
6000`1
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.
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
Dart, 88 bytes
import'dart:math';f(s)=>s.split(":").map(int.parse).reduce((v,e)=>min<num>(v*60+e,6e3));
R, 46 bytes
`:`=c;min(6e3,eval(parse(t=scan(,"")))%*%60:1)
Just redefine : so that we can just use eval to concatenate the hours and minutes together, and do a dot product with c(60,1) to get the seconds.
Python 3, 82 72 62 61 57 bytes
def f(s):x,y=map(int,s.split(":"));return min(x*60+y,6e3)
- -10 bytes by using
min(). - -10 bytes from Arnauld!
- -1 byte from nope!
- -4 bytes from Chas Brown!
CJam, 17 bytes
q':/:i~\60*+6e3e<
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
Husk, 13 bytes
y6000B60mrx":
Explanation
x": Split on colons
mr Convert from string form
B60 Interpret in base 60
y6000 Minimum with 6000
Burlesque, 19 bytes
ps1RAp^60.*.+6000<.
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
APL+WIN, 20 bytes
Prompts for time as string:
6E3⌊60⊥(⍎2↑n),⍎3↓n←⎕
MathGolf, 14 bytes
2<i╟*l2>i+6♪*╓
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)
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
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.
Jelly, 10 bytes
ṣ”:Vḅ60«6ȷ
A monadic Link accepting a list of characters which yields an integer.
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
Befunge-93, 35 bytes
&~$"<"*&+:v
v!`*"<""d"<
_"d""<"*.@.
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).
Japt, 12 bytes
Feel like I'm missing a trick here ...
q': ì60 m6e3
q': ì60 m6e3 :Implicit input of string
q': :Split on ":"
ì60 :Convert to integer from base-60 digit array
m6e3 :Minimum with 6000
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.
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
J, 21 19 bytes
6e3<.60#.[:".' '2}]
[:".' '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.

