~aperezdc/aoc2022

ced9f0c74486b75bdd7f8cafaa614577c675ffaa — Adrian Perez de Castro 2 years ago d471e23
Day 4, first part
2 files changed, 21 insertions(+), 0 deletions(-)

A day04/day04.krk
A day04/day04.test
A day04/day04.krk => day04/day04.krk +15 -0
@@ 0,0 1,15 @@
#! /usr/bin/env kuroko

from fileio import stdin

let count = 0

for line in stdin.readlines():
    let a, b = line.strip().split(",")
    let al, ar = map(int, a.split("-"))
    let bl, br = map(int, b.split("-"))

    if (al <= bl and br <= ar) or (bl <= al and ar <= br):
        count += 1

print(count)

A day04/day04.test => day04/day04.test +6 -0
@@ 0,0 1,6 @@
2-4,6-8
2-3,4-5
5-7,7-9
2-8,3-7
6-6,4-6
2-6,4-8