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))