about summary refs log tree commit diff
path: root/aoc/2021/07/part-one.raku
diff options
context:
space:
mode:
Diffstat (limited to 'aoc/2021/07/part-one.raku')
-rw-r--r--aoc/2021/07/part-one.raku3
1 files changed, 3 insertions, 0 deletions
diff --git a/aoc/2021/07/part-one.raku b/aoc/2021/07/part-one.raku
new file mode 100644
index 0000000..81cb7d4
--- /dev/null
+++ b/aoc/2021/07/part-one.raku
@@ -0,0 +1,3 @@
+my @input = map +*, split ',', trim slurp 'input';
+sub cost($align) { [+] map { abs $align - $_ }, @input }
+put min (cost $_ for (min @input)...(max @input))