aboutsummaryrefslogtreecommitdiff
path: root/aoc-2022-dotnet/Day15
diff options
context:
space:
mode:
authorTomasz Chojnacki <tomaszchojnacki2001@gmail.com>2022-12-30 14:35:09 +0100
committerTomasz Chojnacki <tomaszchojnacki2001@gmail.com>2022-12-30 14:35:09 +0100
commit353d185a1f89654f999dca7b75016ebef461a23c (patch)
tree24acbc0bd35385312a563263ce3b665d49a5ffe9 /aoc-2022-dotnet/Day15
parent62a2e6fb7175f683a4d315374efd5bc4ea331dc5 (diff)
downloadgleam_aoc2020-353d185a1f89654f999dca7b75016ebef461a23c.tar.gz
gleam_aoc2020-353d185a1f89654f999dca7b75016ebef461a23c.zip
Finish day 24
Diffstat (limited to 'aoc-2022-dotnet/Day15')
-rw-r--r--aoc-2022-dotnet/Day15/Program.fs12
1 files changed, 4 insertions, 8 deletions
diff --git a/aoc-2022-dotnet/Day15/Program.fs b/aoc-2022-dotnet/Day15/Program.fs
index e158346..427c411 100644
--- a/aoc-2022-dotnet/Day15/Program.fs
+++ b/aoc-2022-dotnet/Day15/Program.fs
@@ -53,15 +53,15 @@ let sensorList =
let (sensorPos, beaconPos) = Util.parse pline line
{ Pos = sensorPos
- Radius = Vec2.mahattanDist sensorPos beaconPos
+ Radius = Vec2.manhattanDist sensorPos beaconPos
NearestBeacon = beaconPos }
Seq.map parseSensor >> List.ofSeq
let rowCoverages y sensors =
let coverage ({ Radius = radius; Pos = pos }) =
- let offset = radius - abs (Vec2.y pos - y)
- (Vec2.x pos - offset, Vec2.x pos + offset)
+ let offset = radius - abs (pos.y - y)
+ (pos.x - offset, pos.x + offset)
sensors
|> Seq.map coverage
@@ -72,11 +72,7 @@ let solution1 y input =
let beaconsInRow =
sensors
- |> Seq.choose (fun ({ NearestBeacon = b }) ->
- if Vec2.y b = y then
- Some(Vec2.x b)
- else
- None)
+ |> Seq.choose (fun ({ NearestBeacon = b }) -> if b.y = y then Some(b.x) else None)
|> Util.countDistinct
sensors