aboutsummaryrefslogtreecommitdiff
path: root/challenge-194/deadmarshal/lua/ch-1.lua
blob: 67320493e3f1425e5a83ac74151e394eeae003fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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?'))