Last active
August 29, 2015 14:22
-
-
Save isaacabraham/6c1001b43200e97a43a3 to your computer and use it in GitHub Desktop.
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 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where
bridge
comes on line 6?Same for line 13.