File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ object Day18 {
5757 object LinearOnPathPart2Solution extends Part2Solution {
5858 def exitPath (bytes : Seq [Pos ], max : Pos , after : Int ): Option [Seq [Pos ]] = {
5959 val graphSearch = bytesGraphSearch(bytes, max, after + 1 )
60- BFS .searchPaths(graphSearch).paths.get (graphSearch.targetNode) // TODO: optimize paths to not compute everything
60+ BFS .searchPaths(graphSearch).paths.lift (graphSearch.targetNode)
6161 }
6262
6363 override def findBlockingByte (bytes : Seq [Pos ], max : Pos = Pos (70 , 70 )): Pos = {
Original file line number Diff line number Diff line change @@ -23,14 +23,10 @@ trait Distances[A] {
2323trait Paths [A ] {
2424 def prevNodes : collection.Map [A , A ]
2525
26- def paths : collection. Map [A , Seq [A ]] = {
27- prevNodes.map(( node, _) =>
28- node -> (node +: LazyList .unfold0(node)(prevNodes.get)).reverse
26+ def paths : PartialFunction [A , Seq [A ]] =
27+ prevNodes.andThen( node =>
28+ (node #:: LazyList .unfold0(node)(prevNodes.get)).reverse // TODO: don't bother with LazyList now that it's a function
2929 )
30- }
31-
32- /* def paths(node: A): Seq[A] =
33- (node +: LazyList.unfold0(node)(prevNodes.get)).reverse*/
3430}
3531
3632trait Order [A ] {
You can’t perform that action at this time.
0 commit comments