From 1c1dcf178ec6acb70f1e887341a99c3b40970ff1 Mon Sep 17 00:00:00 2001 From: deadmarshal Date: Thu, 15 Dec 2022 10:37:50 +0330 Subject: TWC194 --- challenge-194/deadmarshal/lua/ch-1.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 challenge-194/deadmarshal/lua/ch-1.lua (limited to 'challenge-194/deadmarshal/lua/ch-1.lua') diff --git a/challenge-194/deadmarshal/lua/ch-1.lua b/challenge-194/deadmarshal/lua/ch-1.lua new file mode 100644 index 0000000000..67320493e3 --- /dev/null +++ b/challenge-194/deadmarshal/lua/ch-1.lua @@ -0,0 +1,19 @@ +local function digital_clock(str) + local one,two,three,four = str:match('(.)(.):(.)(.)') + if one == '?' then + if tonumber(two) < 4 then return 2 else return 1 end + elseif two == '?' then + if tonumber(one) < 2 then return 9 else return 3 end + elseif three == '?' then + return 5 + else return 9 + end +end + +print(digital_clock('?5:00')) +print(digital_clock('?3:00')) +print(digital_clock('1?:00')) +print(digital_clock('2?:00')) +print(digital_clock('12:?5')) +print(digital_clock('12:5?')) + -- cgit