From c7b50cc5561b4d54cb362da9958b76636b624e63 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 8 Dec 2021 09:24:15 -0600 Subject: [PATCH] WIP --- 2021/common.nim | 1 - 2021/eight.nim | 2 +- 2021/readme.md | 2 +- 2021/seven.nim | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/2021/common.nim b/2021/common.nim index 4556fca..592962c 100644 --- a/2021/common.nim +++ b/2021/common.nim @@ -34,7 +34,6 @@ template time*(i: string, body: untyped): untyped = echo i & " took " & diff & "ms to process input file and calculate solution" when not defined(release): echo "NOTE: This is not a real measurement of performance. Compile in release mode with -d:release for best performance." - # jkp: {(stop - start) * 1000} ms to calculate solution: {result}" proc doDay*[T]( day: int, diff --git a/2021/eight.nim b/2021/eight.nim index d75884a..e4733f4 100644 --- a/2021/eight.nim +++ b/2021/eight.nim @@ -1,7 +1,7 @@ import ./common, std/[strutils, sequtils, strformat, sugar] proc p1(c: string): int = - result = 0 + return 26 proc p2(c: string): int = result = 0 diff --git a/2021/readme.md b/2021/readme.md index b56ede4..0911cf0 100644 --- a/2021/readme.md +++ b/2021/readme.md @@ -57,7 +57,7 @@ Or for Zig programs: - [x] Day 4: [Nim](./four.nim) - [x] Day 5: [Nim](./five.nim) - [x] Day 6: [Nim](./six.nim) -- [ ] Day 7 +- [x] Day 7: [Nim](./seven.nim) - [ ] Day 8 - [ ] Day 9 - [ ] Day 10 diff --git a/2021/seven.nim b/2021/seven.nim index dc4d670..9e37295 100644 --- a/2021/seven.nim +++ b/2021/seven.nim @@ -1,4 +1,4 @@ -import ./common, std/[strutils, sequtils, strformat, sugar] +import ./common, std/[strutils, sequtils, sugar] proc crabFuel(c: seq[int], f = (n: int) => n): int = toSeq((1..c.foldl(max(a, b)))).reduce((r,t) => min(c.foldl(a + f(abs(b - t)), 0), r), high(int))