Created
December 18, 2016 18:39
-
-
Save theburningmonk/7e17124d96c470bcb585abd4ae3b4aa9 to your computer and use it in GitHub Desktop.
Advent of Code (Day 17)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let findPaths input = | |
| [| ((0, 0), input) |] | |
| |> Seq.unfold (fun paths -> | |
| paths | |
| |> Array.filter (fun (pos, _) -> pos <> (3, 3)) | |
| |> Array.collect (fun (pos, path) -> | |
| let hashVals = hash path |> Seq.take 4 | |
| hashVals | |
| |> Seq.zip [| up; down; left; right |] | |
| |> Seq.choose (fun (f, hashVal) -> | |
| if hashVal > 'a' then f pos path else None) | |
| |> Seq.toArray) | |
| |> function | |
| | [||] -> None | |
| | next -> Some(next, next)) | |
| |> Seq.collect id | |
| |> Seq.choose (function | |
| | (3, 3), path -> Some <| path.Substring(input.Length) | |
| | _ -> None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment