diff options
| author | Alex Pickering <alex@cogarr.net> | 2025-02-07 12:49:48 -0600 |
|---|---|---|
| committer | Alex Pickering <alex@cogarr.net> | 2025-02-07 12:49:48 -0600 |
| commit | 3555be54c2abb8d5ece008a60dbdfbde0ffbddd7 (patch) | |
| tree | 278876284d07118ecdea5c48cb6453f3122887f0 /04/1.lua | |
| download | advent_of_code_2022-master.tar.gz advent_of_code_2022-master.tar.bz2 advent_of_code_2022-master.zip | |
Diffstat (limited to '04/1.lua')
| -rw-r--r-- | 04/1.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/04/1.lua b/04/1.lua new file mode 100644 index 0000000..100da50 --- /dev/null +++ b/04/1.lua @@ -0,0 +1,11 @@ +#!/usr/bin/env lua + +local c = 0 +for line in io.lines() do + local s1, e1, s2, e2 = line:match("(%d+)-(%d+),(%d+)-(%d+)") + s1, e1, s2, e2 = tonumber(s1), tonumber(e1), tonumber(s2), tonumber(e2) + if (s1 >= s2 and e1 <= e2) or (s2 >= s1 and e2 <= e1) then + c = c + 1 + end +end +print(c) |
