Move things around

This commit is contained in:
Daniel Flanagan 2021-12-07 10:10:13 -06:00
parent e88a868165
commit 4be929622f
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4

View file

@ -1,9 +1,6 @@
import std/[strutils, sequtils, tables, strformat] import std/[strutils, sequtils, tables, strformat]
import ./common import ./common
proc f(n: int): int = toSeq(0..abs(n)).foldl(a + b, 0)
proc crabsDistance(input: string): int = proc crabsDistance(input: string): int =
result = int.high() result = int.high()
var max_try = 0 var max_try = 0
@ -14,6 +11,8 @@ proc crabsDistance(input: string): int =
let fuel = dists.foldl(a + abs(b - t), 0) let fuel = dists.foldl(a + abs(b - t), 0)
if fuel < result: result = fuel if fuel < result: result = fuel
proc f(n: int): int = toSeq(0..abs(n)).foldl(a + b, 0)
proc crabsBigDistance(input: string): int = proc crabsBigDistance(input: string): int =
result = int.high() result = int.high()
var max_try = 0 var max_try = 0
@ -27,7 +26,6 @@ proc crabsBigDistance(input: string): int =
let input = 7.loadInputText() let input = 7.loadInputText()
time("day 7 part 1"): echo input.crabsDistance() time("day 7 part 1"): echo input.crabsDistance()
time("day 7 part 2"): echo input.crabsBigDistance() time("day 7 part 2"): echo input.crabsBigDistance()
# time("day 7 part 2"): echo "?"
when not defined(release): when not defined(release):
let testInput = "16,1,2,0,4,2,7,1,2,14" let testInput = "16,1,2,0,4,2,7,1,2,14"