diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-07-06 00:34:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-06 00:34:58 +0100 |
| commit | 4b13caca858d3e45ceccf1bfc2a567fc6c62458e (patch) | |
| tree | 45562ac52d9777744e7f2f6f927c19407596bf13 /challenge-120/abigail/lua/ch-2.lua | |
| parent | 495b4efc48550381635e1e63406ecdb2840995c5 (diff) | |
| parent | 0242bf8e30c825fb37e1a19fb70e8d8b6a47957f (diff) | |
| download | perlweeklychallenge-club-4b13caca858d3e45ceccf1bfc2a567fc6c62458e.tar.gz perlweeklychallenge-club-4b13caca858d3e45ceccf1bfc2a567fc6c62458e.tar.bz2 perlweeklychallenge-club-4b13caca858d3e45ceccf1bfc2a567fc6c62458e.zip | |
Merge pull request #4442 from Abigail/abigail/week-120
Abigail/week 120
Diffstat (limited to 'challenge-120/abigail/lua/ch-2.lua')
| -rw-r--r-- | challenge-120/abigail/lua/ch-2.lua | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/challenge-120/abigail/lua/ch-2.lua b/challenge-120/abigail/lua/ch-2.lua new file mode 100644 index 0000000000..31c18d0b5e --- /dev/null +++ b/challenge-120/abigail/lua/ch-2.lua @@ -0,0 +1,26 @@ +#!/opt/local/bin/lua + +-- +-- See ../README.md +-- + +-- +-- Run as: lua ch-2.lua < input-file +-- + +local DIFF_PER_MINUTE = 11 +local MIN_PER_HOUR = 60 +local FULL_CIRCLE = 720 + +for line in io . lines () do + local _, _, hours, minutes = line : find ("([0-9][0-9]):([0-9][0-9])") + hours = tonumber (hours) + minutes = tonumber (minutes) + local angle = (DIFF_PER_MINUTE * (hours * MIN_PER_HOUR + minutes)) % + FULL_CIRCLE + if 2 * angle >= FULL_CIRCLE + then angle = FULL_CIRCLE - angle + end + + print (angle / 2) +end |
