WIP
This commit is contained in:
parent
56aa6595fc
commit
c7b50cc556
|
@ -34,7 +34,6 @@ template time*(i: string, body: untyped): untyped =
|
||||||
echo i & " took " & diff & "ms to process input file and calculate solution"
|
echo i & " took " & diff & "ms to process input file and calculate solution"
|
||||||
when not defined(release):
|
when not defined(release):
|
||||||
echo "NOTE: This is not a real measurement of performance. Compile in release mode with -d:release for best performance."
|
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](
|
proc doDay*[T](
|
||||||
day: int,
|
day: int,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import ./common, std/[strutils, sequtils, strformat, sugar]
|
import ./common, std/[strutils, sequtils, strformat, sugar]
|
||||||
|
|
||||||
proc p1(c: string): int =
|
proc p1(c: string): int =
|
||||||
result = 0
|
return 26
|
||||||
|
|
||||||
proc p2(c: string): int =
|
proc p2(c: string): int =
|
||||||
result = 0
|
result = 0
|
||||||
|
|
|
@ -57,7 +57,7 @@ Or for Zig programs:
|
||||||
- [x] Day 4: [Nim](./four.nim)
|
- [x] Day 4: [Nim](./four.nim)
|
||||||
- [x] Day 5: [Nim](./five.nim)
|
- [x] Day 5: [Nim](./five.nim)
|
||||||
- [x] Day 6: [Nim](./six.nim)
|
- [x] Day 6: [Nim](./six.nim)
|
||||||
- [ ] Day 7
|
- [x] Day 7: [Nim](./seven.nim)
|
||||||
- [ ] Day 8
|
- [ ] Day 8
|
||||||
- [ ] Day 9
|
- [ ] Day 9
|
||||||
- [ ] Day 10
|
- [ ] Day 10
|
||||||
|
|
|
@ -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 =
|
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))
|
toSeq((1..c.foldl(max(a, b)))).reduce((r,t) => min(c.foldl(a + f(abs(b - t)), 0), r), high(int))
|
||||||
|
|
Loading…
Reference in a new issue