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 {
57
57
object LinearOnPathPart2Solution extends Part2Solution {
58
58
def exitPath (bytes : Seq [Pos ], max : Pos , after : Int ): Option [Seq [Pos ]] = {
59
59
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)
61
61
}
62
62
63
63
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] {
23
23
trait Paths [A ] {
24
24
def prevNodes : collection.Map [A , A ]
25
25
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
29
29
)
30
- }
31
-
32
- /* def paths(node: A): Seq[A] =
33
- (node +: LazyList.unfold0(node)(prevNodes.get)).reverse*/
34
30
}
35
31
36
32
trait Order [A ] {
You can’t perform that action at this time.
0 commit comments