S7KQGPTY6EA4BULFXXKOHCIDJ3BJ62IWXBNJMPPCPMLV3DBUYPTAC
open System.IO
let readLines (filePath: string) = seq {
use sr = new StreamReader (filePath)
while not sr.EndOfStream do
yield sr.ReadLine()
}
type Range = { first: int; last: int }
let rangeFront (r: Range): Range =
{ Range.first = r.first; last = r.first + ((r.last - r.first) / 2) }
let rangeBack (r: Range): Range =
{ Range.first = r.first + ((r.last - r.first) / 2) + 1; last = r.last }
let rangeLower = rangeFront
let rangeUpper = rangeBack
let calculateSeatId (row: int) (col: int): int =
row * 8 + col
let rec binarySearch (s: string) (i: int) (final: int) (r: Range): Range =
let c = s.[i]
let newRange = if (c = 'F' || c = 'L') then (rangeFront r)
else (rangeBack r)
if i = final then newRange
else binarySearch s (i + 1) final newRange
[<EntryPoint>]
let main argv =
let lines = readLines "input.txt"
let seats: bool array = [| for i in 0..(128 * 8) do false |]
let usedSeats = [ for line in lines do
let rowRange = binarySearch line 0 6 { Range.first = 0; last = 127 }
let colRange = binarySearch line 7 9 { Range.first = 0; last = 7 }
let seatId = calculateSeatId rowRange.first colRange.first
Array.set seats seatId true
(seatId) ]
let highestSeatId = List.max usedSeats
let part2 = query {
for i in 1..seats.Length - 1 do
find (seats.[i - 1] && not seats.[i] && seats.[i + 1])
}
printf "%d\n%A\n" highestSeatId part2
0
BFBBBBFRLL
FBFBFFBRLL
BBFBBFBLRL
BFFFBBFLLR
BFFFFBBLRL
BFBBFBFRRL
FBBFBFBRRR
FFBFBFFRLR
BBBFFBFLLL
BFFBBBBRRL
BBFBFFFRRR
FBFFFFFRLL
BFBFBBFLRL
BFBFBFBLRL
BFFFBFFLLL
BBFBBBFRRL
FBFFBBFRRR
FFBBBFFRRL
BFBBBBBLLL
FBFBFFBLLL
BBFBFBBLRR
BFFFFFBRLL
BFBFBBFRLR
BBFFBBFRRL
FBBBFBBRLL
BFFBBFBRRR
BFBFBBFLLL
BBFFBBBRLR
FBFFFFBRRL
BFFFBFBRRL
FFFBBBBLRR
FFBF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BFFFBRRL
BFBBBBBRRL
FFBBFFFRLR
BFFFFFFLRL
FFBBBFFLRR
FFFBFBBLLL
FFBFFFFLLR
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="main.fs" />
</ItemGroup>
</Project>
let part1 (arr: int list) = query {
for a in arr do
for b in arr do
find (a + b = 2020)
}
let part2 (arr: int list) = query {
for a in arr do
let part1 (arr: int list) = query {
for a in arr do
for b in arr do
find (a + b = 2020)
}
let part2 (arr: int list) = query {
for a in arr do
let v = part1 arr |> tupleToArray2 |> Array.reduce (*)
printfn "%d" v
let v2 = part2 arr |> tupleToArray3 |> Array.reduce (*)
printfn "%d" v2
0
let v = part1 arr |> tupleToArray2 |> Array.reduce (*)
printfn "%d" v
let v2 = part2 arr |> tupleToArray3 |> Array.reduce (*)
printfn "%d" v2
0