From dd69954b095e2c7082bbcb77fdfffa980c0ee704 Mon Sep 17 00:00:00 2001 From: setop Date: Thu, 2 Dec 2021 00:22:53 +0100 Subject: [PATCH] day 1 --- d01/d01_1.awk | 16 + d01/d01_2.py | 8 + d01/input | 2000 +++++++++++++++++++++++++++++++++++++++++++++++++ d01/sample | 10 + 4 files changed, 2034 insertions(+) create mode 100644 d01/d01_1.awk create mode 100644 d01/d01_2.py create mode 100644 d01/input create mode 100644 d01/sample diff --git a/d01/d01_1.awk b/d01/d01_1.awk new file mode 100644 index 0000000..6c92772 --- /dev/null +++ b/d01/d01_1.awk @@ -0,0 +1,16 @@ +NR == 1 { + A = $1 + next +} + +$1 > A { + N++ +} + +{ + A = $1 +} + +END { + print N +} \ No newline at end of file diff --git a/d01/d01_2.py b/d01/d01_2.py new file mode 100644 index 0000000..9e78654 --- /dev/null +++ b/d01/d01_2.py @@ -0,0 +1,8 @@ +import sys +L = [ int(l[:-1]) for l in sys.stdin.readlines() ] +Z = zip(L, L[1:], L[2:]) +M = [ a+b+c for (a,b,c) in Z] +Y = zip(M, M[1:]) +P = [ [0,1][a