tadd dec1 solution - aoc22 - advent of code 2022 solutions | |
git clone git://src.adamsgaard.dk/aoc22 | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit b7f5e63c9ca56df0b4d5da38ae286f91cdada827 | |
parent 08f1c03418679c7ceb516b80aa3b667fd429a6af | |
Author: Anders Damsgaard <[email protected]> | |
Date: Thu, 1 Dec 2022 12:32:26 +0000 | |
add dec1 solution | |
Diffstat: | |
A 1/aoc1 | 12 ++++++++++++ | |
A 1/data | 14 ++++++++++++++ | |
A 1/mkfile | 2 ++ | |
3 files changed, 28 insertions(+), 0 deletions(-) | |
--- | |
diff --git a/1/aoc1 b/1/aoc1 | |
t@@ -0,0 +1,12 @@ | |
+#!/bin/awk -f | |
+# run with ./aoc1.awk <data | sort -n | tail -n 1 | |
+ | |
+function evalelf() { | |
+ printf "%d\telf %d\n", total, ++elf; total=0; getline | |
+} | |
+ | |
+/^$/ { evalelf() } | |
+ | |
+{ total += $1 } | |
+ | |
+END{ evalelf() } | |
diff --git a/1/data b/1/data | |
t@@ -0,0 +1,14 @@ | |
+1000 | |
+2000 | |
+3000 | |
+ | |
+4000 | |
+ | |
+5000 | |
+6000 | |
+ | |
+7000 | |
+8000 | |
+9000 | |
+ | |
+10000 | |
diff --git a/1/mkfile b/1/mkfile | |
t@@ -0,0 +1,2 @@ | |
+run:V: data aoc1 | |
+ ./aoc1 <data | sort -n | tail -n 1 |