From 3555be54c2abb8d5ece008a60dbdfbde0ffbddd7 Mon Sep 17 00:00:00 2001 From: Alex Pickering Date: Fri, 7 Feb 2025 12:49:48 -0600 Subject: inital commit --- 04/2.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 04/2.lua (limited to '04/2.lua') diff --git a/04/2.lua b/04/2.lua new file mode 100644 index 0000000..ae7d546 --- /dev/null +++ b/04/2.lua @@ -0,0 +1,16 @@ +#!/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 + (s2 >= s1 and s2 <= e1) or + (e2 >= s1 and e2 <= e1) or + (s1 >= s2 and e1 <= e2) or + (s2 >= s1 and e2 <= e1) + then + c = c + 1 + end +end +print(c) -- cgit v1.2.3-70-g09d2