Skip to content

Instantly share code, notes, and snippets.

@mrange
Created December 6, 2020 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrange/e50d42c0a363fc5832651e77b89774a2 to your computer and use it in GitHub Desktop.
Save mrange/e50d42c0a363fc5832651e77b89774a2 to your computer and use it in GitHub Desktop.
Advent of Code
[<EntryPoint>]
let main argv =
let parseBoardingPass (boardingPass : string) =
let bn = boardingPass.Replace('F', '0').Replace('L', '0').Replace('B', '1').Replace('R', '1')
let sid = System.Convert.ToInt32(bn, 2)
sid/8, sid%8, sid
let testCases =
[|
"FBFBBFFRLR", (44 , 5, 357)
"BFFFBBFRRR", (70 , 7, 567)
"FFFBBBFRRR", (14 , 7, 119)
"BBFFBBFRLL", (102, 4, 820)
|]
for boardingPass, seating in testCases do
let s = parseBoardingPass boardingPass
if s <> seating then
printfn "Test case failed for '%s' expected %A but got %A" boardingPass seating s
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment