Skip to content

Instantly share code, notes, and snippets.

@isaacabraham
Last active August 29, 2015 14:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacabraham/6c1001b43200e97a43a3 to your computer and use it in GitHub Desktop.
Save isaacabraham/6c1001b43200e97a43a3 to your computer and use it in GitHub Desktop.
type Bridge = { RunwayLength: int; GapSize: int; LandingSize: int }
type BikeState = { Speed: int; Position: int }
// Get current position
let (|OnTheRunway|JustBeforeGap|InFlight|AfterGap|) bikeState =
if bikeState.Position >= bridge.RunwayLength + bridge.GapSize then AfterGap
elif bikeState.Position > (bridge.RunwayLength - bikeState.Speed) then JustBeforeGap
elif bikeState.Position < bridge.RunwayLength then OnTheRunway
else InFlight
// Get current speed
let (|TooSlow|TooFast|TargetSpeed|) speed =
let targetSpeed = bridge.GapSize + 1
if speed < targetSpeed then TooSlow
elif speed > targetSpeed then TooFast
else TargetSpeed
@vasily-kirichenko
Copy link

Where bridge comes on line 6?
Same for line 13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment