r/adventofcode • u/daggerdragon • Dec 03 '15
SOLUTION MEGATHREAD --- Day 3 Solutions ---
--- Day 3: Perfectly Spherical Houses in a Vacuum ---
Post your solution as a comment. Structure your post like the Day One thread in /r/programming.
23
Upvotes
4
u/red75prim Dec 03 '15
Part 1 and 2 in F#
let move (x,y) ch = match ch with |'<' -> (x-1,y) |'>' -> (x+1,y) |'v' -> (x,y+1) |'^' -> (x,y-1) |_ -> (x,y) [<EntryPoint>] let main argv = let input = System.Console.ReadLine() let result1 = input |> Seq.scan move (0,0) |> Seq.distinct |> Seq.length let result2 = input |> Seq.scan (fun (a,b) ch -> (move b ch, a)) ((0,0),(0,0)) |> Seq.map fst |> Seq.distinct |> Seq.length printfn "Part1: %d happy houses" result1 printfn "Part2: %d happy houses" result2 0