Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open System.IO
- module PathWalker =
- let stringListLogger (stringList: string[]) = Seq.iter(fun x -> printfn "%s" (x.ToString())) stringList
- let walk (x, y) (steps, direction) =
- match direction with
- | 'F' -> (x, y + steps)
- | 'B' -> (x, y - steps)
- | 'H' -> (x + steps, y)
- | 'V' -> (x - steps, y)
- | _ -> (x, y)
- let walkAll (line: string) =
- line
- |> Seq.chunkBySize 2
- |> Seq.map (fun arr -> (int (arr.[0].ToString()), arr.[1]))
- |> Seq.fold walk (0, 0)
- let walkLine input =
- input
- |> walkAll
- [<EntryPoint>]
- let main argv =
- let (x, y) = File.ReadAllLines "input.txt" |> String.concat "" |> PathWalker.walkLine
- printfn "%i %i" x y
- 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement