From a1e4ad6038c54021b65d1ec8c9000235a62ed774 Mon Sep 17 00:00:00 2001 From: pegasust Date: Mon, 5 Dec 2022 02:12:20 +0000 Subject: [PATCH] d4: 1-liner python --- 2022/d4/src/golf.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 2022/d4/src/golf.py diff --git a/2022/d4/src/golf.py b/2022/d4/src/golf.py new file mode 100644 index 0000000..366888b --- /dev/null +++ b/2022/d4/src/golf.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 + +FILE_LOC="./data/submission.txt" +print(sum([any(g[t][0] <= g[1-t][0] and g[1-t][1] <= g[t][1] for t in range(2)) for g in ([[int(t) for t in w.split("-")] for w in l.split(",")] for l in (l.strip() for l in open(FILE_LOC, "r")) if len(l) > 0)])) +print(sum([any(g[1-t][0] <= g[t][1] and g[t][1] <= g[1-t][1] for t in range(2)) for g in ([[int(t) for t in w.split("-")] for w in l.split(",")] for l in (l.strip() for l in open(FILE_LOC, "r")) if len(l) > 0)]))