Skip to content

Instantly share code, notes, and snippets.

@theburningmonk
Created December 18, 2016 18:36
Show Gist options
  • Save theburningmonk/a8a337a228ed9614e16a05f58fe2a216 to your computer and use it in GitHub Desktop.
Save theburningmonk/a8a337a228ed9614e16a05f58fe2a216 to your computer and use it in GitHub Desktop.
Advent of Code (Day 17)
let inline between low hi x = x >= 0 && x < hi
let step direction (dx, dy) (x, y) path =
if x + dx |> between 0 width && y + dy |> between 0 height
then Some((x+dx, y+dy), path + direction)
else None
let up = step "U" (0, -1)
let down = step "D" (0, 1)
let left = step "L" (-1, 0)
let right = step "R" (1, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment