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
| open System.Text | |
| open System.Security.Cryptography | |
| let input = "udskfozm" | |
| let width, height = 4, 4 | |
| let md5 = CryptoConfig.CreateFromName("MD5") :?> HashAlgorithm | |
| let hash (input : string) = | |
| let bytes = input |> Encoding.UTF8.GetBytes |> md5.ComputeHash |
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 part1 = findPaths input |> Seq.tryHead |
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 part2 = findPaths input |> Seq.map String.length |> Seq.max |
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
| open System | |
| open System.Text | |
| open System.Security.Cryptography | |
| let input = "udskfozm" | |
| let width, height = 4, 4 | |
| let md5 = CryptoConfig.CreateFromName("MD5") :?> HashAlgorithm | |
| let hash (input : string) = |
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 input = "11011110011011101" |> Seq.map ((=) '1') |> Seq.toArray | |
| let solve diskSize input = | |
| let rec dragonCurve (a : bool[]) = | |
| if a.Length >= diskSize | |
| then a.[0..diskSize-1] | |
| else | |
| [| | |
| yield! a | |
| yield false |
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 input2 = input1 @ [ { Number = 7; Positions = 11; Time0Pos = 0 } ] | |
| let part2 = solve input2 |
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
| type Disc = | |
| { | |
| Number : int | |
| Positions : int | |
| Time0Pos : int | |
| } | |
| let solve (discs : Disc list) = | |
| // what's the first time we can press and get through the first slot? | |
| let fstDisc = discs.[0] |
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 hex = | |
| seq { | |
| yield! Seq.zip { 0uy..9uy } { '0'..'9' } | |
| yield! Seq.zip { 10uy..15uy } { 'a'..'f' } | |
| } | |
| |> Map.ofSeq | |
| let hash (input : string) = | |
| let bytes = input |> Encoding.UTF8.GetBytes |> md5.ComputeHash | |
| let chars = Array.zeroCreate<char> (bytes.Length * 2) |
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 keyStretch (input : string) = | |
| { 0..2016 } |> Seq.fold (fun last _ -> hash last) input | |
| let part2 = solve keyStretch |
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
| open System | |
| open System.Collections.Generic | |
| open System.Text | |
| open System.Security.Cryptography | |
| let input = "ahsbgdzn" | |
| let md5 = CryptoConfig.CreateFromName("MD5") :?> HashAlgorithm | |
| let hash (input : string) = |