projects
/
advent-of-code-19.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
10166d0
)
Tidying
author
Neil Smith
<neil.git@njae.me.uk>
Wed, 22 Jan 2020 06:08:09 +0000
(10:08 +0400)
committer
Neil Smith
<neil.git@njae.me.uk>
Wed, 22 Jan 2020 06:08:09 +0000
(10:08 +0400)
advent23/src/advent23.hs
patch
|
blob
|
history
diff --git
a/advent23/src/advent23.hs
b/advent23/src/advent23.hs
index 6bcc534677027557562d7b234259d00571263a77..fe2a9cd3c45f25a47fcd049a90f76653c55e878a 100644
(file)
--- a/
advent23/src/advent23.hs
+++ b/
advent23/src/advent23.hs
@@
-49,7
+49,7
@@
main = do
print $ part2 mem
print $ part2 mem
-part1 mem =
(runNetworkUntil255 net) ^. packetY
+part1 mem =
runNetworkUntil255 net
where net = buildNetwork mem
where net = buildNetwork mem
@@
-57,9
+57,9
@@
part2 mem = runNetworkUntilTermination natNet
where natNet = buildNatNetwork mem
where natNet = buildNatNetwork mem
-runNetworkUntil255 :: Network ->
Packet
+runNetworkUntil255 :: Network ->
Integer
runNetworkUntil255 net0
runNetworkUntil255 net0
- | not $ null goalPackets =
head goalPackets
+ | not $ null goalPackets =
(head goalPackets) ^. packetY
| otherwise = runNetworkUntil255 net3
where net1 = runNetworkStep net0
(net2, packets) = extractPackets net1
| otherwise = runNetworkUntil255 net3
where net1 = runNetworkStep net0
(net2, packets) = extractPackets net1
@@
-145,7
+145,7
@@
extractPackets net = (net', packets)
extractPacket :: EncapsulatedMacine -> [Packet]
extractPacket e = if length output >= 3
extractPacket :: EncapsulatedMacine -> [Packet]
extractPacket e = if length output >= 3
- then [Packet { _destination =
fromIntegral $
output!!0
+ then [Packet { _destination = output!!0
, _packetX = output!!1
, _packetY = output!!2} ]
else []
, _packetX = output!!1
, _packetY = output!!2} ]
else []