/* Wrote a microwave timer (code golf)in Picat. https://codegolf.stackexchange.com/questions/204969/write-a-microwave-timer """ Write a microwave timer! 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. """ This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import util. main => go. go ?=> Tests = ["01:30", "00:66", "01:99", "02:39", "99:99"], foreach(T in Tests) [H,M] = T.split(":").map(to_int), println(T=t(H,M)) end, nl. go => true. go2 => foreach(T in ["01:30","00:66","01:99","02:39","99:99"]) s(T).println end, nl. % 18 chars t(H,M)=min([6000,H*60+M]). % Including parsing: 52 chars s(T)=min([6000,S[1]*60+S[2]])=>S=T.split(":").map(to_int).