Compare commits

1 Commits

Author SHA1 Message Date
Smaug123
0df2a648b3 Some enumerators 2022-12-09 20:40:42 +00:00
96 changed files with 351 additions and 17892 deletions

View File

@@ -3,7 +3,7 @@
"isRoot": true, "isRoot": true,
"tools": { "tools": {
"fantomas": { "fantomas": {
"version": "5.2.0-alpha-008", "version": "5.1.0",
"commands": [ "commands": [
"fantomas" "fantomas"
] ]

7
.gitattributes vendored
View File

@@ -1,4 +1,3 @@
* eol=auto * text=auto
*.sh eol=lf *.sh text=lf
*.txt eol=lf *.txt text=lf
*.nix eol=lf

View File

@@ -13,12 +13,6 @@ env:
jobs: jobs:
build: build:
strategy:
matrix:
config:
- Release
- Debug
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -30,79 +24,36 @@ jobs:
- name: Restore dependencies - name: Restore dependencies
run: dotnet restore run: dotnet restore
- name: Build - name: Build
run: dotnet build --no-restore --configuration ${{matrix.config}} run: dotnet build --no-restore
- name: Test - name: Test
run: dotnet test --no-build --verbosity normal --configuration ${{matrix.config}} run: dotnet test --no-build --verbosity normal
- name: Run app
run: dotnet run --project AdventOfCode2022.App/AdventOfCode2022.App.fsproj --no-build
run-app: check-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Build
run: nix build
- name: Run app
run: ./result/bin/AdventOfCode2022.App
check-dotnet-format:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Install Nix - name: Setup .NET SDK v7.0.x
uses: cachix/install-nix-action@v22 uses: actions/setup-dotnet@v3
with: with:
extra_nix_config: | dotnet-version: 7.0.x
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - name: Prepare .NET tools
run: dotnet tool restore
- name: Run Fantomas - name: Run Fantomas
run: nix run .#fantomas -- -r --check . run: ./hooks/pre-push
check-nix-format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Run Alejandra
run: nix develop --command alejandra --check .
shellcheck: shellcheck:
name: Shellcheck name: Shellcheck
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
name: Checkout
- name: Install Nix
uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Run ShellCheck - name: Run ShellCheck
run: nix develop --command bash -c "find . -type f -name '*.sh' | xargs shellcheck" uses: ludeeus/action-shellcheck@master
linkcheck:
name: Check links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Nix
uses: cachix/install-nix-action@v22
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Run link checker
run: nix develop --command markdown-link-check README.md
all-required-checks-complete: all-required-checks-complete:
needs: [check-dotnet-format, check-nix-format, build, shellcheck, linkcheck, run-app] needs: [check-format, build, shellcheck]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- run: echo "All required checks complete." - run: echo "All required checks complete."

2
.gitignore vendored
View File

@@ -6,5 +6,3 @@ riderModule.iml
.idea/ .idea/
*.sln.DotSettings.user *.sln.DotSettings.user
.vs/ .vs/
*.log
result

View File

@@ -6,9 +6,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Assembly.fs" />
<Compile Include="Run.fs" />
<Compile Include="Inputs.fs" />
<Compile Include="Program.fs" /> <Compile Include="Program.fs" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day1.txt" /> <EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day1.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day2.txt" /> <EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day2.txt" />
@@ -19,30 +16,10 @@
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day7.txt" /> <EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day7.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day8.txt" /> <EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day8.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day9.txt" /> <EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day9.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day10.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day11.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day12.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day13.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day14.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day15.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day16.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day17.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day18.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day19.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day20.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day21.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day22.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day23.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day24.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day25.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\AdventOfCode2022\AdventOfCode2022.fsproj" /> <ProjectReference Include="..\AdventOfCode2022\AdventOfCode2022.fsproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
</ItemGroup>
</Project> </Project>

View File

@@ -1,18 +0,0 @@
namespace AdventOfCode2022.App
open System.IO
open System.Reflection
[<RequireQualifiedAccess>]
module Assembly =
type private Dummy =
class
end
let readResource (name : string) : string =
let asm = Assembly.GetAssembly typeof<Dummy>
use stream = asm.GetManifestResourceStream $"AdventOfCode2022.App.%s{name}"
use reader = new StreamReader (stream)
reader.ReadToEnd ()

View File

@@ -1,6 +0,0 @@
namespace AdventOfCode2022.App
[<RequireQualifiedAccess>]
module Inputs =
let days = Array.init 25 (fun day -> Assembly.readResource $"Day%i{day + 1}.txt")
let inline day (i : int) = days.[i - 1]

View File

@@ -1,132 +1,77 @@
namespace AdventOfCode2022.App namespace AdventOfCode2022.App
open System.Diagnostics open System.Diagnostics
open BenchmarkDotNet.Attributes open System.IO
open BenchmarkDotNet.Configs open System.Reflection
open BenchmarkDotNet.Running open AdventOfCode2022
module Benchmarks =
type Benchmark1To5 () =
[<GlobalSetup>]
member _.Setup () = Run.shouldWrite <- false
[<Params(1, 2, 3, 4, 5)>]
member val Day = 0 with get, set
[<Params(false, true)>]
member val IsPartOne = false with get, set
[<Benchmark>]
member this.Benchmark () : unit =
Run.allRuns.[this.Day - 1] (not this.IsPartOne) (Inputs.day this.Day)
[<GlobalCleanup>]
member _.Cleanup () = Run.shouldWrite <- true
type Benchmark6To10 () =
[<GlobalSetup>]
member _.Setup () = Run.shouldWrite <- false
[<Params(6, 7, 8, 9, 10)>]
member val Day = 0 with get, set
[<Params(false, true)>]
member val IsPartOne = false with get, set
[<Benchmark>]
member this.Benchmark () : unit =
Run.allRuns.[this.Day - 1] (not this.IsPartOne) (Inputs.day this.Day)
[<GlobalCleanup>]
member _.Cleanup () = Run.shouldWrite <- true
type Benchmark11To15 () =
[<GlobalSetup>]
member _.Setup () = Run.shouldWrite <- false
[<Params(11, 12, 13, 14, 15)>]
member val Day = 0 with get, set
[<Params(false, true)>]
member val IsPartOne = false with get, set
[<Benchmark>]
member this.Benchmark () : unit =
Run.allRuns.[this.Day - 1] (not this.IsPartOne) (Inputs.day this.Day)
[<GlobalCleanup>]
member _.Cleanup () = Run.shouldWrite <- true
type Benchmark16To20 () =
[<GlobalSetup>]
member _.Setup () = Run.shouldWrite <- false
[<Params(16, 17, 18, 19, 20)>]
member val Day = 0 with get, set
[<Params(false, true)>]
member val IsPartOne = false with get, set
[<Benchmark>]
member this.Benchmark () : unit =
Run.allRuns.[this.Day - 1] (not this.IsPartOne) (Inputs.day this.Day)
[<GlobalCleanup>]
member _.Cleanup () = Run.shouldWrite <- true
type Benchmark21To25 () =
static member finalBenchmarkArgs =
(25, true) :: List.allPairs [ 21..24 ] [ false ; true ]
|> Seq.ofList
|> Seq.map box
[<GlobalSetup>]
member _.Setup () = Run.shouldWrite <- false
[<Benchmark>]
[<ArgumentsSource "finalBenchmarkArgs">]
member this.Benchmark (args : obj) : unit =
let day, isPartOne = unbox<int * bool> args
if day <= 24 then
Run.allRuns.[day - 1] (not isPartOne) (Inputs.day day)
else if not isPartOne || day <> 25 then
failwithf "Unexpected args: %+A" args
else
Run.day25 (Inputs.day 25)
[<GlobalCleanup>]
member _.Cleanup () = Run.shouldWrite <- true
module Program = module Program =
type Dummy =
class
end
let readResource (name : string) : string =
let asm = Assembly.GetAssembly typeof<Dummy>
use stream = asm.GetManifestResourceStream $"AdventOfCode2022.App.%s{name}"
use reader = new StreamReader (stream)
reader.ReadToEnd ()
[<EntryPoint>] [<EntryPoint>]
let main args = let main _ =
match args with let days = Array.init 9 (fun day -> readResource $"Day%i{day + 1}.txt")
| [| "bench" |] ->
let config =
ManualConfig
.Create(DefaultConfig.Instance)
.WithOptions ConfigOptions.DisableOptimizationsValidator
let _summary = BenchmarkRunner.Run<Benchmarks.Benchmark1To5> config let inline day (i : int) = days.[i - 1]
let _summary = BenchmarkRunner.Run<Benchmarks.Benchmark6To10> config
let _summary = BenchmarkRunner.Run<Benchmarks.Benchmark11To15> config
let _summary = BenchmarkRunner.Run<Benchmarks.Benchmark16To20> config
let _summary = BenchmarkRunner.Run<Benchmarks.Benchmark21To25> config
0
| _ ->
let time = Stopwatch.StartNew () let time = Stopwatch.StartNew ()
time.Restart () time.Restart ()
for day = 1 to Run.allRuns.Length do do
Run.allRuns.[day - 1] false (Inputs.day day) let lines = StringSplitEnumerator.make '\n' (day 1)
Run.allRuns.[day - 1] true (Inputs.day day) printfn "%i" (Day1.part1 lines)
printfn "%i" (Day1.part2 lines)
Run.day25 (Inputs.day 25) do
let lines = StringSplitEnumerator.make '\n' (day 2)
printfn "%i" (Day2.part1 lines)
printfn "%i" (Day2.part2 lines)
do
let day3 = day 3
let lines = StringSplitEnumerator.make '\n' day3
printfn "%i" (Day3Efficient.part1 lines)
printfn "%i" (Day3Efficient.part2 (day3.Split '\n'))
do
let lines = StringSplitEnumerator.make '\n' (day 4)
printfn "%i" (Day4.part1 lines)
printfn "%i" (Day4.part2 lines)
do
let lines = StringSplitEnumerator.make '\n' (day 5)
printfn "%s" (Day5.part1 lines)
printfn "%s" (Day5.part2 lines)
do
let day6 = day 6
printfn "%i" (Day6.part1 day6)
printfn "%i" (Day6.part2 day6)
do
let day7 = day(7).Split '\n'
printfn "%i" (Day7.part1 day7)
printfn "%i" (Day7.part2 day7)
do
let day8 = StringSplitEnumerator.make '\n' (day 8)
printfn "%i" (Day8.part1 day8)
printfn "%i" (Day8.part2 day8)
do
let day9 = StringSplitEnumerator.make '\n' (day 9)
printfn "%i" (Day9.part1 day9)
printfn "%i" (Day9.part2 day9)
time.Stop () time.Stop ()
printfn $"Took %i{time.ElapsedMilliseconds}ms" printfn $"Took %i{time.ElapsedMilliseconds}ms"

View File

@@ -1,383 +0,0 @@
namespace AdventOfCode2022.App
open AdventOfCode2022
[<RequireQualifiedAccess>]
module Run =
let mutable shouldWrite = true
let day1 (partTwo : bool) (input : string) =
let lines = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day1.part1 lines
if shouldWrite then
printfn "%i" output
else
let output = Day1.part2 lines
if shouldWrite then
printfn "%i" output
let day2 (partTwo : bool) (input : string) =
let lines = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day2.part1 lines
if shouldWrite then
printfn "%i" output
else
let output = Day2.part2 lines
if shouldWrite then
printfn "%i" output
let day3 (partTwo : bool) (input : string) =
let lines = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day3Efficient.part1 lines
if shouldWrite then
printfn "%i" output
else
let output = Day3Efficient.part2 (input.Split '\n')
if shouldWrite then
printfn "%i" output
let day4 (partTwo : bool) (input : string) =
let lines = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day4.part1 lines
if shouldWrite then
printfn "%i" output
else
let output = Day4.part2 lines
if shouldWrite then
printfn "%i" output
let day5 (partTwo : bool) (input : string) =
let lines = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day5.part1 lines
if shouldWrite then
printfn "%s" output
else
let output = Day5.part2 lines
if shouldWrite then
printfn "%s" output
let day6 (partTwo : bool) (input : string) =
if not partTwo then
let output = Day6.part1 input
if shouldWrite then
printfn "%i" output
else
let output = Day6.part2 input
if shouldWrite then
printfn "%i" output
let day7 (partTwo : bool) (input : string) =
let day7 = input.Split '\n'
if not partTwo then
let output = Day7.part1 day7
if shouldWrite then
printfn "%i" output
else
let output = Day7.part2 day7
if shouldWrite then
printfn "%i" output
let day8 (partTwo : bool) (input : string) =
let day8 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day8.part1 day8
if shouldWrite then
printfn "%i" output
else
let output = Day8.part2 day8
if shouldWrite then
printfn "%i" output
let day9 (partTwo : bool) (input : string) =
let day9 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day9.part1 day9
if shouldWrite then
printfn "%i" output
else
let output = Day9.part2 day9
if shouldWrite then
printfn "%i" output
let day10 (partTwo : bool) (input : string) =
let day10 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day10.part1 day10
if shouldWrite then
printfn "%i" output
else
let output = Day10.part2 day10
if shouldWrite then
Day10.render (printfn "%s") output
let day11 (partTwo : bool) (input : string) =
let day11 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day11.part1 day11
if shouldWrite then
printfn "%i" output
else
let output = Day11.part2 day11
if shouldWrite then
printfn "%i" output
let day12 (partTwo : bool) (input : string) =
let day12 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day12.part1 day12
if shouldWrite then
printfn "%i" output
else
let output = Day12.part2 day12
if shouldWrite then
printfn "%i" output
let day13 (partTwo : bool) (input : string) =
let day13 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day13.part1 day13
if shouldWrite then
printfn "%i" output
else
let output = Day13.part2 day13
if shouldWrite then
printfn "%i" output
let day14 (partTwo : bool) (input : string) =
let day14 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day14.part1 day14
if shouldWrite then
printfn "%i" output
else
let output = Day14.part2 day14
if shouldWrite then
printfn "%i" output
let day15 (partTwo : bool) (input : string) =
let day15 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day15.part1 2000000 day15
if shouldWrite then
printfn "%i" output
else
let output = Day15.part2 4000000 day15
if shouldWrite then
printfn "%i" output
let day16 (partTwo : bool) (input : string) =
let day16 = input.Split '\n'
if not partTwo then
let output = Day16.part1 day16
if shouldWrite then
printfn "%i" output
else
let output = Day16.part2 day16
if shouldWrite then
printfn "%i" output
let day17 (partTwo : bool) (input : string) =
let day17 = input.TrimEnd ()
if not partTwo then
let output = Day17.part1 day17
if shouldWrite then
printfn "%i" output
else
let output = Day17.part2 day17
if shouldWrite then
printfn "%i" output
let day18 (partTwo : bool) (input : string) =
let day18 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day18.part1 day18
if shouldWrite then
printfn "%i" output
else
let output = Day18.part2 day18
if shouldWrite then
printfn "%i" output
let day19 (partTwo : bool) (input : string) =
let day19 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day19.part1 day19
if shouldWrite then
printfn "%i" output
else
let output = Day19.part2 day19
if shouldWrite then
printfn "%i" output
let day20 (partTwo : bool) (input : string) =
let day20 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day20.part1 day20
if shouldWrite then
printfn "%i" output
else
let output = Day20.part2 day20
if shouldWrite then
printfn "%i" output
let day21 (partTwo : bool) (input : string) =
let day21 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day21.part1 day21
if shouldWrite then
printfn "%i" output
else
let output = Day21.part2 day21
if shouldWrite then
printfn "%i" output
let day22 (partTwo : bool) (input : string) =
let day22 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day22.part1 day22
if shouldWrite then
printfn "%i" output
else
let output = Day22.part2 day22
if shouldWrite then
printfn "%i" output
let day23 (partTwo : bool) (input : string) =
let day23 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day23.part1 day23
if shouldWrite then
printfn "%i" output
else
let output = Day23.part2 day23
if shouldWrite then
printfn "%i" output
let day24 (partTwo : bool) (input : string) =
let day24 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day24.part1 day24
if shouldWrite then
printfn "%i" output
else
let output = Day24.part2 day24
if shouldWrite then
printfn "%i" output
let day25 (input : string) =
let day25 = StringSplitEnumerator.make '\n' input
let output = Day25.part1 day25
if shouldWrite then
printfn "%s" output
let allRuns =
[|
day1
day2
day3
day4
day5
day6
day7
day8
day9
day10
day11
day12
day13
day14
day15
day16
day17
day18
day19
day20
day21
day22
day23
day24
|]

View File

@@ -8,6 +8,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Assembly.fs" /> <Compile Include="Assembly.fs" />
<Compile Include="TestEnumerators.fs" />
<Compile Include="Day1.fs" /> <Compile Include="Day1.fs" />
<Compile Include="Day2.fs" /> <Compile Include="Day2.fs" />
<Compile Include="Day3.fs" /> <Compile Include="Day3.fs" />
@@ -17,22 +18,6 @@
<Compile Include="Day7.fs" /> <Compile Include="Day7.fs" />
<Compile Include="Day8.fs" /> <Compile Include="Day8.fs" />
<Compile Include="Day9.fs" /> <Compile Include="Day9.fs" />
<Compile Include="Day10.fs" />
<Compile Include="Day11.fs" />
<Compile Include="Day12.fs" />
<Compile Include="Day13.fs" />
<Compile Include="Day14.fs" />
<Compile Include="Day15.fs" />
<Compile Include="Day16.fs" />
<Compile Include="Day17.fs" />
<Compile Include="Day18.fs" />
<Compile Include="Day19.fs" />
<Compile Include="Day20.fs" />
<Compile Include="Day21.fs" />
<Compile Include="Day22.fs" />
<Compile Include="Day23.fs" />
<Compile Include="Day24.fs" />
<Compile Include="Day25.fs" />
<EmbeddedResource Include="Inputs\Day1.txt" /> <EmbeddedResource Include="Inputs\Day1.txt" />
<EmbeddedResource Include="Inputs\Day2.txt" /> <EmbeddedResource Include="Inputs\Day2.txt" />
<EmbeddedResource Include="Inputs\Day3.txt" /> <EmbeddedResource Include="Inputs\Day3.txt" />
@@ -42,22 +27,6 @@
<EmbeddedResource Include="Inputs\Day7.txt" /> <EmbeddedResource Include="Inputs\Day7.txt" />
<EmbeddedResource Include="Inputs\Day8.txt" /> <EmbeddedResource Include="Inputs\Day8.txt" />
<EmbeddedResource Include="Inputs\Day9.txt" /> <EmbeddedResource Include="Inputs\Day9.txt" />
<EmbeddedResource Include="Inputs\Day10.txt" />
<EmbeddedResource Include="Inputs\Day11.txt" />
<EmbeddedResource Include="Inputs\Day12.txt" />
<EmbeddedResource Include="Inputs\Day13.txt" />
<EmbeddedResource Include="Inputs\Day14.txt" />
<EmbeddedResource Include="Inputs\Day15.txt" />
<EmbeddedResource Include="Inputs\Day16.txt" />
<EmbeddedResource Include="Inputs\Day17.txt" />
<EmbeddedResource Include="Inputs\Day18.txt" />
<EmbeddedResource Include="Inputs\Day19.txt" />
<EmbeddedResource Include="Inputs\Day20.txt" />
<EmbeddedResource Include="Inputs\Day21.txt" />
<EmbeddedResource Include="Inputs\Day22.txt" />
<EmbeddedResource Include="Inputs\Day23.txt" />
<EmbeddedResource Include="Inputs\Day24.txt" />
<EmbeddedResource Include="Inputs\Day25.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -38,6 +38,7 @@ module TestDay1 =
let ``Part 1, given example`` () = let ``Part 1, given example`` () =
Day1.part1 (StringSplitEnumerator.make '\n' testInput) |> shouldEqual 24000 Day1.part1 (StringSplitEnumerator.make '\n' testInput) |> shouldEqual 24000
[<Test>] [<Test>]
let ``Part 2, given example`` () = let ``Part 2, given example`` () =
Day1.part2 (StringSplitEnumerator.make '\n' testInput) |> shouldEqual 45000 Day1.part2 (StringSplitEnumerator.make '\n' testInput) |> shouldEqual 45000

View File

@@ -1,203 +0,0 @@
namespace AdventOfCode2022.Test
open System
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay10 =
let input =
"""addx 15
addx -11
addx 6
addx -3
addx 5
addx -1
addx -8
addx 13
addx 4
noop
addx -1
addx 5
addx -1
addx 5
addx -1
addx 5
addx -1
addx 5
addx -1
addx -35
addx 1
addx 24
addx -19
addx 1
addx 16
addx -11
noop
noop
addx 21
addx -15
noop
noop
addx -3
addx 9
addx 1
addx -3
addx 8
addx 1
addx 5
noop
noop
noop
noop
noop
addx -36
noop
addx 1
addx 7
noop
noop
noop
addx 2
addx 6
noop
noop
noop
noop
noop
addx 1
noop
noop
addx 7
addx 1
noop
addx -13
addx 13
addx 7
noop
addx 1
addx -33
noop
noop
noop
addx 2
noop
noop
noop
addx 8
noop
addx -1
addx 2
addx 1
noop
addx 17
addx -9
addx 1
addx 1
addx -3
addx 11
noop
noop
addx 1
noop
addx 1
noop
noop
addx -13
addx -19
addx 1
addx 3
addx 26
addx -30
addx 12
addx -1
addx 3
addx 1
noop
noop
noop
addx -9
addx 18
addx 1
addx 2
noop
noop
addx 9
noop
noop
noop
addx -1
addx 2
addx -37
addx 1
addx 3
noop
addx 15
addx -21
addx 22
addx -6
addx 1
noop
addx 2
addx 1
noop
addx -10
noop
noop
addx 20
addx 1
addx 2
addx 2
addx -6
addx -11
noop
noop
noop
"""
[<Test>]
let ``Part 1, given`` () =
Day10.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 13140
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day10.txt"
Day10.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 15140
[<Test>]
let ``Part 2, given`` () =
let output = ResizeArray ()
Day10.part2 (StringSplitEnumerator.make '\n' input) |> Day10.render output.Add
output
|> List.ofSeq
|> shouldEqual
[
"##..##..##..##..##..##..##..##..##..##.."
"###...###...###...###...###...###...###."
"####....####....####....####....####...."
"#####.....#####.....#####.....#####....."
"######......######......######......####"
"#######.......#######.......#######....."
]
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day10.txt"
let output = ResizeArray ()
Day10.part2 (StringSplitEnumerator.make '\n' input) |> Day10.render output.Add
output
|> List.ofSeq
|> shouldEqual
[
"###..###....##..##..####..##...##..###.."
"#..#.#..#....#.#..#....#.#..#.#..#.#..#."
"###..#..#....#.#..#...#..#....#..#.#..#."
"#..#.###.....#.####..#...#.##.####.###.."
"#..#.#....#..#.#..#.#....#..#.#..#.#...."
"###..#.....##..#..#.####..###.#..#.#...."
]

View File

@@ -1,58 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay11 =
let input =
"""Monkey 0:
Starting items: 79, 98
Operation: new = old * 19
Test: divisible by 23
If true: throw to monkey 2
If false: throw to monkey 3
Monkey 1:
Starting items: 54, 65, 75, 74
Operation: new = old + 6
Test: divisible by 19
If true: throw to monkey 2
If false: throw to monkey 0
Monkey 2:
Starting items: 79, 60, 97
Operation: new = old * old
Test: divisible by 13
If true: throw to monkey 1
If false: throw to monkey 3
Monkey 3:
Starting items: 74
Operation: new = old + 3
Test: divisible by 17
If true: throw to monkey 0
If false: throw to monkey 1
"""
[<Test>]
let ``Part 1, given`` () =
Day11.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 10605
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day11.txt"
Day11.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 120384
[<Test>]
let ``Part 2, given`` () =
Day11.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 2713310158L
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day11.txt"
Day11.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 32059801242L

View File

@@ -1,36 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay12 =
let input =
"""Sabqponm
abcryxxl
accszExk
acctuvwj
abdefghi
"""
[<Test>]
let ``Part 1, given`` () =
Day12.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 31
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day12.txt"
Day12.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 456
[<Test>]
let ``Part 2, given`` () =
Day12.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 29
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day12.txt"
Day12.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 454

View File

@@ -1,54 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay13 =
let input =
"""[1,1,3,1,1]
[1,1,5,1,1]
[[1],[2,3,4]]
[[1],4]
[9]
[[8,7,6]]
[[4,4],4,4]
[[4,4],4,4,4]
[7,7,7,7]
[7,7,7]
[]
[3]
[[[]]]
[[]]
[1,[2,[3,[4,[5,6,7]]]],8,9]
[1,[2,[3,[4,[5,6,0]]]],8,9]
"""
[<Test>]
let ``Part 1, given`` () =
Day13.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 13
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day13.txt"
Day13.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 5185
[<Test>]
let ``Part 2, given`` () =
Day13.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 140
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day13.txt"
Day13.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 23751

View File

@@ -1,33 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay14 =
let input =
"""498,4 -> 498,6 -> 496,6
503,4 -> 502,4 -> 502,9 -> 494,9
"""
[<Test>]
let ``Part 1, given`` () =
Day14.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 24
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day14.txt"
Day14.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 768
[<Test>]
let ``Part 2, given`` () =
Day14.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 93
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day14.txt"
Day14.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 26686

View File

@@ -1,48 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay15 =
let input =
"""Sensor at x=2, y=18: closest beacon is at x=-2, y=15
Sensor at x=9, y=16: closest beacon is at x=10, y=16
Sensor at x=13, y=2: closest beacon is at x=15, y=3
Sensor at x=12, y=14: closest beacon is at x=10, y=16
Sensor at x=10, y=20: closest beacon is at x=10, y=16
Sensor at x=14, y=17: closest beacon is at x=10, y=16
Sensor at x=8, y=7: closest beacon is at x=2, y=10
Sensor at x=2, y=0: closest beacon is at x=2, y=10
Sensor at x=0, y=11: closest beacon is at x=2, y=10
Sensor at x=20, y=14: closest beacon is at x=25, y=17
Sensor at x=17, y=20: closest beacon is at x=21, y=22
Sensor at x=16, y=7: closest beacon is at x=15, y=3
Sensor at x=14, y=3: closest beacon is at x=15, y=3
Sensor at x=20, y=1: closest beacon is at x=15, y=3
"""
[<Test>]
let ``Part 1, given`` () =
Day15.part1 10 (StringSplitEnumerator.make '\n' input) |> shouldEqual 26
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day15.txt"
Day15.part1 2000000 (StringSplitEnumerator.make '\n' input)
|> shouldEqual 6275922
[<Test>]
let ``Part 2, given`` () =
Day15.part2 20 (StringSplitEnumerator.make '\n' input) |> shouldEqual 56000011
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day15.txt"
Day15.part2 4000000 (StringSplitEnumerator.make '\n' input)
|> shouldEqual 11747175442119L

View File

@@ -1,49 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay16 =
let input =
"""Valve AA has flow rate=0; tunnels lead to valves DD, II, BB
Valve BB has flow rate=13; tunnels lead to valves CC, AA
Valve CC has flow rate=2; tunnels lead to valves DD, BB
Valve DD has flow rate=20; tunnels lead to valves CC, AA, EE
Valve EE has flow rate=3; tunnels lead to valves FF, DD
Valve FF has flow rate=0; tunnels lead to valves EE, GG
Valve GG has flow rate=0; tunnels lead to valves FF, HH
Valve HH has flow rate=22; tunnel leads to valve GG
Valve II has flow rate=0; tunnels lead to valves AA, JJ
Valve JJ has flow rate=21; tunnel leads to valve II
"""
[<Test>]
let ``seq behaviour`` () =
IntSet.ofSeq [ 1 ; 2 ; 3 ; 16 ]
|> IntSet.toSeq
|> List.ofSeq
|> shouldEqual [ 1 ; 2 ; 3 ; 16 ]
[<Test>]
let ``Part 1, given`` () =
Day16.part1 (input.Split '\n') |> shouldEqual 1651
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day16.txt"
Day16.part1 (input.Split '\n') |> shouldEqual 1751
[<Test>]
let ``Part 2, given`` () =
Day16.part2 (input.Split '\n') |> shouldEqual 1707
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day16.txt"
Day16.part2 (input.Split '\n') |> shouldEqual 2207

View File

@@ -1,31 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay17 =
let input = ">>><<><>><<<>><>>><<<>>><<<><<<>><>><<>>"
[<Test>]
let ``Part 1, given`` () =
Day17.part1 (input.TrimEnd ()) |> shouldEqual 3068
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day17.txt"
Day17.part1 (input.TrimEnd ()) |> shouldEqual 3127
[<Test>]
let ``Part 2, given`` () =
Day17.part2 (input.TrimEnd ()) |> shouldEqual 1514285714288L
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day17.txt"
Day17.part2 (input.TrimEnd ()) |> shouldEqual 1542941176480L

View File

@@ -1,51 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay18 =
let input1 =
"""1,1,1
2,1,1
"""
let input2 =
"""2,2,2
1,2,2
3,2,2
2,1,2
2,3,2
2,2,1
2,2,3
2,2,4
2,2,6
1,2,5
3,2,5
2,1,5
2,3,5
"""
[<Test>]
let ``Part 1, given`` () =
Day18.part1 (StringSplitEnumerator.make '\n' input1) |> shouldEqual 10
Day18.part1 (StringSplitEnumerator.make '\n' input2) |> shouldEqual 64
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day18.txt"
Day18.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 3542
[<Test>]
let ``Part 2, given`` () =
Day18.part2 (StringSplitEnumerator.make '\n' input2) |> shouldEqual 58
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day18.txt"
Day18.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 2080

View File

@@ -1,34 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay19 =
let input =
"""Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 2 ore. Each obsidian robot costs 3 ore and 14 clay. Each geode robot costs 2 ore and 7 obsidian.
Blueprint 2: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 8 clay. Each geode robot costs 3 ore and 12 obsidian.
"""
[<Test>]
let ``Part 1, given`` () =
Day19.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 33
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day19.txt"
Day19.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 2341
[<Test>]
let ``Part 2, given`` () =
Day19.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual (62 * 56)
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day19.txt"
Day19.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 3689

View File

@@ -1,39 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay20 =
let input =
"""1
2
-3
3
-2
0
4
"""
[<Test>]
let ``Part 1, given`` () =
Day20.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 3
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day20.txt"
Day20.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 7225
[<Test>]
let ``Part 2, given`` () =
Day20.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 1623178306L
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day20.txt"
Day20.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 548634267428L

View File

@@ -1,49 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay21 =
let input =
"""root: pppw + sjmn
dbpl: 5
cczh: sllz + lgvd
zczc: 2
ptdq: humn - dvpt
dvpt: 3
lfqf: 4
humn: 5
ljgn: 2
sjmn: drzm * dbpl
sllz: 4
pppw: cczh / lfqf
lgvd: ljgn * ptdq
drzm: hmdt - zczc
hmdt: 32
"""
[<Test>]
let ``Part 1, given`` () =
Day21.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 152L
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day21.txt"
Day21.part1 (StringSplitEnumerator.make '\n' input)
|> shouldEqual 54703080378102L
[<Test>]
let ``Part 2, given`` () =
Day21.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 301L
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day21.txt"
Day21.part2 (StringSplitEnumerator.make '\n' input)
|> shouldEqual 3952673930912L

View File

@@ -1,46 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay22 =
let input =
""" ...#
.#..
#...
....
...#.......#
........#...
..#....#....
..........#.
...#....
.....#..
.#......
......#.
10R5L5R10L4R5L5
"""
[<Test>]
let ``Part 1, given`` () =
Day22.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 6032
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day22.txt"
Day22.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 103224
[<Test>]
let ``Part 2, given`` () =
Day22.part2Example (StringSplitEnumerator.make '\n' input) |> shouldEqual 5031
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day22.txt"
Day22.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 189097

View File

@@ -1,39 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay23 =
let input =
"""....#..
..###.#
#...#.#
.#...##
#.###..
##.#.##
.#..#..
"""
[<Test>]
let ``Part 1, given`` () =
Day23.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 110
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day23.txt"
Day23.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 4025
[<Test>]
let ``Part 2, given`` () =
Day23.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 20
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day23.txt"
Day23.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 935

View File

@@ -1,38 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay24 =
let input =
"""#.######
#>>.<^<#
#.<..<<#
#>v.><>#
#<^v^^>#
######.#
"""
[<Test>]
let ``Part 1, given`` () =
Day24.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 18
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day24.txt"
Day24.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 283
[<Test>]
let ``Part 2, given`` () =
Day24.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 54
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day24.txt"
Day24.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 883

View File

@@ -1,76 +0,0 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
open System
[<TestFixture>]
module TestDay25 =
let input =
"""1=-0-2
12111
2=0=
21
2=01
111
20012
112
1=-1=
1-12
12
1=
122
"""
[<Test>]
let ``Part 1, given`` () =
Day25.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual "2=-1=0"
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day25.txt"
Day25.part1 (StringSplitEnumerator.make '\n' input)
|> shouldEqual "2-0=11=-0-2-1==1=-22"
let testCases =
[
1, "1"
2, "2"
3, "1="
4, "1-"
5, "10"
6, "11"
7, "12"
8, "2="
9, "2-"
10, "20"
15, "1=0"
20, "1-0"
2022, "1=11-2"
12345, "1-0---0"
314159265, "1121-1110-1=0"
1747, "1=-0-2"
906, "12111"
198, "2=0="
11, "21"
201, "2=01"
31, "111"
1257, "20012"
32, "112"
353, "1=-1="
107, "1-12"
7, "12"
3, "1="
37, "122"
]
|> List.map TestCaseData
[<TestCaseSource(nameof testCases)>]
let ``toInt works`` (int : int, str : string) =
Day25.toInt (str.AsSpan ()) |> shouldEqual int
[<TestCaseSource(nameof testCases)>]
let ``ofInt works`` (int : int, str : string) = Day25.ofInt int |> shouldEqual str

View File

@@ -1,137 +0,0 @@
noop
noop
addx 5
addx 1
addx 10
addx -4
noop
addx -1
noop
addx 5
addx -5
addx 9
addx 2
addx -15
addx 18
addx 8
addx -2
noop
addx -18
addx 21
addx 1
addx -37
addx 27
addx -24
addx 2
addx 5
addx -7
addx 26
addx -16
addx 2
addx 5
addx -15
noop
addx 20
addx 2
addx 4
addx -3
addx 2
noop
addx 3
addx 2
addx 5
addx -40
addx 2
addx 33
addx -30
addx 5
addx 5
addx 17
addx -19
addx 2
addx 5
addx 20
addx -16
addx 3
addx -2
addx 7
noop
addx -2
addx 5
addx 2
addx 3
addx -2
addx -38
addx 5
addx 2
addx 1
addx 15
addx -8
noop
addx -2
addx 4
addx 2
addx 4
addx -2
noop
addx 6
addx 2
addx -1
addx 4
noop
addx 1
addx 4
noop
noop
noop
addx -37
addx 5
addx 2
addx 22
addx -17
addx -2
noop
addx 3
addx 2
noop
addx 3
addx 2
noop
noop
noop
addx 5
addx 5
addx 2
addx 3
noop
addx 2
addx -23
addx 2
addx -14
noop
addx 29
addx -26
noop
addx 8
noop
noop
noop
addx -9
addx 11
addx 5
addx 2
noop
addx 1
noop
noop
addx 5
noop
noop
addx 2
noop
addx 3
addx 2
addx -2
noop
noop
noop

View File

@@ -1,55 +0,0 @@
Monkey 0:
Starting items: 99, 67, 92, 61, 83, 64, 98
Operation: new = old * 17
Test: divisible by 3
If true: throw to monkey 4
If false: throw to monkey 2
Monkey 1:
Starting items: 78, 74, 88, 89, 50
Operation: new = old * 11
Test: divisible by 5
If true: throw to monkey 3
If false: throw to monkey 5
Monkey 2:
Starting items: 98, 91
Operation: new = old + 4
Test: divisible by 2
If true: throw to monkey 6
If false: throw to monkey 4
Monkey 3:
Starting items: 59, 72, 94, 91, 79, 88, 94, 51
Operation: new = old * old
Test: divisible by 13
If true: throw to monkey 0
If false: throw to monkey 5
Monkey 4:
Starting items: 95, 72, 78
Operation: new = old + 7
Test: divisible by 11
If true: throw to monkey 7
If false: throw to monkey 6
Monkey 5:
Starting items: 76
Operation: new = old + 8
Test: divisible by 17
If true: throw to monkey 0
If false: throw to monkey 2
Monkey 6:
Starting items: 69, 60, 53, 89, 71, 88
Operation: new = old + 5
Test: divisible by 19
If true: throw to monkey 7
If false: throw to monkey 1
Monkey 7:
Starting items: 72, 54, 63, 80
Operation: new = old + 3
Test: divisible by 7
If true: throw to monkey 1
If false: throw to monkey 3

View File

@@ -1,41 +0,0 @@
abcccccccccccccccccccccccccccccccccccccaaaaaaacccccccaaaaaaaaaaaccccccccccccccccccccaaacaaaaaaaacccccccccccccccccccccccccccccccccccaaaaa
abccccccccccccccccccaaccaacccccccccccccaaaaaaaccccccccaaaaaaaaaaacccccccaaaaccccccccaaaaaaaaaaaaacccccccccccccccccccccccccccccccccaaaaaa
abccccccccccccccccccaaaaaaccccccccccaaaccaaaaaacccccccaaaaaaaaaaccccccccaaaaccccccaaaaaaaaaaaaaaacccccccccccccccccccaaacccccccccccaaaaaa
abcccccccccccccccccccaaaaacccccccccccaaccaacaaaccccccaaaaaaaaaaaccccccccaaaacccccaaaaaaaaacaaaaaaacccccccccccccccccaaaacccccccccccaaacaa
abccccccccccccccccccaaaaaaccccccccaacaaaaaacccccccccaaaaaaaaaaaaacaaaccccaaccccccaaaaaaaaacaacccccccccccccccccaaaccaaaacccccccccccccccaa
abcccccccccccccccccaaaaaaaacccccccaaaaaaaaccccccaaaaaaaacaaaacaaaaaaacccccccccaaccccaaaaaacaaacccccccccccccccaaaakkkaaccccccccccccccccaa
abcccccccccccccccccaaaaaaaaccccccccaaaaaccccaacccaaaaaaaaaaaacaaaaaaccccccccccaacccaaaaaaaaaaaacccccccccccccccakkkkkklcccccccccccccccccc
abaaacccccccccccaaccccaaccccccccccccaaaaaccaaacccaaaaaaaaaaaaaaaaaaaaccccccaaaaaaaacaacccaaaaaaccccccccccccccckkkkkkkllcccccccaaaccccccc
abaaaacccccccaacaaccccaacccccccccccaaacaaaaaaaccccaaaaaaaaaaaaaaaaaaaacccccaaaaaaaaaaaccccaaaaacccccccccccccckkkksssllllccccccaaaaaacccc
abaaaacccccccaaaaacccccccccccaaaccccaacaaaaaaccccaaaaaacaaaaaaaaaaaaaacccccccaaaaccccccccaaaaacccccccccccccckkkksssssllllcccccaaaaaacccc
abaaacccccccccaaaaaaccccccccaaaaccccccccaaaaaaaacaaaaaaaaaaaaacaaacaaacccccccaaaaacccccccaaaaacccccccccccccjkkkrssssssllllccccccaaaccccc
abccccccccccaaaaaaaaccccccccaaaacccccccaaaaaaaaacaacaaaaaaaaaacaaaccccccccccaaacaaccccccccccccccccccccccccjjkkrrsuuussslllllcccccaaccccc
abccaaacccccaaaaacccccccccccaaaaccccccaaaaaaaaaacccccaaaaaaaaaacaaccccccccccaacccacccccccccccccccccccccjjjjjjrrrsuuuussslllllmcccddacccc
abcccaaaccaccacaaaccccccccccccccccccccaaaaaaaccccccccccaaaaaaaaccccccaacccccccccccaaaaacccccccccccccccjjjjjjrrrruuuuuusssllmmmmmddddcccc
abccaaaaaaaacccaaaccccccccccccccccaaacccccaaaccccccccccccaaacccccccccaacccccccccccaaaaacccccccccccccjjjjjrrrrrruuuxuuussqqqqmmmmmdddcccc
abcaaaaaaaacccaaaaaacaaaaaccccccaaaaaaccccaaacccaaccccccccaaccccccaaaaaaaaccaaacccaaaaaaccccccccccccjjjjrrrrrruuuxxxuuuqqqqqqqmmmdddcccc
abaaaaaaaaaccccaaaaacaaaaaccccccaaaaaaaaccccccaaaaaaccccccccccccccaaaaaaaaccaaacaaaaaaaacccccccccccjjjjrrrtttuuuuxxxyvvvvvqqqqmmmdddcccc
abaaaaaaaaaccaaaaaaacaaaaaaccccccaaaaaaaacccccaaaaaaccccccccccccccccaaaaccaaaaaaaaaaaaaacccccccccaaiijqqqrttttuuuxxyyvvvvvvvqqmmmdddcccc
abcaaaaaaaaccaaaaaaaaaaaaaacccccaaaaaaaacccccccaaaacccccaaaaccccccccaaaaacaaaaaaaaccaaccccccccccaaaiiiqqqttttxxxxxxyyyyyyvvvqqmmmdddcccc
abcccaaaaaaacaaaaaaaaaaaaaacccccaaaaaaaaaaaccccaaaaccccaaaaacccccccaaaaaacaaaaaaacccccccccccccccaaaiiiqqqtttxxxxxxxyyyyyyvvqqqmmmdddcccc
SbcccaacccaccccaaacacccaaacccccccccaaaaaaaaacccaccaccccaaaaaaccccccaaccaacccaaaaaccccccccccccccccaaiiiiqqtttxxxxEzzzyyyyvvvqqqmmmddccccc
abccaaaccccccccaaccccccccccccccccccaaaaaaaaccccccccccccaaaaaaccccccccccccccaaacaaaccaacccccccccccccciiiqqqttttxxxyyyyyvvvvqqqmmmdddccccc
abccccccccccccccccccccccccccccccccaaaaaaaccccccccccccccaaaaaacccccccccccccccaacccccaaaaaaaccccccccccciiiqqqttttxxyyyyyvvvrrrnnneeecccccc
abcaaaaccccccccccccccccccccccccccaaaaaaaaccccccccccccccccaacccccccccccccccccccccccccaaaaacccccccccccciiiqqqqttxxyyyyyyyvvrrnnnneeecccccc
abcaaaaacccccccccccccccccccccccccaaaacaaacccaccaaacccccccccccccccccccccccccaaaccccaaaaaaaccccccccccccciiiqqqttwwyywwyyywwrrnnneeeccccccc
abaaaaaacccaccaccccccccccccccccccaaaaccaacccaaaaaaccccccccccccccccaaaccccaaaaaacccaaaaaaaacccccccccccciiiqqqtswwwwwwwwwwwrrnnneeeccccccc
abaaaaaacccaaaaccccccccaaaacccccccaaacccccccaaaaaacccccccccccccccaaaaaaccaaaaaacccaaaaaaaacaaccccccaaciiiqppsswwwwsswwwwwrrrnneeeccccccc
abcaaaaacccaaaaacccccccaaaacccccccccccccccccaaaaaaaccccccccccccccaaaaaaccaaaaaacccccaaaaaaaaaccccccaaaahhpppssswwsssswwwwrrrnneeeacccccc
abcaaaccccaaaaaacccccccaaaaccccccccccccccccaaaaaaaaccccccccccccccaaaaacccaaaaaccccccaacaaaaaaaaccaaaaaahhpppsssssssssrrrrrrnnneeeacccccc
abccccccccaaaaaaccccccccaacccccccccccccccccaaaaaaaaccccaacccccccccaaaaaccaaaaacccccccccaaaaaaaaccaaaaachhpppssssssoosrrrrrrnnneeeaaacccc
abccccccccccaaccccccccccccccccaaaaaccccccaacccaaacccaaaaacccccccccaacaacccccccccccccccccaaaaaaacccaaaaahhhppppssppooooorroonnffeaaaacccc
abaaccccccccccccccccccccccccccaaaaaccccccaacccaaaccccaaaaacccccccccccccccccccccccccccaacaaaaacccccaacaahhhppppppppoooooooooonfffaaaacccc
abaccccccccccccccccccccccccccaaaaaacccaaaaaaaacccccccaaaaaccccccccccccccccccccccccaaaaaaaaaaaccccccccccchhhpppppppgggoooooooffffaacccccc
abaccccccccccccccccccccccccccaaaaaacccaaaaaaaaccccccaaaaaccccccacccaacccccccccccccaaaaaccccaaccccccccccchhhhhhggggggggfffffffffaaacccccc
abaacccccccccccccccccccccccccaaaaaacccccaaaacccccccccaaaacccaacaacaaacccccccccccccaaaaaaacccccccccccccccchhhhgggggggggffffffffccaacccccc
abcccccccaacccccccccccccccccccaaaccccccaaaaaccccccccaaaaccaaaacaaaaacccccccccccccaaaaaaaaccccccccccccccccchhhggggaaaagffffffcccccccccccc
abcccccccaacccccccccccccaacccccccccccccaaaaaaccaaccccaaaaaaaaacaaaaaacccccccaaaacaaaaaaaacccccccccccaacccccccaaaacaaaacccccccccccccccccc
abccccaaaaaaaacccccccaacaaaccccccccccccaaccaacaaaacccaaaaaaaacaaaaaaaaccccccaaaaccacaaaccaaaccccaaaaaacccccccaacccaaaacccccccccccccaaaaa
abccccaaaaaaaacccccccaaaaaccccccccccccccccccccaaaaccccaaaaaaacaaaaaaaaccccccaaaaccccaaaccaaaaaccaaaaaaaacccccccccccaaaccccccccccccccaaaa
abccccccaaaaccccccccccaaaaaaccccccccccccccccccaaaacccaaaaaaaaaaccaaccccccccccaacccccccccaaaaacccaaaaaaaacccccccccccaaaccccccccccccccaaaa
abcccccaaaaaacccccccaaaaaaaacccccccccccccccccccccccaaaaaaaaaaaaaaaacccccccccccccccccccccaaaaaacccaaaaaaaccccccccccccccccccccccccccaaaaaa

View File

@@ -1,449 +0,0 @@
[[[[2],9,1,[2,2,4,8]],[1,8,8],9,[7,2,[7,0,1],0,[10,9,10,3]]]]
[[1,6,[[0,0,10,9]],[[10,6,0,2],[7,4],[2]],[[],3]],[[2,7,2],5,[[7,0,5],[8],1,[],3],2]]
[[10,10,10,4,[8,[8],6,[]]]]
[[],[[[8,2,6],0,4,10]],[8,[10,[10,4],[6]],2,7,[[8]]]]
[[7,2,[5],[[0,5,10],[4,10,10,6,1],5],4],[],[[2],4,8],[]]
[[1,3,[10,10,[3,5,8]],5,[6,[3,5,2,2],[1,2,10,2,10]]],[9,[[9,3,0,10],1,2],[[8,7],[0,3,9],[3],8],[5,[],8,[1,1,6],[]],2],[3,0]]
[[4,10,8,5,[[2,3],[8,0,2],[8,8,0,4,7],2]],[[5,[7],0,8]],[],[[],[[5,8],[1,6],[7]],[[],5],[4,6]]]
[[[[9,0,10],10]],[[7,5,1],7]]
[[1,[6,6,[7,3]]],[[],[],8],[2],[0,5,[[1,1,0,0,10]],8]]
[[[],[2,10,[10],[8,5]],[[10,6,5],[],1],[]],[[[],2,[7,1,4,8,4],7,[10,10]],1,[1],[5,8]],[],[2,5,[9,[8,2,0],8]],[[[]],1,[4,0,5],2,9]]
[[],[2,4,[[9,1,2,0,0]]],[[[0,8,2,5,5],2,1],[4]]]
[[9,4],[],[[[4,7],4],[[10,8]],[5,[6,2],[8],[]],[[2,9,7,7],8],[[5,8,9,7,5]]],[2,[9,[],[8,8,3,7,2],1,[10,9,8,1,8]],[],5,0],[[],9,[5,0,[2,5,2,10,8],2],[[1,4,7,7],10],7]]
[[[4,[4]],0,[9,6,[3,10],[],[1,9,2]]],[8,9,[6,3],[[],2,[5,6,1,0]]]]
[[6,6,[[9],10]],[7,[[7,5],6],9]]
[[],[],[[],3,[[9,3,3],1]]]
[[],[[[4,1,4,10],[7,10,8,8],[7]]],[7,9,0]]
[[[9,[0],7,[6,6,10],7],[2,9,9]]]
[[[5,5,9,[8,5,9,10,2]]],[8],[8,3,[[]],6],[2,4,[[5,10,7,9,1],[3,4,5],[5,0,0]],[7,0],[1,[]]]]
[3,3,9,9,9]
[3,3,9,9]
[[[[9]],3],[]]
[[],[10,[[6,7],[4]],7,[[10,4,3],7],1],[],[[10,10,[4,3,8,3,3]],[[9],[9,4,4]],5,0,[]],[]]
[[[],8,4],[[[2,9,0]],[[],[7,2],2,[8,7,2]],9,4],[4,1,5]]
[[[[10,10,6,0],[5,6,3],[],6,[6,9]]]]
[[[8,[],5,[8,0,4],[6]]],[8,9,4,[],[[7,2],10,0,[0,9,6,1],[5,6]]],[[]],[1,[],6,[5,[0,8,6,8,4]]],[[[3,8,8,4,9],9,[1],5],[7],7]]
[[2],[[[4,0],5],3]]
[[[9],[[5,0,5,8],[8,6,2,4,2]],[[]],2],[4,[10,10,4,3],[[9,9],[1,0,9,10]],10],[[],3]]
[[[],9,[[],8],[]],[[[2,3,10,5],9]]]
[[[8,6],[1,[]],10],[[8,[5,9],5,7],10,4,1]]
[[],[]]
[[],[[2,[8],2],7],[8,8,3,5],[[5],[2,[],8,[5,3,0,2],2]],[[[3,5,1,2],[0,10],[9,10],2],[[9],0],10,[[0,0,2,7,2]],5]]
[[[7,[6,7,8,5,3]],5,0,7],[5,[[7,4,2],2,[]]]]
[[[1,[4,8,1,6,2],2],5,10,2,9],[0,7,0,[],7],[2,[3],[1,1,[9],8],[1,5],[[0,10],[2,9,4,5],[],[5,5,4]]]]
[[[[]],7,[[3,9,10,2,8],[7,0,5,6,3]]],[[[9,2,3,9,2],[5,6,3,5,5]]]]
[[[],2,[6],6,2]]
[[[[9],8,[4,1,2,3]],[]]]
[[[[9,1,4],8],8,[10,2,10],[[8],[10,5,0],[8,10,10,0,6]],[8,2,8]],[1]]
[[10,[],[[2]]],[[],0,1,10]]
[[[2],2,[4],[9,4,10,9]],[0,[[4],6,[0],10,6],0,1,[6]]]
[[[3,8]],[2],[[9,[3],7],7,[[8,1,6,10],9,8],6,[9,[5,2]]],[1,5,[[],0,0,3]],[4,3]]
[[9,0,10,6],[9,3,[],[6,[3,0,1,10,9],[10,10,4,0],5]],[],[[5,10]],[8,[[10,2,0],[8,9,2,10,5],[9,4,9,1]]]]
[[3,[9],[[8,7,2,5]],[3,0,[],4]]]
[[9,5,10,[[]]],[7,1,8,1]]
[[8,[[3],[9,10],[8,0,7],0]],[0],[4,2,[[5,2,10]]]]
[[[6],[6,5,10,1]],[3,4,[],9],[[[10,4],7,[],[0,1]],[[],6],[1,3,[3,7,1,6,5]]],[[9],7,5,5]]
[[4,[[2],[8,3,5],[8,1]],4,[],[]],[[[8,5,10,2,10],[9,7,5,9],[10,5,1,5]],[3,[3]]],[[[6,6,2,6],3,[],[0,7,10]]],[9],[[2,[0,6,9],8,[],[10,2]],2,[]]]
[[[0,8]]]
[[2,6,[[4,9],[5,0,7,10,5],4],6],[[[7],8],2,[]],[[],6],[3]]
[[[],[1],[],[]],[]]
[[[[],[6],2,[1,1,0]],10,[0,[2,4,5,2],[],[7,2,7],8]],[],[],[0]]
[[10,[[10,7],[7,1,6,7,4],[1,7,5,10,2]]],[0,[[1,0,7,5],[6,6,1,9]]],[5,8,[9]]]
[[],[[1,[1,3],[3,9],6]],[]]
[[[[10,8,9],[1],1,9],10,3,4,[]]]
[[4]]
[[[1,[]],[]],[8,[[],[4,7],0,[5,9,10,6]],[],[9],1]]
[[2,5],[],[[[8,2,2],[],[4,1,1,0]]]]
[[1,3,[],[[]],[[6,3,5,5],[4],[0],7,10]],[],[[[6],4,7,6]]]
[[0,4,0,[8,[]],3],[6,[[8,5,7],[4,8,2,5,6],7],3]]
[[[],[[3,2,3,1,5],[9,1],[2,4,3,9],10,[5]],6],[8,10,9,5,3],[5,1],[]]
[[[],[0]],[2]]
[[7,[[5,8,9,10,4],[8,9,1]]],[[4,3,[]],[[5,10],[7,7,3,6,6]],[7,5,[5,7,8,7],[7,3,1,7]]],[3,[[9,7,7,9,0],1],8],[0,8,[3,[0,8,0],[8],[1,5],[1,1,10,4,3]]],[[6,[5,2],[],4,2],3]]
[[[[],[],[1,7,7,8,4],10]],[3,[]],[[[],6,0,9],[]]]
[[[1,[6],[]]],[0,10,[4,[9,3],[5,10,3],9,10]],[[6,6,2,[2,2,7],[8,6,5,2,9]],10,[[4,2,5,0],[7,9],[2]]],[7,5,[]],[[],6]]
[[4,[[0,9,9,8,7],[3,1,0,4],[6]],9,[[9]],0],[[],[[0],3,[0,3,1,6,5],[0,6,10]]]]
[[0,[[9,4],[1,9,10,2],6,1],4,[]],[3,[[10,4,3]],5,[9,6,10]],[5,[3,2,[10,2,10,2]],10,1],[10,[5,2,[7,2,5,7,8]],[10,[8,0,3]],[6],[]],[6,0,5]]
[[9,8,4,[],[]],[6],[10],[[[4,10,8,1],4,[1,1,0,8],[]]],[]]
[[3,2],[4,8]]
[[[[3],10,0,[6,6,2,10],0],[4,[],[8,1,3,3],[10,4,10]]],[[],3,[0,[],[10,8,9,5,3],8,1]],[9,[]]]
[[4,7,[[8,10,6],[2,7,5],[8,10,3,9],[0,5,10],5]],[],[],[0],[0,4,9]]
[[],[9,3,[],[[]],5],[7,[[2,5,6,8,6],[],10,2,2],[1],[[],0,10,[7,7]],[9,0,9,7,[1,0]]],[4]]
[[[]],[[[5,2,4,0,4],0,[2,5,1,6]],9,7,[10],[7,[6,7,3,2],[10,6],4]],[3,10],[[[10,10,1,3,3]],[[10],1,4,[]],0,[4,9,[7,7,1,9],[]]],[8,[[]],[[3,10,8,9],[9,2,5],0]]]
[[7],[[[4,7,10,5,9],8]]]
[4,7,5,9]
[4,7,5,9,8]
[[[[7,0,9],[6],1,[4,4,6,1],6]]]
[[0,1,[7,[1,3,8,7,5],[],2,[1,7,9,7]]],[],[8],[4,[[0,3],2,6,[7,1]],[[7],[],6,4,9],1,0]]
[[[[],[9,8],4],[[9,6,3,4],8,9,[7,3]],4,[],[2,9,0,[5,4,2]]],[1,1,2]]
[[[[2,6,8,2,9],[3,9],6,[1,3,10,5,1],10],[[10,8,1],0,[1,9,8,10],3,6],7,[[0,2,1],4,9,[]]],[[7,[10,7,5,2,6]],9,3,4],[[[5,4,2,1],10,7,[8]],[10,[]],9,[0,[3,10]],3],[]]
[[1,4,[[2,8,4,2,2],4,[1,7,5],8,[6,6]],[[4,2,8,5],8,2,4],[]],[],[4,4,3],[[4,[1],[5,4,3],[10],[2,5,10,2]]],[2,10]]
[[7,7,[[1,3,10],2,10,4,[0,5]]],[]]
[[1,[[10,1,9],[7,3,3,10],6],[10,[2,9,3,0],3]]]
[[4,5,[[5,9,8],2,3,[8,3,10,1,0]]]]
[[0,10]]
[[7,[6],[]],[[],[[7,4,7,6],[],7,2],2],[[1,[1,5,5,0],[9,9,8,1],4,4],1,6,[],4]]
[[3,[[],[9],8],[4,[5,10,10,5],0,10,4],3,10],[[3,[6,5],8],0,9,8,[5]]]
[[6,8,[],[]],[[[]],[8,3,[7],9,[9,5,0]],[[3,6,8,6,10],[8],9,4],[3]]]
[[[4,[10,7,7,6],8,[2,1]],9,[5,[6,8,1,10,5],[7],4,[10,6,10]]],[[[8,8,8],5,10,7,[6,9,4,9]],[8]],[9,7,9,0,[[9,9,1,8],6,8,2,[4,1]]],[3,[4,[10,2,3,8]],8,[[5,6,8,6,10],5,2,[2,9],[5,6,3,4,4]],6],[10,[8,[7]],[]]]
[[[[6],[6],2,3,4],9],[[[7,3,1,5],[3,0,1,3]],[7,2],[8,3]],[3]]
[[[7,0,7],7,1,[[5,1,1,9,4],5,[3,5,7],7],0]]
[[[10,10,[5,2,2],[7,1,0,6,0],2],[[7,0,8,2],[],4,[2,4,4,2],5]]]
[[[5,3]]]
[[6,1],[[[7,0]],9,[[6],[],[8,10,7],3],[[1]],8],[6,10],[8,4,[[9,0],[6],10,[7,9,10,2,2],[7,9,2,8,6]],[[3,9,3,7,6],1],7]]
[[4,[],0,[[0],6,10,3],5],[[[1,1,10,10,2],[]],9,9,7],[[[4,1,5,5],5,[4]],[5],1,[4,8,1]]]
[[[],[3,10],[4,[8,3,2,6],5,5,3],[8]],[[5,2,9],[9]]]
[[4,[[3,4],3,2]]]
[[3,3]]
[[],[0],[9,1,0,6],[[[0,3],[],[6,3,5]],[6],5]]
[[[7,7,7],0,4,[5,8,[2],8,[5,5,4]],9],[[[4,3,1],[8,9]],[],[5,5,[10],[10,5]],[4,7,8]]]
[[7],[7,8],[5],[7,7],[9,3,[6,[],[8],1]]]
[[[1,[7,1,0,0,1],2,[3,6,1,6,5]],[]],[2,1,[5,10,[10,0,5,0],[6,5]],1,8]]
[[[[5,5,9,6,1]],9,9],[[3,8],[1,8],1,[]]]
[[5,[],[[2,0],5]],[[],9,[8,5]],[[[7,0]]],[]]
[[[],[],8,[2,4,[1],9]]]
[[[[3,2,0],[7,7,2,3,7],8,5],[[8],2,3],[8],[5,3,[4,7],[9,2,4,4,9],6],1],[[2],[6],[[0,7]],10,2]]
[[],[],[10]]
[[],[[[3,5,9,7,3],[],0,[0,4,2,7]],2,[],[[8],4,4,[],[9]],2]]
[[9,1]]
[[[5,[1,8,1,0,9],[7,4,1,3]],[[6],[3],7],[[],0,[8],[10,6,8,10]]],[2,7,4],[4,[[],8,5,[8,3,3]],[],4,[[9,9,4],2,[],5,8]],[[],8],[[[1,3,10],[2,7,8]],[],[9],10,4]]
[[],[[3]],[[[9,8,2]],0,6,2],[[[],0],6,9,8,5]]
[[3]]
[[10,[10,[2,7,3,7,7],[7,0,0],10,[8,2,7,0]]]]
[[[7,[7],8],2,5,[5,4]]]
[[9,3,[5],5,0]]
[[7,5]]
[[7],[]]
[[9,[[],0,9],[7,[8,0,0,7],0,[],4],[]]]
[[[[8,5,0],[3,3],[4],8],10,[5,[9,8,4,6],0,7],[[5,7,10],[10,10,6,3],5],5],[[],9,[8]],[],[]]
[[0,[[0,2,10,4],[7,3],6],9],[3,[0,[8,8,3,9,7]],[],[[4,9],6,[10,1,2,0],10,[]],[7,7,[9,8,1],1,2]]]
[[[0,5,[],[9,1,4],[4,5,8,8]],9,[[],4,[0,8,6],4,8]],[[[9],7,[],[2,0,5,1,5]],8,1],[5,2],[6]]
[[[]],[],[]]
[[[[5,9,2,3],1,0,0],7,5,[1,8,5]],[[0,4],[[0,0]],8,[[5,2],5,[5,6,8],2],3],[0,[[3],[0,0,2,0],1],[10,[6],[6,7,2,1],[1,1,1,2,7],8],[[3,1,8],9,9]]]
[[2,[8,0,7],8],[6,[],[5,[6],0,0,[7,2,7,2]],[]],[5,[[6,9,1,9],[0,9],[10]]],[[[3,7,5],[]]],[]]
[[1,[[8]]]]
[[[0,9,[5,8,4],[]],3,[0,8,[0,0,10],[0,8]],4,9],[1]]
[[[],[[8,4,6,7],5,8,7,1],3,[[5,10,3,4]],[9]],[[],8,8,[[7,9,8,6,0],1,4,[1,4],6]],[3,6,0],[8,6,[],[[7,5],[5,1],10,8,[]],[[5,2,4,3,7],[5,0,10],1]],[[]]]
[[],[],[6,4,[0,8,[]]],[[7,[7,0,7,4],10]]]
[[[[4,2,8],6],[[2,4,1],1,[0,4,7]]],[[],[],2,3]]
[[3,[[0,9],8,4,[3,4,7],6]],[0,7,[],2],[[[1,2,7,7],3,[5]]],[[],[1],[0],[[7,1,1],9,9,8,[]]]]
[[[4,0],9,[[7,5,10],9,[9,0],[7],8],[5]],[],[0,3,1],[9,10,2,0,[[4,5,3,1],[4,8,6,0]]]]
[[[8],9],[]]
[[0,[[0,9,8,8],3,6,[2,4,6]],7,5],[[6,[7,8],6],[],[],[10,7,[3,8,3]],[[5,9,5]]]]
[[[10,[0,8,6,10]],[[9,2,8,10],3]]]
[[2,[[2,5,2],8]],[[],8,0,7,5],[4,2,6,5],[[0,4],[[0,3,0],[1,5,1],1]]]
[[[[8],[2,5],5,[3,10]]],[]]
[[[[5,1,4],10],[2],4,[7]],[[[],[4,5],2,1],8,7,[7,[0,9,6,7,9],9,4],[3,5,5,[6,10,2,4],10]]]
[[[0,6,6,[3]],10,[5,10]],[],[[6,1],4],[[4,[2,6,5],[],[0],[7,1,10,9,3]],[[5,0],[1,7,3],[6,5,9,8],[0,4,8,1,1]],[],[]],[[[7,8,1,3],8,9],4,[1,[1,1,0,0],8]]]
[[],[[[8,9,5,8],[6,4],1,[4,8,9,2],6]],[[4,6,[5],[0,8,6,9,6],[7,8,8]],[3,5,[0],7,8]]]
[[[0,[3,1,8,1],[5],[10,6]],10,0]]
[[1],[[4,[6,4]],1,6]]
[[[5,3]],[[9,6,2,[3,6,8,6,0]],0],[[[2],[10,4,9,10,4],[2,9,6,1],9,10],[6]],[8,4,[[],[2,0,0,6],[1],[3,4,8],4]],[[],[[6,10],[3,10,5]],[6,0,10,8,6],6]]
[[[7],[4,[3,9]],[1],6,[[9,0],6,[2,7],10,[2,5]]],[7],[7]]
[[[5,6,[3,4,5]],[[7,4,1],10,9,[4,8],[7,5,5,10]],[4,4,[1,0,1,5,1]],5,2],[[6,1,[2,3,7,4],7]]]
[[[6,[0,9,1],[7,8],[6,2,2,1]],[[4,1]],[3,6]],[]]
[[6,[[3,9],7,3],2,10,[7,3,[6],[],[0,4,9,10,1]]],[3],[[[10],4,[6,7,1,0,0],0],1,[[6,0,5,4,0],6,[1,3,6,4]],0],[[[0,5],[5,5,7,9],[0,2,2]]]]
[[[[],10,7,[0]],[4,2,[],[1,1,5],5],3,6,5],[],[[2,9,[8]],6,[1,[1,9,0,2]]],[]]
[[[3],0,0,[[1,5],5,[8,4,1,5],5,10],[[1,10],7,9,[4,8,7,2],[]]],[],[],[],[]]
[[]]
[[[7,8,[10,7,9,2],[4,2,9,1],[10]],2,3],[[]],[[[3,1,9,1,10],10,5,[],4],[[5,8,2,6,3]],1,[],0],[4,[6,2,[8,9,8,1]],1],[6,[],8]]
[[10,8,9],[[4,4,[6,10,3],[6,3,9,9,3]],[7,5]],[8,9,[[],2,1,9,[8,0,7,2,6]],[1,[1]]]]
[[5,[9],[],0,3],[[],7,0],[[6]]]
[[5],[9,3,10,4,[7,5,[],[]]],[[9,9,2,10,[10,2,6,4]],[],[]],[[],2],[[6]]]
[[1,[[8,0],6],8,0]]
[[6,0,[]]]
[[10,[6,2,8,[4],3],[[],5,[2,10,0,1,2],[0],[9,0,7,2]],[[6,6,0,0],1,5,3],[[6,2,3,8],6,2,7]],[8,6,[5,1,10,[10,7],3],[],8]]
[[4],[7,2],[[[9,10,1],7],[],[[3],[5,4],7],[[3,10,2]],[3,[5,4,4,5,9]]],[5,[1,10]],[5]]
[[[[4,9,5],8,[4]],[1],10,[2,[6,7,7,3],8,9],5],[4,0,6],[2]]
[[[2],[[]]],[[6,[9],6],4,0,[1,3,[0,6,6],8,[1,4,9]],[[4,0,9],[0]]],[1,4,[1,[7,8,6,6]],1,1],[3,2,9]]
[[5,[3,[],[8,0,3],4],4,7,0],[[]]]
[[[[9,2,2],0,7],[[],[],[6,2,4,0,0],[2,6,2,6],8],0],[]]
[[[8,[6,9,0,8],5,[1,1,3,3,1]],[8,[],[3,8,9,0],[]]],[[7,[7,7,3,1]],5,4,0,3]]
[[[[8,0],[4,2,1],[5,1,2,1],5,[5,0,10,1,8]],[7,4,[7,2,7]]],[8,6,[[8],[9,4,6],[6,7,4,7]],[[3],[3,5],[4,4,9],10,[2,1,8]],1],[[2,[9,5,6,7,9],7,5,[]],[[5,3,1,0],[7],8,[1,9,7],[]]]]
[[1,2,[[9,3],10,6],6],[[],[1,7],[5,[10,5,10],[0,5,3],8],3]]
[[[[2,5,0],[9,0,8,8,7],10],3,9],[[[0,0,5]],[],[],[],[[3,1,8,0]]],[[[8],5],[[1,3,8,7],[0],1],1,[3,[4]],[9,5,[7,3,2,8],6]],[6,2,[[1,8],[],[0,6,7]]],[[],3,2]]
[[[[2,6,2,3,10],[]],8,7],[[[9,5,9],[0,4,4]],[[]],[[],7,10,[1,5],[7,10]],10,3],[[[10,2,0,1,6],4],1,2,10],[]]
[[7,1,[[6,1,0,2,7],[3,9,3],9,[],[7,4]],[[]],4],[[[5,5,8,2],[10],[3,6,5,10,3]],[[],[1],[]],7,[[6,3,4],[3,2,9,4,7]]],[8,[4,[5,8]],7,0,4]]
[[5,[4,[8,7,7,3],[9,7,9,10]],[[4,4,5,10,0]],[[7,3],[4,3,6,1]],3],[10,2,1,[[9,7,4,9,8],[],[],8]]]
[[[[0,3],5,9,[4,3,7,3,5],9],6,[],[10,1,[8,1,8,8,3]]],[1,8,0],[2,[[]]]]
[[3],[4,10,0,[1,2,9,8,7],2],[[5,[7,8,3,9]]]]
[[5,6,[[0,2],[5,10,1,9,6],10,10,[2,7,9,1,1]],4],[],[[],[2,7],1]]
[[0],[[0,[4,4,4,2],[8,3,4,10,9]],8]]
[[10,[[],[8,7]]],[[[2,10,3,8,6],7,6],1,[3,2,[6,5,6,3,7],10],3,[3,[],6,[6,2,8,8,2]]],[],[[8,[3]]],[5]]
[[[]],[],[[],[],5,[[5,4,7,1],8,8,1,0]],[6,[[8],6,6,[3,3,5,8,3]],7],[[3],10]]
[[1,[[5,2,1]]],[[[10,0,3,7,3],[10,2,9,5],[0],8],8,[[4,4,8],[6,10,0],[0,10,10],[10,2,8],[10,4,2]],[2]]]
[[8,[]],[[1,[7,5,7,10,4],4,[10,6,10,5]],1,7,0,[[10,10,0,7],10,0]],[10]]
[[1],[],[[[1,1,10,9,4]],[],4,2],[4]]
[[[],[[],3,[9,8,2],[9]],[0,[1,2]],2,9],[],[],[9],[[[3,2,5,3]],[10,[10,2]]]]
[[[],[2,[7,9],[5,9,4]],[[1,1,10,4],6,10,[7,3,3,6,9]]],[[[10,0,3,2]],5,[3,1,10,[3,1,7,3,1],10]],[1,[[0,5,4,3,9],0,5,6,[8,1,2,0,0]],6,4,[2,[6,2,6,4]]]]
[[9,[1,[2,9,3,1]],[1,6,7],[7,[9,2,6,0,5],8],4],[8,8,10]]
[[[]]]
[[1,[[3],8,[9,7,7,8,0],[7,10,4,9,0],[]]],[0,[[1],5,6,[1,3]],[[8],[2,9,1,3,4],[9,8,3]],2,8],[],[4,2],[2,[[7],[1,5],[]],6]]
[[9,[9],0,[6,[1,10,8,8,6],[],6,2]],[[[2,1,9],6,[]]],[[],[[2,3,5,8],[2,9,5,7,7],7],[],[8,[7,3,3],[8],3]],[7,[[5,9,5],4]]]
[[[6,[10,7,6],[10,3,6,3],[]],[]]]
[[5,2,8],[[],[[1,10,6,1],1],[2,[8,0,4,10,7],[10],8]],[[[10,1],[6],[2,5,4,8]],[3,5,4,[],1]]]
[[[],[[],5,[0],5,2],2,10,7],[7,9,[[2,6,8,1],[],6],[],[[0,0,3,10],1,[9,8],7,[]]],[[[3,7],[8],[3],4,[2,9,2,4]],[[8,2,6,2,10],[10,8,3],[5,5,7,7],[6]],[],8],[],[]]
[[],[],[6,9,[[10,2],[],6],[[9,10,7]],[[4,5],3]],[[7],9,[[],3,4,[5,2,1],[]],[[10],6,9,[4],[10,1,9,3,6]],[[]]]]
[[[10,2],[[7,5,4,9,4],10,[7],7,8]]]
[[4,[9,[],5,7],4,2],[6],[9,8,[2,3]],[]]
[[],[[5],4,9,[],[7,2,0,[7,2,1,9,6],0]],[10,3,[[],[],5,0]]]
[[[[1,0,2],[10]]]]
[[],[],[4]]
[[7],[[9],[0,[],2]]]
[[[],2],[7,4,3],[]]
[[2],[[[5,10,3,3],5,10,[10,8,6,8,9],5]]]
[[9],[5,[8,[6,4,4,10],8,1]],[9,[8,[4,5,0,5],10,6],[7],9,4],[],[4,[0,10,5]]]
[[[0,[10,0],[6,10]],[],9,[]],[8,[2,[1,9,7],0],4,4]]
[[],[],[[[0,5,5,6]],[8,[3,7,7],3,[4,2,0,3,0],[]],[],[[7,0,8,0],10,3,[2,2,7,1,4],5],[2,[10],1,[8,4,7]]],[8]]
[[[],5]]
[[2,7,[9,[8,4,4,10,0],4,7],[[0,7,5,1],3,[7],[2],8],[[10,4,0,7],8,4,4]],[8,[],[2,[]],[]],[1,8,5,1]]
[[[[3]],10],[6,9,[9,[],6],[[9,3,8],[3,3,2,10,2],2,[7,0]]]]
[[[[8,0,8,6],[],[3,2]]],[[[5],1,4,[3,6,3]],3,1,[3,9,[6,2,3],5]],[],[[],0],[[],[[10,4,1]]]]
[[[1,10,[1,7,3,4]],[[8,4],[],[7],[0,2,3,6],5],[8],0],[],[[[],[4]]]]
[[8,[],[[9,3]],4],[6]]
[[1,8,10,[],[]],[9,1,[[3,5,7],5,[6,4,5,3],1]],[[],[10,[7,6,0,3],[8,0],[7,7,4,4,0]]],[10,4],[[[0,3],2,5,0,[9,4]],6]]
[[[9,[5],1,[3,7,10]],1,0,[1,0,4]],[10,[[],[],[6,4,8,2,10]],[7,2,1],6,5]]
[[[],[[4,3,7,9,5]],2,[],[9,5,4,[0,0,5,4,7]]],[[[],[3,9]],10,1,[10,[],9,6,[2,10,10,3]]]]
[[9,8,[4,[6,1,6,6,3],[3,9],9,[5,0,0]],[]],[[[2,4,8,7,1],5,5,1,9],[[],6],[[4,7,7,7,9],6,[10],7],[[],4,9,[3,10,7]],9]]
[[10,[[1]],2,[]]]
[[3,10,[8],1,[[9],3,[7,5,6,2,9],8]],[[],7,1,0,[]],[[4,[3,7,9,7,4]],2,[[5,1,10],[3],6],9,5]]
[[],[1],[],[6,[3,1,6],[[6,6,5],6,[],8,9]],[[7,8,[10],4]]]
[[[[8,2,8]],3,2,[],6],[7,5,[2,6]],[[[5,1,4],[8,5,5,0],4,[6,9],8],[[8,9]],[[8,4,9],3,9,7],7],[6]]
[[],[8,[[9,0],[5],[1]],2,6,[5,6,[8,9,6,7,9],[9,1],7]]]
[[6,5,9],[]]
[[2,10,[9,[3,2,9,4,8],[7],[9,4,6,5,0]]],[[[1]],[4],[5,[9]],1]]
[[7,10],[7,[8,[7,1,9,8],3,[1],[6,7,9]],2]]
[[[[8,1,2,5,9],[],6,[]],[[3,1,8]],[],0],[[0],6,[[2,6],[8],[],3]],[3,[[3],7,[8],[],4],[[7,9,7],[],[7,10,3,2],[2,3],[1,9,9]]],[[0,10,10],3,[],0]]
[[7],[[1,[],7,4,4],[[2,5],[6]]],[[[2,5,7,5],4],10,10,[2,[1]]],[[[9,7,10,0,0],10,[10,8]]]]
[[[5,9,[5,5,1,6,5]]]]
[[5],[6,5]]
[[[],3]]
[[[10,[5,0,2,5],[7,5,10,4,0],10],[],[[6,7],[]],3],[[4,[6],7],2,6,1],[],[]]
[[[7,[6]],[[8,10],0,[3],1,3]],[[[3,2,6,8,3],[2,6,0,5,3],[1,3,8]]],[10,3,0],[5,[1,[4,6],[],3,[7,7]],0,[5,[1,6,0]],[[],10]],[[[0,7,9,9],6,2],3]]
[[[9,5,10,5],[2]],[],[]]
[[],[9,[[8],[0],[6,10,7,4]]]]
[[[[8,4],[3,5,5,4,1],[4],9],[6,2],9,10,[[1]]],[[[6,2,3],[1,1,6,0]],[],9,[[0,6],[10]],1],[[],[8,[3],[0,8,6,10],[0,5,5,8],[]],8,7,3],[[[6],6,5,1]]]
[[4,[1,[7]],7,[3]],[8,[6,[]],[[6],8,[1,3]],[[6,10,5,3,4],7,[],[4,10,2]],[5,1,6,2]],[[[2,4],8,4],[[2,2]],[[4,6,10,8,6],[3,2,6,6,8],0],[[7,6,0,8],2],7]]
[[[2,5,1,2]],[10,[4,[4,10,6,8]],2,[[7,0],[10,2,8,8],5],5],[[[10],[6,8,5],9,9],[[5,2,1],[10,7,9,1,2]]]]
[[8,[[0],[7,2,9,10]],[[2],1,7,[10,9,7,9]]],[[[],4,[]]]]
[[[[0,6,8,3,6],7,2,[8,0,3,9],1],6,5,[4,[1,9],3,[]]]]
[[9,8,[4],6],[8,4,7],[[[9,1,9,5,6],10,0]]]
[[[[],4,[5,9,7,7,9],[]],[[10,3,6,3],0,10,[7,2,2,5,3],[8,6,1,9]]],[],[3,5]]
[[[[9,8,2,7],3,[8,10]],5,0,[5,8,5],[8,[5,4]]]]
[[[[5]],1,6,[5,3,[8,2,3,0,5],8,2]],[]]
[[[5,[2,8,6,5],[10,9,10],[]],[3,[4,9,5,3],[],5],4],[2,1],[[0,6,9,[1,2]]]]
[[[1],4,[[2,5,6,0]]],[4],[6,[[1,3,7,9,9],3],4,0],[[10,9,1],[[9,8,1],[],[9,8,8,9]],[6,7,5,[]]],[[[6,2,4],2,[2,3,2,1,10],3],0]]
[[],[9,[[8,0,0,5,5],3,[0,6,8,9],[7,4,1,2],[]]],[[9,[2,2,10,3,10],6]],[10,[6,[9,8,2],[4,6,6,2],4,[9]],[4]],[]]
[[[[5,9,8,10,10]]],[[]],[[[6],[2,10,6],6,[6],6],10,[6,6,[]],[5]],[[[8,8,7,1,7]],[4,[5,7],[7,5,5],8],4,[3,[10,6,9],[0,2,0,1,9],8]]]
[[],[[[9,2,5,5,8]]],[7,[[]],[3,1,[10],3]],[[[7,2,0,2],10,8,10],4,[7,[7,6,6,10,3],0,1,1],0],[3,7,[6,1,6,[0,10,0,0,4]]]]
[[2,1,2,2],[[[1]],2,[[]]],[[[4,4,6,10],[8,10,10,7,10],[1],6],[1,2,[5]],3],[[[5,8]],[[9],10],10,8,[[4,4,9,4]]],[]]
[[[],3,[0,[],[7,10,8,7]],[2,6,[6,10],[6,10,4],3],[[10],[1,2],1]],[[[8,0],[10,5,7,8,0],[8,3,3,9,5],0,[5]],[8],4,5],[],[[[2,6],0,[3,8,10,8,6]],3,[]]]
[[],[[],[[7,0,3],[],[10,5,10,4,9],[3],[7,1,0,8,3]],[4,9],[1,8,[1,0,9,1,3],[5,0,5]]],[[]],[[],[]]]
[[0,[4,8,6,2],[[6,2,8,9],7],6],[[2,[],[8,2,3],[10]],10,9,4],[],[]]
[[[[9],7],[10,3,9,[3,1,0,9,7]],[[5],[0,4,10],[3],6,7],6]]
[[7]]
[[9,8,5,[9,[4,7,6,8,10]]],[7,6,5,[3]],[[[6,10,7,1,9],[],0,[]],[[3,1],8,6],[7],7,7]]
[[[[10,3,8,0],5,[10],10,[10,6,6,3]]]]
[[[[4,5,5,3],0,6,[7,7],[2,10,9,1,4]],7],[],[[[6],[3,2,1],4]],[[[7],[0,8,4,7,6],6,0],[5,0,2,[6,4,0,2],4]],[[[6,3],5,4,8,2]]]
[[[2,[1,1],[2,10,8,10,9],1],[8],[6,[],3,[9,0,3]]],[8,[[10,8,5,4],0],[]],[[[8,0,0,9,9],[8,4,9,6,2],[1,8,1]],[]],[],[[[],[2,1,0,4]]]]
[[5,4,8],[4],[[5,[3,9,3,0,3]],4,[[],10,[8,1,4]],8,[[9,8],[10,2,1],[4],0,[5,7]]]]
[[7,[],5,10],[[5],4],[[7,[3,10,2,9,7],[7,3,6,6],6],[[0,7,10,1],[],[7,9],9,3]]]
[[[[0,9,10],5,[]],[],[4]],[[],[5,[1]],9],[9]]
[[8,[8],7,6]]
[[[[1,0,7,7],6,6],3]]
[[[[5,10,9,2]],5,1,[5,[7,9,10,3,7]],[[4,10,3,4]]],[],[4,1,[[1,8,8],7,[8,3],[4,10,9]],[[6,7,1,7,1],7]],[[[7,1,1,2],2],[],[6,5,[9,8,10,9,1]],[[2]],3]]
[[[[],[7],[],1,[1,6]],[7,7,[2]],10,[6],[6,7]],[8],[[0,[0,1,0]]],[[[],[8],7,[],10]]]
[[],[4,[4,7,[]]],[]]
[[],[7,[9,[],7],[9,9],[10],0],[8,[6,[],4],[[8,3,8,9],0],6],[1,[[4,3],[10,6,7,10,6],4,0]]]
[[[[5,0,4,5],[7,7,2,6]],[],10],[[[]],8,[[9,5,6],[],[9,5],5],5],[6,4]]
[[[],[4,[8],0,[5,7,8]],[6,9,[8,7,10],2],8],[]]
[[9,6,5,4,[[4],[5,0,7,0,0]]],[[10,[3,1,5,2],6,[]],9,[[8]],[[7,8]]],[],[[8,[0,6,4,6],[9],[7],6],[5,7,8,[0,2,3],4]]]
[[[],3],[4,3,3,[4,10,[7,10]]]]
[[[0,1]]]
[[],[[10,4,[],0],2,4,[3,[10,6,8,5],2]],[1,7,4,[],[[1,7],10,1,10]],[[[7,9],9,[],7,[2,10,6,7]],2],[[[2]],4,6,1]]
[[],[[],2,[1,4,10,2,[1]],[4,5,10],2],[6,4,6,3]]
[[],[7,[2,6],[[6,6,9,5]],5,10]]
[[8,[6,[10],3,10,10],[]]]
[[0,9],[7,[[5],10,[1,9,10,0,3],3],[[8,2],8,2],[[2,2],9,9,2,[1,7,4]],4],[[[2,7,2],1,2],6],[[8,10],[3,2,5,[3,0],[0]]]]
[[7,[10,10,[2,8,8,1],10,9]],[1,[[4,0,3],1,0,[2,4],0]],[[[],[7,3,10],[10,9,6,5],[0,2,3]],2,[10,6,3],4,[[1,8,4,5],[],[3,10],[9,2,7]]],[5,3]]
[[1,3,0],[4,9,1],[]]
[[9,7,9,[[2,4,9,5,10],9],1],[7],[[],0,[[5,10,10]],0],[5,[0,[],10],[2,[6,6,2,6],6,[4,9,2,1]],[[],3,9,[5]]],[[7,[0,0],8,[7,5,4,8,0]],3,0,1,[[7,2],1]]]
[[[[3],9,[0,5,5,0,2]],[],9,[1,[6,4,6,0],[10,8,6,4],10,7]],[[[5,10,9,1],[],10,[],[8,2,3,4]],6],[],[1,[],[[10,8,4],[3],4,9,[]],[6]],[]]
[[9,[5,[6,8,3,1,9]],5],[[[10,1,1,5,7],2,1,10,4],7],[],[[[0,6,10,7,9]],9,[],[8,[9],9],[[7,2,9,5,9],[],8,8,[4,4,0]]]]
[[5,[1,[],[5]],[[1,1,0,6,5],[5,0,2,1,5],[],3,3],9],[10,[7,[7,6,2],[2,6,5,9],[4,0]],7]]
[[[9,[3,6,6,8,5],0,[]],[],7,[[5,9,1,4,4]]]]
[[1,6],[5,8,8,[[10,10,10],8,[6,1,8,9,2],[2,4,4],[10]]],[[],[],0]]
[[0,0,6],[2,8],[7,[[5,8,2,7,8],7,[9,2,6]],[[6,2,1,7,7],10,6,[8]]],[]]
[[[2,10,5,[],[6]]],[[],4,[5],3,3]]
[[9,4],[]]
[[[3,[]],7,10,[[5,3],[8,7],2,9],7],[],[[3,[9,8,8],8],7,[[7],0]],[[],[[3,2,0]],[[5,8]],10,[[],[9,0,0]]],[8,[],4,4,[[4,7],3,[2,9,10,1],[2,1,6]]]]
[[[2,[0,4]],5,2],[[1,8],[[1,7],[8,2,5,1,2],[1],[],3]],[]]
[[[[5,0,0,0,1],5],[4,[9,5,10,0],[9,9,6,3],[]],[[5,1,5,8,0],[10],[5,9,6],7],[[],9,[0,8,8,1,2]],8],[],[6,[[1,4],1,7,[7,3,0]],9],[],[]]
[[3,[2,[9,8],5],8],[[],4,3],[[[]],3,[]],[0,[[],6],[[8]],[1,[9],1,9,1],[5,[6,6],0]],[[]]]
[[0],[[[8],[6,2,1,4,10]]],[2]]
[[9],[[]],[9,9,5,[5]]]
[[9,[[6,6],9]],[[],0,2,[[4,2],[5,3,0,3,7],0],[[5,7,3]]],[[1,5,[0,8,3,0],[],[7,4]]],[7,6,[[5,0],0]],[]]
[[[[0,7,5,5,3],3,3,[10,9,2,10]],2],[[[0,3,8,7,1],[]]],[],[10,9]]
[[[3,[2,5,3,10],[10,0,2]],1],[7,[[6,5,10,5],5,[7,8]],[[],[6,7,7],[],[0,6,8,9,8],[7,9]],8],[],[[5,[0,1,3],1,[10,0,7]],2],[[[2,1],[10],3]]]
[[[0,3,5,[],6],[[5,5,0,7,2],[9,6,7],2],1]]
[]
[[3,2,[[0],[3,10,7],[8,9],10,[5,4]],[8,8,[4,2,9,4]],[[2,1,5],0,0,6]],[[[4]],[]],[]]
[[],[2],[[9,[2,3,2,5],6,[10,2,10,10]],9,[]],[[7,5,[],1,8],[3,[],3,[7,1,3,3]],[1,[],7],[5,4]]]
[[1,[9,4]],[0,9],[4,[[],[9,0],4,2,[1]]],[[],[4,[9,1,0,9],[1,9,5],3,[]],[[9,0,8],4,3],[7,5,4,6]],[[],[10,[0,1],[]],[1,[],[],1],[[9],2,0],5]]
[[6,[7]],[[[]]],[9,[2,[3,1,9,5]]],[8,[[2,4,10]],[9,1,[3,0,6,7,10],2,4],[]],[3]]
[[[6,10,[]],0,[7],6,2],[9,[10,[5,4,6,5],[0],0],2,6]]
[[[[],[10,0],[2,1,7],[]],[8,1,10]],[],[4,[0,[0,9,4,3],[4,10],[8,2,5,4,1]],2]]
[[[[7,5,8,9],6],[8,6,[10,7,9,5,2],[10,1,8]],3,10,8],[[[4,9,10,3,9],8],[[10,0,10,1],3,[8,0,4],[7,10,1,8],[9,9]],[3]],[[10,[10,2,6],1],[[8],[9,6,9,4],[2,9]],0]]
[[],[7,[[3,0,3,7,3],[6,6,10,8,5],[],10],0,10,[[],3,[],5,[5,5,5,0]]],[[[0,8,6,7],[0,4,5,5,9]],[4,2],[[10,1,1,1,0],4,[],[3,6],[0,9]],0],[[8,2,2,6],[[1,9],9,[4]],6]]
[[1,[[7,10]],10,6]]
[[],[7],[5,7,10,[0,[9],[2],[4],6]],[9,3,6],[]]
[[[2,[0,1,6,5],4,8]]]
[[[[3],4]]]

View File

@@ -1,151 +0,0 @@
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
481,92 -> 481,96 -> 476,96 -> 476,99 -> 487,99 -> 487,96 -> 485,96 -> 485,92
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
470,76 -> 470,80 -> 466,80 -> 466,84 -> 481,84 -> 481,80 -> 474,80 -> 474,76
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
495,155 -> 499,155
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
500,138 -> 505,138
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
481,92 -> 481,96 -> 476,96 -> 476,99 -> 487,99 -> 487,96 -> 485,96 -> 485,92
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
489,115 -> 489,119 -> 481,119 -> 481,126 -> 494,126 -> 494,119 -> 493,119 -> 493,115
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
485,112 -> 485,102 -> 485,112 -> 487,112 -> 487,111 -> 487,112 -> 489,112 -> 489,105 -> 489,112
481,92 -> 481,96 -> 476,96 -> 476,99 -> 487,99 -> 487,96 -> 485,96 -> 485,92
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
470,49 -> 470,53 -> 468,53 -> 468,60 -> 477,60 -> 477,53 -> 476,53 -> 476,49
483,160 -> 487,160
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
491,131 -> 502,131 -> 502,130
475,88 -> 475,89 -> 483,89 -> 483,88
483,164 -> 487,164
498,147 -> 503,147
505,147 -> 510,147
485,112 -> 485,102 -> 485,112 -> 487,112 -> 487,111 -> 487,112 -> 489,112 -> 489,105 -> 489,112
516,150 -> 521,150
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
496,13 -> 501,13
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
512,147 -> 517,147
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
497,141 -> 502,141
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
480,162 -> 484,162
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
485,112 -> 485,102 -> 485,112 -> 487,112 -> 487,111 -> 487,112 -> 489,112 -> 489,105 -> 489,112
489,155 -> 493,155
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
498,157 -> 502,157
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
491,147 -> 496,147
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
489,115 -> 489,119 -> 481,119 -> 481,126 -> 494,126 -> 494,119 -> 493,119 -> 493,115
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
470,76 -> 470,80 -> 466,80 -> 466,84 -> 481,84 -> 481,80 -> 474,80 -> 474,76
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
475,88 -> 475,89 -> 483,89 -> 483,88
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
486,162 -> 490,162
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
508,144 -> 513,144
481,92 -> 481,96 -> 476,96 -> 476,99 -> 487,99 -> 487,96 -> 485,96 -> 485,92
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
470,49 -> 470,53 -> 468,53 -> 468,60 -> 477,60 -> 477,53 -> 476,53 -> 476,49
477,164 -> 481,164
485,112 -> 485,102 -> 485,112 -> 487,112 -> 487,111 -> 487,112 -> 489,112 -> 489,105 -> 489,112
504,141 -> 509,141
489,164 -> 493,164
480,42 -> 485,42
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
470,49 -> 470,53 -> 468,53 -> 468,60 -> 477,60 -> 477,53 -> 476,53 -> 476,49
485,112 -> 485,102 -> 485,112 -> 487,112 -> 487,111 -> 487,112 -> 489,112 -> 489,105 -> 489,112
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
489,115 -> 489,119 -> 481,119 -> 481,126 -> 494,126 -> 494,119 -> 493,119 -> 493,115
486,157 -> 490,157
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
470,76 -> 470,80 -> 466,80 -> 466,84 -> 481,84 -> 481,80 -> 474,80 -> 474,76
485,112 -> 485,102 -> 485,112 -> 487,112 -> 487,111 -> 487,112 -> 489,112 -> 489,105 -> 489,112
501,144 -> 506,144
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
485,112 -> 485,102 -> 485,112 -> 487,112 -> 487,111 -> 487,112 -> 489,112 -> 489,105 -> 489,112
470,76 -> 470,80 -> 466,80 -> 466,84 -> 481,84 -> 481,80 -> 474,80 -> 474,76
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
492,166 -> 496,166
509,150 -> 514,150
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
480,134 -> 480,135 -> 500,135 -> 500,134
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
486,166 -> 490,166
494,144 -> 499,144
481,92 -> 481,96 -> 476,96 -> 476,99 -> 487,99 -> 487,96 -> 485,96 -> 485,92
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
480,134 -> 480,135 -> 500,135 -> 500,134
481,46 -> 486,46
477,44 -> 482,44
470,49 -> 470,53 -> 468,53 -> 468,60 -> 477,60 -> 477,53 -> 476,53 -> 476,49
491,131 -> 502,131 -> 502,130
492,157 -> 496,157
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
488,150 -> 493,150
481,92 -> 481,96 -> 476,96 -> 476,99 -> 487,99 -> 487,96 -> 485,96 -> 485,92
474,46 -> 479,46
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
489,115 -> 489,119 -> 481,119 -> 481,126 -> 494,126 -> 494,119 -> 493,119 -> 493,115
460,73 -> 460,70 -> 460,73 -> 462,73 -> 462,69 -> 462,73 -> 464,73 -> 464,65 -> 464,73 -> 466,73 -> 466,65 -> 466,73 -> 468,73 -> 468,64 -> 468,73 -> 470,73 -> 470,68 -> 470,73 -> 472,73 -> 472,68 -> 472,73
489,115 -> 489,119 -> 481,119 -> 481,126 -> 494,126 -> 494,119 -> 493,119 -> 493,115
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
470,76 -> 470,80 -> 466,80 -> 466,84 -> 481,84 -> 481,80 -> 474,80 -> 474,76
488,46 -> 493,46
495,150 -> 500,150
474,166 -> 478,166
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
484,44 -> 489,44
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
484,39 -> 484,38 -> 484,39 -> 486,39 -> 486,33 -> 486,39 -> 488,39 -> 488,30 -> 488,39 -> 490,39 -> 490,35 -> 490,39 -> 492,39 -> 492,38 -> 492,39 -> 494,39 -> 494,30 -> 494,39 -> 496,39 -> 496,36 -> 496,39
489,115 -> 489,119 -> 481,119 -> 481,126 -> 494,126 -> 494,119 -> 493,119 -> 493,115
481,92 -> 481,96 -> 476,96 -> 476,99 -> 487,99 -> 487,96 -> 485,96 -> 485,92
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
489,115 -> 489,119 -> 481,119 -> 481,126 -> 494,126 -> 494,119 -> 493,119 -> 493,115
492,153 -> 496,153
502,150 -> 507,150
470,49 -> 470,53 -> 468,53 -> 468,60 -> 477,60 -> 477,53 -> 476,53 -> 476,49
475,88 -> 475,89 -> 483,89 -> 483,88
480,134 -> 480,135 -> 500,135 -> 500,134
470,76 -> 470,80 -> 466,80 -> 466,84 -> 481,84 -> 481,80 -> 474,80 -> 474,76
492,26 -> 492,17 -> 492,26 -> 494,26 -> 494,16 -> 494,26 -> 496,26 -> 496,22 -> 496,26 -> 498,26 -> 498,17 -> 498,26 -> 500,26 -> 500,20 -> 500,26 -> 502,26 -> 502,25 -> 502,26 -> 504,26 -> 504,23 -> 504,26 -> 506,26 -> 506,21 -> 506,26 -> 508,26 -> 508,16 -> 508,26 -> 510,26 -> 510,24 -> 510,26
480,166 -> 484,166
470,49 -> 470,53 -> 468,53 -> 468,60 -> 477,60 -> 477,53 -> 476,53 -> 476,49
470,76 -> 470,80 -> 466,80 -> 466,84 -> 481,84 -> 481,80 -> 474,80 -> 474,76
485,112 -> 485,102 -> 485,112 -> 487,112 -> 487,111 -> 487,112 -> 489,112 -> 489,105 -> 489,112
470,49 -> 470,53 -> 468,53 -> 468,60 -> 477,60 -> 477,53 -> 476,53 -> 476,49

View File

@@ -1,23 +0,0 @@
Sensor at x=3289936, y=2240812: closest beacon is at x=3232809, y=2000000
Sensor at x=30408, y=622853: closest beacon is at x=-669401, y=844810
Sensor at x=3983196, y=3966332: closest beacon is at x=3232807, y=4625568
Sensor at x=929672, y=476353: closest beacon is at x=-669401, y=844810
Sensor at x=1485689, y=3597734: closest beacon is at x=1951675, y=3073734
Sensor at x=69493, y=1886070: closest beacon is at x=-669401, y=844810
Sensor at x=2146060, y=3999371: closest beacon is at x=2300657, y=4128792
Sensor at x=3228558, y=3890086: closest beacon is at x=3232807, y=4625568
Sensor at x=3031444, y=2295853: closest beacon is at x=2928827, y=2611422
Sensor at x=374444, y=3977240: closest beacon is at x=-888612, y=4039783
Sensor at x=1207660, y=2710720: closest beacon is at x=1951675, y=3073734
Sensor at x=3851310, y=61626: closest beacon is at x=4807592, y=976495
Sensor at x=3195193, y=3022787: closest beacon is at x=2928827, y=2611422
Sensor at x=1784895, y=2111901: closest beacon is at x=1951675, y=3073734
Sensor at x=2894075, y=2427030: closest beacon is at x=2928827, y=2611422
Sensor at x=3301867, y=803327: closest beacon is at x=3232809, y=2000000
Sensor at x=2506616, y=3673347: closest beacon is at x=2300657, y=4128792
Sensor at x=2628426, y=3054377: closest beacon is at x=1951675, y=3073734
Sensor at x=2521975, y=1407505: closest beacon is at x=3232809, y=2000000
Sensor at x=2825447, y=2045173: closest beacon is at x=3232809, y=2000000
Sensor at x=2261212, y=2535886: closest beacon is at x=2928827, y=2611422
Sensor at x=3956000, y=1616443: closest beacon is at x=3232809, y=2000000
Sensor at x=3870784, y=2872668: closest beacon is at x=2928827, y=2611422

View File

@@ -1,60 +0,0 @@
Valve QP has flow rate=0; tunnels lead to valves IS, DG
Valve MC has flow rate=0; tunnels lead to valves XX, QQ
Valve OT has flow rate=7; tunnels lead to valves OE, BL, DJ, JS, LS
Valve CZ has flow rate=0; tunnels lead to valves IC, ZL
Valve GI has flow rate=0; tunnels lead to valves OM, GF
Valve YB has flow rate=0; tunnels lead to valves DQ, MX
Valve EJ has flow rate=0; tunnels lead to valves GB, ES
Valve IS has flow rate=19; tunnels lead to valves AS, OB, QP
Valve WI has flow rate=21; tunnels lead to valves SS, AK
Valve JS has flow rate=0; tunnels lead to valves OT, HV
Valve UR has flow rate=0; tunnels lead to valves OM, ZI
Valve UC has flow rate=0; tunnels lead to valves QX, NG
Valve BL has flow rate=0; tunnels lead to valves YW, OT
Valve AK has flow rate=0; tunnels lead to valves WI, AL
Valve QQ has flow rate=16; tunnels lead to valves MC, WH, MS, IY
Valve PW has flow rate=0; tunnels lead to valves ZL, EK
Valve AS has flow rate=0; tunnels lead to valves IS, MS
Valve ZL has flow rate=9; tunnels lead to valves CD, QX, PW, CZ, PQ
Valve OB has flow rate=0; tunnels lead to valves HS, IS
Valve OE has flow rate=0; tunnels lead to valves IC, OT
Valve AL has flow rate=0; tunnels lead to valves VX, AK
Valve AM has flow rate=0; tunnels lead to valves OM, YW
Valve QX has flow rate=0; tunnels lead to valves UC, ZL
Valve DJ has flow rate=0; tunnels lead to valves OT, ST
Valve ZI has flow rate=0; tunnels lead to valves VX, UR
Valve PQ has flow rate=0; tunnels lead to valves ZL, YW
Valve OM has flow rate=22; tunnels lead to valves GI, AM, EK, UR
Valve NG has flow rate=13; tunnels lead to valves UC, HS, GF
Valve AA has flow rate=0; tunnels lead to valves UJ, ES, JP, HY, ST
Valve HY has flow rate=0; tunnels lead to valves GZ, AA
Valve MS has flow rate=0; tunnels lead to valves AS, QQ
Valve JK has flow rate=0; tunnels lead to valves YW, GB
Valve JP has flow rate=0; tunnels lead to valves AA, PF
Valve ST has flow rate=0; tunnels lead to valves AA, DJ
Valve CD has flow rate=0; tunnels lead to valves SS, ZL
Valve ES has flow rate=0; tunnels lead to valves EJ, AA
Valve PF has flow rate=0; tunnels lead to valves JP, HV
Valve RL has flow rate=0; tunnels lead to valves GB, IC
Valve IY has flow rate=0; tunnels lead to valves QQ, SN
Valve UJ has flow rate=0; tunnels lead to valves IC, AA
Valve HS has flow rate=0; tunnels lead to valves NG, OB
Valve WH has flow rate=0; tunnels lead to valves QQ, MX
Valve YA has flow rate=0; tunnels lead to valves GB, HV
Valve SN has flow rate=0; tunnels lead to valves IY, DG
Valve GF has flow rate=0; tunnels lead to valves GI, NG
Valve YW has flow rate=8; tunnels lead to valves GZ, JK, BL, PQ, AM
Valve DG has flow rate=17; tunnels lead to valves QP, SN
Valve MX has flow rate=11; tunnels lead to valves WH, YB
Valve DQ has flow rate=0; tunnels lead to valves YB, HV
Valve SS has flow rate=0; tunnels lead to valves CD, WI
Valve HV has flow rate=4; tunnels lead to valves YA, DQ, TO, JS, PF
Valve GB has flow rate=6; tunnels lead to valves LS, RL, JK, EJ, YA
Valve EK has flow rate=0; tunnels lead to valves OM, PW
Valve LS has flow rate=0; tunnels lead to valves GB, OT
Valve IC has flow rate=5; tunnels lead to valves CZ, OE, UJ, TO, RL
Valve XX has flow rate=0; tunnels lead to valves MC, FM
Valve VX has flow rate=25; tunnels lead to valves ZI, AL
Valve GZ has flow rate=0; tunnels lead to valves HY, YW
Valve FM has flow rate=20; tunnel leads to valve XX
Valve TO has flow rate=0; tunnels lead to valves IC, HV

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +0,0 @@
Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 8 clay. Each geode robot costs 2 ore and 18 obsidian.
Blueprint 2: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 4 ore and 15 obsidian.
Blueprint 3: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 3 ore and 8 obsidian.
Blueprint 4: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 19 clay. Each geode robot costs 2 ore and 12 obsidian.
Blueprint 5: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 11 clay. Each geode robot costs 4 ore and 7 obsidian.
Blueprint 6: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 7 clay. Each geode robot costs 2 ore and 19 obsidian.
Blueprint 7: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 14 clay. Each geode robot costs 4 ore and 11 obsidian.
Blueprint 8: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 7 clay. Each geode robot costs 3 ore and 10 obsidian.
Blueprint 9: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 6 clay. Each geode robot costs 2 ore and 16 obsidian.
Blueprint 10: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 5 clay. Each geode robot costs 3 ore and 15 obsidian.
Blueprint 11: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 10 clay. Each geode robot costs 2 ore and 13 obsidian.
Blueprint 12: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 12 clay. Each geode robot costs 3 ore and 17 obsidian.
Blueprint 13: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 19 clay. Each geode robot costs 2 ore and 18 obsidian.
Blueprint 14: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 6 clay. Each geode robot costs 4 ore and 11 obsidian.
Blueprint 15: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 12 clay. Each geode robot costs 3 ore and 8 obsidian.
Blueprint 16: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 16 clay. Each geode robot costs 4 ore and 16 obsidian.
Blueprint 17: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 7 clay. Each geode robot costs 3 ore and 8 obsidian.
Blueprint 18: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 11 clay. Each geode robot costs 2 ore and 16 obsidian.
Blueprint 19: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 11 clay. Each geode robot costs 2 ore and 8 obsidian.
Blueprint 20: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 11 clay. Each geode robot costs 3 ore and 14 obsidian.
Blueprint 21: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 15 clay. Each geode robot costs 2 ore and 13 obsidian.
Blueprint 22: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 9 clay. Each geode robot costs 3 ore and 7 obsidian.
Blueprint 23: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 4 ore and 8 obsidian.
Blueprint 24: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 5 clay. Each geode robot costs 3 ore and 12 obsidian.
Blueprint 25: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 15 clay. Each geode robot costs 3 ore and 16 obsidian.
Blueprint 26: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 3 ore and 10 obsidian.
Blueprint 27: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 9 clay. Each geode robot costs 3 ore and 7 obsidian.
Blueprint 28: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 11 clay. Each geode robot costs 3 ore and 8 obsidian.
Blueprint 29: Each ore robot costs 2 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 16 clay. Each geode robot costs 2 ore and 11 obsidian.
Blueprint 30: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 2 ore and 13 obsidian.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -1,72 +0,0 @@
#.#####..#..##......##.#..####....#.#.####..##.#######..##..##.###...#..
..#..##.#.#.#.##.#......######.#...###....#....#.#..#####.....#..#.####.
....#..#.###.####.......#.#.###..#.######...##..#.#.#..#.######.####..##
...#.#..####...#..##.#.####..#..##.#####..##.#...#..##..#..#.#.#.####...
.##..###..###.#.##...#..#.#.##.##.###.##....#.####.#.##.#..##.#####.#..#
#.#.###.#######..#...#####.##..##..##.#...#.#...#####.##....###.#...###.
...#...##.#..#.###....#.#.##..#.#..##.#.#.#..#...#.....#.####.##.#..##..
####.#...##.##.#..#.#####.#.##.###..#...#.#.##.##......##..#.#..##..##..
..#.##.##.####....##.....#.#.......##.#..#.###.####.###.#.....#.#.#...##
##...###..###.#.####.#..#...###...####..#####.#.#..##....#.#.####...#..#
####..#.#.##.##....#..##.###.#..#..###.##.#.....#######..##.##....#.#.##
.##...#.#####...#......##.#.##..#.####......#..###.##.##..#.#...##....##
.#.##.#.##.#..#..###.#.###....#.#.#.#.#.###....##..####.#######.##.##.#.
#######.##.#...###.#..#######.#..##.#..#.#...#.#.#.#..##.##.#.#.#....#..
#.#.#.#.##..##..#.##...##.#.###.####...####.##..#.##.##.###.###.#....##.
#...######.#....####.#.#.##....#..#...##.........#####.###..##.#.#..#.#.
#.#.#.#.#...#.###...#.....#.#....######......#..#..#.###.#..#.#.##.#....
#.##.#...#####.#....#.#.#..##...##.##.##.#####.####.#.##.#.###...#.##.##
#...#.#.###........##..#...#.###...###.##......##.####..#.##....##.#..##
#####.#..#.....#######..........#..####..##.#.#####..###...#...##.#.####
...###..##.##.##.##.#..###...###.#.##.#.###.##.#.#........###...#....##.
###.##...##.###..#..#.#.#...##.#.#.....##.#.##....####.####..#######..##
##.#.#..#..###.#.#######..#..#.#.#..#####...####...#.####....##.###..##.
..#.#.#....####.#.......#..#..###.##.#...##.####..###.#.#..####..#.####.
.#.#..##.##..#...##...###.##.#.#.#..#####...#...#####..##.#...###..#.##.
..###.#...#.#...#.###...###.##.#.#....#.#...##...##.....#.##.#.###.#....
##....#..#........###..#.##.#..##...#.#.#..##.####.#...#.########.###...
..#####.##.#...#..##...###.#####...#....#.##.######.#..#.##....###..##..
.####.##..###...#.##...#.#.##..###.......#.###.#.##...#.#....#.#.##..##.
#..#..###....#..#.#.....#.#.#####..##...####....####.#.#.##....#####.##.
##########.####.#...##.##...#....##..##...###....#..###.##..##.###...###
##.###..##.####.....#.#.....#.##...#...###..#.#...#....###..###.......#.
##..###.#....##..#.#....###...#.####.#.###.#.#.#..##.##..##.######.##...
#...####...#.##..##.##.#..####.#..#..#.##.##....#..#.##..##.#.###..#.###
#.#..##.###.....#....###.##.##.#.###.#####.#.....##.##.##..#.##.###..###
#...#..##..#..###....#..#...#..###...#.##.#.#.###...###..#.##..#..##.##.
#.#..#.##.#...#..............#.###...##.##.#.....########.###....#.....#
#..#.#...##..#.#.###.##.#.#....####.#.##.#.###.###.#..#..##.....#..####.
.....###....##.##..##..#....######......##.###..#.#......#.#..#..#...#.#
.##...###.#.#.###...##...##.#.####..#.###.#.#.#.###...##.#...#....###..#
#..####.#...#.##..#..#.###.###...#.#.#..##....####..#...##........####..
....##.##....#.....#..##..###..####..##.#.#.######..#....#..####.###.#..
.#.##..#..#.#.....#........#..###.##.###.##.#..#..##.....#.#.###.###..#.
#.#.#.#..#.###.#..#.##.##..######.##.######.#...#.###..#...#...##....#.#
##..#...##.#.#.#.######.####.###...####..#....####...#.#..###...##.##..#
.##.#....#...##...#...##.##.####..#.##..#.##.####..#.##..#..###..######.
.##.#.#.##.#.####..#..#..##.#....#...####.###.##.####.....###..#..#.#..#
#.##..#....##....##...#.##..####.#..####....###.##...###....##.###.##...
..##..##.#...#.#..###...#.#.#.###.#.#######..#..###.#.###..#.###....#..#
#..##.##.####..##.#....##..#.#......###....######..#.....###.....#.#.#..
.#...###.##...#.##.##...##...##..####...#..########.###..########.#..#.#
###.##.###.#.##.#..#.###....##...###.#.###.##..#.#...#..#####.##.##...#.
.###.####..###.#.....####.#...###.##.#.##..#..#....##....#.#..#....###..
##.#.#..##.#####..########..##...####....#.##.#.#.###.###.####.....####.
#....###.....####.###.###.##..#...#.##.##...##.#..#.........#####......#
##.####.#.#..#..#.##...#.##......#...#.#.#.####.##..##...####.....#.#.#.
...#.###.#..###.....#.#####.#.....####.###...#.###....#...#..#.#...##.#.
.#.......#...#......##..#.###....#.######..###.##...###...##.#.#.##..#.#
.##.###.#..#.#####..###...#.###...##.#.####.#.#.#..#....#####...#..##.##
.###..#...##..#.....##.#...#.#...##..##.#.###..###.#....##.###.###..#...
#######.##..#..#.#...#..#.#..#.#..###..#########.#.....#.....####.##.#.#
#.##..####...##.#..###.###...#....####...####..#...#####...##.#...#####.
#..##.#..#.######.#.#.#.##...##..#...##...#.......#.#####.#...#.##..#.#.
.##..#..###..#####.#.##..######.##...#.###.##.##.#..#....#..#.###..####.
...#...##.#...##.#.###.#.#..##..####.....#..........#..#.........##..##.
#####..##......##.##...#.##.###...####....##.##..#.###.#..##..#.##.#....
.###....##.#####.#.###.#.##...##.####....###..#......#.#..#....##.#.#.##
..###.#....#######.#.#..#.###.##.##..#..###...##.###.##.####.##.##.####.
.#.#...##.#..##.....###.#..#.#...##..#..#.#.#.###.##.##.#.....#.##..#...
.#####.#....#..#.####..####..#....#....##.#...#.##...###.#.#...#########
###.####....#.####..#..###....#.###.##...#####.###...#.#..#.#........###
#.#.######...#.#..#####.#.####.....##...#.###.#.##..##.#.#.##..#.####.#.

View File

@@ -1,27 +0,0 @@
#.########################################################################################################################
#<^^^^v^><<v<v.v<>><^><v<vv^vv<^^.^v^.v.<<<<v.vv<.>^^><v.^>v^>^>^^v>>v^^^.<v<>v<>.<>v^^^^^^>>^^.^^>>vv><^v<^.<v><^^v^<<<>#
#<>>>^^v^>v>v>^^^^.<<<>><^^>>^^<>v^v^v>^v>v>^vv.vvv>v<^^<<v>v^^><^>.>^^^.><^^<v.<^^>.v<vv<^>^<<<<v^vv>>>>v^.^v.>>>^v.>.v>#
#.v^v>vv.v<<^v>^<^v<.v<<.>>^vv<.^v^<^^>^<vv^vv>><^vv<<v>^^^vvv<v.><^.<v<^>>>.^<^<.v<^<^v>><^^^><^>>v^<^<v>^>>v^v<><^vv<v<#
#>.>>^<^v>v^.><^^.>.^>v>^^><vv>v><.^v<>^<<vvvv.<>>>^v.v<vv>.v..v^>><<v.^.^^v>^^v<v>>>^v<vvv.<^^<<>^>^.>v^^>^v<^v^v<>.<v<<#
#<v^^>v>vvvv<^^.^<^v><v<>v^>v<^<^^^<>^<<v<^>^^.<^v^^<<>.>vvv^^^v<v.^^^^<<<>^v^><^>v>><^.<^^^<>^v^v>^^v>>v>v<v><>v.^><v>>>#
#<^v>..>^>vv>v<<v>.v>vv>v^v<<<<<<<<v^^<v<.v.^<>>^>^^<>^^<>v<v.<^<.vvvvv>v^.^><<v>v<>>v.v.v^^>v<^v<^>v^v><<.<^^>v^vv<^^vv>#
#>v^^v^v>.<.^vv.^<<<<.<v>>v>>v^<.<><>v><<<^.<>v><.v^<v><<.><<<^^vv>^>v<<<>^<.^v>vv^<<^.>^<^^v<<vvvvv><^>v>^.>>>.v^.v^vv<>#
#<<<>>...v^^>^v<^v>>><<<>>vv^^<^^>^v<.>v^.>>v<<v>>>>^><.>v^.^vv><v^<.^v<^v<<<.^v^^^^<>^v>^>>>vv^<<.^>>v><vvvv<>v^<>><v<v>#
#>.>><vvv<<>v<><^><v>>.^<>.>^v^.<^.<>^>v^.><<^>><v><>..v<>^^<^.>><<^<<^<.^>^.vv^^>^.^>^.v^>v<>^^vv<.<>>><<^v>v<<>>v><^^<>#
#<<>.v<<<>^.vv<^v>.>^<><>v^.v<>v<>>vv<<.^^<<>^>>.><v<^<v^.>^vvv<vv.^^.^><v^v^v^<>v.vv>v>.>v.vv<<v^<>^^^^<v^^^.>v.vv^<..><#
#>.<<<v<>vv>>^v>vvv<^<>.vvv^<^>v<>^^<v^..><.<^<><>^^^^<^>.<v^>>v>^>v>^<><<v>v>v<^^<v>v>v>><>^v<.^v^><v^^<v^>v><..^.v<^<v>#
#>>^<^<v<<^vv>^^<>^<<>.<<v<^v^^v>.vv<><<v>^<>^><v^>.>>v^^<^^^^>v^^^^vv<>>><<^^<<><<<>v^<v^v<^.<>>>>^v>^><<<^^><vv<<<^<.<>#
#<^>.vv>>^.v.>^^v>.^<>>^<<..<v><^><><^v<v<^v^>^^^>v<^^.<>v.<<v<vv.>v^^<^<>>>vvv<^<^v><v>v>v^>..^<v<vv<<^^^v>.^><v<>^>><>>#
#>^<><<>^<<v><^>v^.v><>.<<^>>.<^^<v<<^>.>v.>v>><^^<>vv<<<>v.<vv><v<<.<>v<<.vv<><>>^vv<>v>vv^.<v<v<>><.v^v><.v^.v^v>>v>>v<#
#<<>><^^<v.v<<vv>>.<>v>>^^<^v.<v^<vv.vvv<><<<^v.^^<.><v<v<..v^>v^.^v^>v<>^v<<^<>vvv><>>v^^^>v<<<>.^<vv^>^>v^v^^.><<.>>^^>#
#<^.v^>^v>^<^><<^v^>v^<><<^^^v<<^.v^v<>^.>.v<<<v^vv^^v.<v<^^<^v^.><^^>v.<v<<^^<vv<>>>.<>^.^v>v>v><^><<<>.^^<>v.<.v><><v><#
#><<^>^<v<>^^^vv^>>.vv>vvv^v^>^^>v<<>^^^^>^>v<>>v^v>v><>.^vv^<>>>><<<>^>^.>..vv>^^^<^>v<>>^v><v<>^vv>v>^^vv<><^>^^^..>>>>#
#><vv^<v^^>><<v<v.<.v^..v><^v<<>^v>.^><v><^^v^<^<v><vvv^^v^><^v.><vv><^>^<v^v><v<.>^><^<<<v>>>v<><.^<^>^v<<^^>.<>vv<^.<v>#
#<.^^>><>><>><><>^.^>.vv^>>><<><vvvvv^v<<^^>.^..>><<<v>>.<>v<^<vv<^^.v^>>v<>vv^>vv<^<><<.vv><.<^^><>.vv<<><v>><>v<vvvv^.>#
#<v<<.^..v<>v><v<>>^<<.><^<v<^vv>vv>>v>^^<^^^>v^^>><^v<^.<<^^v<^v>>^.^<v.<>^v<^v^>v><v<>>^.>v.>>v>.>^v<>v<v>v<v<.>vv><.>>#
#<v^vv>>v<<.<v^<<.>^<^v<>v^^<>.v^>^v<v>>>vv>^^>>>v<<<><<^^.>>^><>^<v<>>.v>^>v^^>^^>>>v>v^>>v>^^.v>.vvv>.v<>.^^<<<^vv^>^^>#
#>v^^.v^<.<^v<>.^<><>^^^.v.<<.^<^v<vv^v^>v^>^v.^.v^>vvv<^<>^>^^v>v>v^.v^^>^>>^>^v^>^v^^.><^.^^>^^<^><>>^>.>.^^^v<<<v.>v>.#
#<v><>v<^^<><<vv.v><v>.vv^><.v^.<v^v.><>^<>.^<<vvv^vv^>v.^v>.><^^<.>>vvv><^<^<v>v<^v.^^><>>>.<^^<v<v^^.^v<^>^<v^<>>v>>>><#
#><^^v>>>vv>^<<<<>>v>vv<vv<>>>><v>.v<<.<>><v^.<>.<<^vv>^><v<^>^<<v^<^><>>.v<^vv<vv<><^<>.vv^v^^<>>vvv<>^<v<<v<<v^<v<^>^^>#
#<v..<.vv<v<>vvv^..v>^v^><^<^>>^.v^^<><>>v^>><><<v<v>><^^^v>vv><<^<.>>>v<v.><>v><>>^^<<.>>.><>vv>.^^vv>>>^vv^<^>^<^<^<<^>#
########################################################################################################################.#

View File

@@ -1,114 +0,0 @@
1-0-0020
1=0---1=1=201
10=02-0=1
1-12-=111201-1212
110=-222=0201=
10--2=20
2=12=-02222021=02-
1-1-1=-1
2=2=2--00-2121=02-1
201-1-210-
1212-11=
2=---10
2=1-02200001211
1===1-2==2-1
10=--=-=00
22-0=
2==0-1022=02
11221=-==-1-20-0
100
10-=22===1=00=0
2=0
1=1=0101=20
2--0=02-11021-
1222011-2--2=
22
20==00=122
2=1-010
20-=222-=2-1002-2
2=
122==01==12202-=
120202
2112=2-0202-12-02
1-=
11=
1101-1==2--
1=0=00=2=0-=02
1021--
1=02-=201122-=12-1
1==0=200=02=2=-2=22
1=21=10211-2222
21-0
1==21=
12=-220002-1=-21=2
1100-=-
1201=02=-111=00-0=
10=-=0122100==1--2
21=-12
10=21-0-2-200022
2102=-2--=1-2=2-1
1=1211101
2002=02--===
1200-
11--20-=-
10-20-0
1=2=
20100-22-0
12==-1
22=0011
2-200222=1121
201-2-=2==00-
1=-=0=--0===2
21=----2==020
1=1-20-=1=-02-2--2=
21
1=202110111=000
2-22-002=
10=1-001
1-002-221000=02
2==---1-0
1012=0--=00--10
1-2=21-2
1=1
11-
1-10--122-12
20
1==
2010=-2-2==2=--
1=11=
10-=
1=-=2--2-110=100
100==--01==
1-1-20=--1-2-0212
20-1001002-
2=1-
1==-2-0-102=-
1-1
12-1-0=2=-22--=10
10=21-02--=-=22
110210-12210--1-=-
1==1--2=21
1-0200=2-2-
22==-00=-
1-=2=-20-202=20111
2=0=-1=
1=-212=1=2
10-220=02
100-
1==02=0021
10=-1222-
1-212==
12-012=
1-0-102-1=-=-01=1-=1
1-
11211
2-0
1=0=
1=0=111000--=12=1
1-1-011==0102-
2==02202=2-=2
11---01-=--=2-02
1==0120-01=0-=0
1=-=2=1-=0=0==212=
212211110=
1=20101-==1

View File

@@ -0,0 +1,57 @@
namespace AdventOfCode2022.Test
open System.Collections.Generic
open AdventOfCode2022
open NUnit.Framework
open FsUnitTyped
[<TestFixture>]
module TestEnumerators =
[<Test>]
let ``MapEnumerator doesn't allocate`` () =
let original = seq { 1..100 }
let f (x : int) = byte x + 1uy
let enum = MapEnumerator.make f (original.GetEnumerator ())
//let foo = unbox<IEnumerator<byte>> (enum.GetEnumerator ())
//let enum = MapEnumerator.make<byte, byte> id foo
// Seq's GetEnumerator does allocate.
let bytesBefore = System.GC.GetAllocatedBytesForCurrentThread ()
let mutable expected = 2uy
for output in enum do
// shouldEqual allocates
if output <> expected then
failwithf "not equal, expected %i, actual %i" expected output
expected <- expected + 1uy
let bytesAfter = System.GC.GetAllocatedBytesForCurrentThread ()
bytesAfter |> shouldEqual bytesBefore
[<Test>]
let ``ChooseEnumerator doesn't allocate`` () =
let original = seq { 1..100 }
let enum =
ChooseEnumerator.make
(fun x -> let x = byte x + 1uy in if x % 2uy = 0uy then ValueSome x else ValueNone)
(original.GetEnumerator ())
let bytesBefore = System.GC.GetAllocatedBytesForCurrentThread ()
let mutable expected = 2uy
for output in enum do
// shouldEqual allocates
if output <> expected then
failwithf "not equal, expected %i, actual %i" expected output
expected <- expected + 2uy
let bytesAfter = System.GC.GetAllocatedBytesForCurrentThread ()
bytesAfter |> shouldEqual bytesBefore

View File

@@ -1,4 +1,4 @@

Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "AdventOfCode2022", "AdventOfCode2022\AdventOfCode2022.fsproj", "{6C4FDE18-389F-4AE6-AE9A-B4BD5BA19773}" Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "AdventOfCode2022", "AdventOfCode2022\AdventOfCode2022.fsproj", "{6C4FDE18-389F-4AE6-AE9A-B4BD5BA19773}"
EndProject EndProject

View File

@@ -1,16 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="EfficientString.fs" /> <Compile Include="EfficientString.fs" />
<Compile Include="IntSet.fs" />
<Compile Include="Arr2D.fs" />
<Compile Include="Arr3D.fs" />
<Compile Include="Day1.fs" /> <Compile Include="Day1.fs" />
<Compile Include="Day2.fs" /> <Compile Include="Day2.fs" />
<Compile Include="Day3.fs" /> <Compile Include="Day3.fs" />
@@ -21,26 +18,6 @@
<Compile Include="Day7.fs" /> <Compile Include="Day7.fs" />
<Compile Include="Day8.fs" /> <Compile Include="Day8.fs" />
<Compile Include="Day9.fs" /> <Compile Include="Day9.fs" />
<Compile Include="Day10.fs" />
<Compile Include="Day11.fs" />
<Compile Include="Day12.fs" />
<Compile Include="Day13.fs" />
<Compile Include="Day14.fs" />
<Compile Include="Day15.fs" />
<Compile Include="Day16.fs" />
<Compile Include="Day17.fs" />
<Compile Include="Day18.fs" />
<Compile Include="Day19.fs" />
<Compile Include="Day20.fs" />
<Compile Include="Day21.fs" />
<Compile Include="Day22.fs" />
<Compile Include="Day23.fs" />
<Compile Include="Day24.fs" />
<Compile Include="Day25.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Collections.ParallelSeq" Version="1.2.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@@ -1,102 +0,0 @@
namespace AdventOfCode2022
#if DEBUG
#else
#nowarn "9"
#endif
open Microsoft.FSharp.NativeInterop
[<Struct>]
#if DEBUG
type Arr2D<'a> =
{
Elements : 'a array
Width : int
}
member this.Height = this.Elements.Length / this.Width
#else
type Arr2D<'a when 'a : unmanaged> =
{
Elements : nativeptr<'a>
Length : int
Width : int
}
member this.Height = this.Length / this.Width
#endif
[<RequireQualifiedAccess>]
module Arr2D =
/// It's faster to iterate forward over the first argument, `x`.
let inline get (arr : Arr2D<'a>) (x : int) (y : int) : 'a =
#if DEBUG
arr.Elements.[y * arr.Width + x]
#else
NativePtr.get arr.Elements (y * arr.Width + x)
#endif
let inline set (arr : Arr2D<'a>) (x : int) (y : int) (newVal : 'a) : unit =
#if DEBUG
arr.Elements.[y * arr.Width + x] <- newVal
#else
NativePtr.write (NativePtr.add arr.Elements (y * arr.Width + x)) newVal
#endif
#if DEBUG
let create (width : int) (height : int) (value : 'a) : Arr2D<'a> =
let arr = Array.create (width * height) value
{
Width = width
Elements = arr
}
#else
/// The input array must be at least of size width * height
let create (arr : nativeptr<'a>) (width : int) (height : int) (value : 'a) : Arr2D<'a> =
{
Width = width
Elements = arr
Length = width * height
}
#endif
[<RequiresExplicitTypeArguments>]
#if DEBUG
let zeroCreate<'a when 'a : unmanaged> (width : int) (height : int) : Arr2D<'a> =
{
Elements = Array.zeroCreate (width * height)
Width = width
}
#else
let zeroCreate<'a when 'a : unmanaged> (elts : nativeptr<'a>) (width : int) (height : int) : Arr2D<'a> =
{
Elements = elts
Width = width
Length = width * height
}
#endif
/// The closure is given x and then y.
#if DEBUG
let inline init (width : int) (height : int) (f : int -> int -> 'a) : Arr2D<'a> =
let result = zeroCreate<'a> width height
#else
let inline init (arr : nativeptr<'a>) (width : int) (height : int) (f : int -> int -> 'a) : Arr2D<'a> =
let result = zeroCreate<'a> arr width height
#endif
for y = 0 to height - 1 do
for x = 0 to width - 1 do
set result x y (f x y)
result
let inline clear (a : Arr2D<'a>) : unit =
#if DEBUG
System.Array.Clear a.Elements
#else
NativePtr.initBlock a.Elements 0uy (uint32 sizeof<'a> * uint32 a.Length)
#endif

View File

@@ -1,100 +0,0 @@
namespace AdventOfCode2022
#if DEBUG
#else
#nowarn "9"
#endif
open Microsoft.FSharp.NativeInterop
[<Struct>]
#if DEBUG
type Arr3D<'a> =
{
Elements : 'a array
Width : int
WidthTimesHeight : int
}
member this.Depth = this.Elements.Length / this.WidthTimesHeight
#else
type Arr3D<'a when 'a : unmanaged> =
{
Elements : nativeptr<'a>
Length : int
Width : int
WidthTimesHeight : int
}
member this.Depth = this.Length / this.WidthTimesHeight
#endif
[<RequireQualifiedAccess>]
module Arr3D =
/// It's faster to iterate forward over the first argument, `x`, and then the
/// second argument, `y`.
let inline get (arr : Arr3D<'a>) (x : int) (y : int) (z : int) : 'a =
#if DEBUG
arr.Elements.[z * arr.WidthTimesHeight + y * arr.Width + x]
#else
NativePtr.get arr.Elements (z * arr.WidthTimesHeight + y * arr.Width + x)
#endif
let inline set (arr : Arr3D<'a>) (x : int) (y : int) (z : int) (newVal : 'a) : unit =
#if DEBUG
arr.Elements.[z * arr.WidthTimesHeight + y * arr.Width + x] <- newVal
#else
NativePtr.write (NativePtr.add arr.Elements (z * arr.WidthTimesHeight + y * arr.Width + x)) newVal
#endif
#if DEBUG
let create (width : int) (height : int) (depth : int) (value : 'a) : Arr3D<'a> =
let arr = Array.create (width * height * depth) value
{
Width = width
WidthTimesHeight = width * height
Elements = arr
}
#else
/// The input array must be at least of size width * height * depth
let create (arr : nativeptr<'a>) (width : int) (height : int) (depth : int) (value : 'a) : Arr3D<'a> =
{
Width = width
Elements = arr
Length = width * height * depth
WidthTimesHeight = width * height
}
#endif
[<RequiresExplicitTypeArguments>]
#if DEBUG
let zeroCreate<'a when 'a : unmanaged> (width : int) (height : int) (depth : int) : Arr3D<'a> =
{
Elements = Array.zeroCreate (width * height * depth)
Width = width
WidthTimesHeight = width * height
}
#else
let zeroCreate<'a when 'a : unmanaged>
(elts : nativeptr<'a>)
(width : int)
(height : int)
(depth : int)
: Arr3D<'a>
=
{
Elements = elts
Width = width
WidthTimesHeight = width * height
Length = width * height * depth
}
#endif
let inline clear (a : Arr3D<'a>) : unit =
#if DEBUG
System.Array.Clear a.Elements
#else
NativePtr.initBlock a.Elements 0uy (uint32 sizeof<'a> * uint32 a.Length)
#endif

View File

@@ -2,7 +2,6 @@
open System open System
open System.Collections.Generic open System.Collections.Generic
open System.Globalization
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module Day1 = module Day1 =
@@ -16,7 +15,7 @@ module Day1 =
counts.Add acc counts.Add acc
acc <- 0 acc <- 0
else else
acc <- acc + Int32.Parse (line, NumberStyles.None) acc <- acc + Int32.Parse line
if acc <> 0 then if acc <> 0 then
counts.Add acc counts.Add acc

View File

@@ -1,90 +0,0 @@
namespace AdventOfCode2022
open System.Collections.Generic
open System
type Day10Instruction =
| Noop
| Addx of int
[<RequireQualifiedAccess>]
module Day10 =
let parse (lines : StringSplitEnumerator) : Day10Instruction IReadOnlyList =
use mutable enum = lines
let output = ResizeArray ()
for line in enum do
let line = line.TrimEnd ()
if not (line.IsWhiteSpace ()) then
let toAdd =
if EfficientString.equals "noop" line then
Day10Instruction.Noop
else
let mutable split = StringSplitEnumerator.make' ' ' line
StringSplitEnumerator.chomp "addx" &split
let value = StringSplitEnumerator.consumeInt &split
if split.MoveNext () then
failwith "line had too many spaces"
Day10Instruction.Addx value
output.Add toAdd
output :> _
let perform (startState : 'a) (onCycle : 'a -> int -> int -> 'a) (instructions : Day10Instruction IReadOnlyList) =
let mutable cycle = 0
let mutable state = startState
let mutable spritePos = 1
let inline incrCycle () =
state <- onCycle state cycle spritePos
cycle <- cycle + 1
for instruction in instructions do
incrCycle ()
match instruction with
| Day10Instruction.Noop -> ()
| Day10Instruction.Addx newX ->
incrCycle ()
spritePos <- spritePos + newX
state
let part1 (lines : StringSplitEnumerator) : int =
let instructions = parse lines
let updateState cost cycle spritePos =
if cycle % 40 = 19 then
cost + ((cycle + 1) * spritePos)
else
cost
perform 0 updateState instructions
let part2 (lines : StringSplitEnumerator) : char[] =
let instructions = parse lines
let arr = Array.create 240 '.'
let updateState (arr : char[]) cycle spritePos =
if spritePos - 1 = cycle % 40 && spritePos % 40 <> 0 then
arr.[cycle] <- '#'
elif spritePos + 1 = cycle % 40 && spritePos % 40 <> 39 then
arr.[cycle] <- '#'
elif spritePos = cycle % 40 then
arr.[cycle] <- '#'
arr
perform arr updateState instructions
let inline render ([<InlineIfLambda>] print : string -> unit) (arr : char[]) : unit =
let arr = arr.AsSpan ()
for i = 0 to 5 do
let toPrint = arr.Slice (i * 40, 40)
print (toPrint.ToString ())

View File

@@ -1,332 +0,0 @@
namespace AdventOfCode2022
open System.Collections.Generic
open System
open System.Globalization
open Microsoft.FSharp.NativeInterop
#if DEBUG
open Checked
#endif
#nowarn "9"
[<Measure>]
type monkey
[<RequireQualifiedAccess>]
module Day11 =
type Monkey =
{
OperationIsPlus : bool
/// Negative is None
Argument : int64
TestDivisibleBy : int64
TrueCase : int<monkey>
FalseCase : int<monkey>
}
let parse (memory : nativeptr<int64>) (lines : StringSplitEnumerator) : Monkey array * nativeptr<int64>[] * int[] =
use mutable enum = lines
let output = ResizeArray ()
let startingItems = ResizeArray ()
while enum.MoveNext () do
let monkey =
let line = enum.Current.TrimEnd ()
let mutable enum = StringSplitEnumerator.make' ' ' (line.TrimEnd ':')
StringSplitEnumerator.chomp "Monkey" &enum
let monkey = StringSplitEnumerator.consumeInt &enum * 1<monkey>
if enum.MoveNext () then
failwith "Bad Monkey row"
monkey
if not (enum.MoveNext ()) then
failwith "Ran out of rows"
let line = enum.Current
let startItems =
let line = line.Trim ()
let mutable enum = StringSplitEnumerator.make' ' ' line
StringSplitEnumerator.chomp "Starting" &enum
StringSplitEnumerator.chomp "items:" &enum
let items = ResizeArray ()
while enum.MoveNext () do
let s = enum.Current.TrimEnd ','
items.Add (Int64.Parse s)
items
if not (enum.MoveNext ()) then
failwith "Ran out of rows"
let line = enum.Current
let operationIsPlus, arg =
let line = line.Trim ()
let mutable enum = StringSplitEnumerator.make' ':' line
StringSplitEnumerator.chomp "Operation" &enum
if not (enum.MoveNext ()) then
failwith "expected an operation"
let line = enum.Current.Trim ()
if enum.MoveNext () then
failwith "bad formatting on operation"
let mutable enum = StringSplitEnumerator.make' '=' line
StringSplitEnumerator.chomp "new " &enum
if not (enum.MoveNext ()) then
failwith "expected an RHS"
let rhs = enum.Current.Trim ()
if enum.MoveNext () then
failwith "too many equals signs"
let mutable enum = StringSplitEnumerator.make' ' ' rhs
StringSplitEnumerator.chomp "old" &enum
if not (enum.MoveNext ()) then
failwith "expected three elements on RHS"
let operationIsPlus =
if enum.Current.Length > 1 then
failwith "expected operation of exactly 1 char"
match enum.Current.[0] with
| '*' -> false
| '+' -> true
| c -> failwithf "Unrecognised op: %c" c
if not (enum.MoveNext ()) then
failwith "expected three elements on RHS"
let arg =
if EfficientString.equals "old" enum.Current then
-1L
else
let literal = Int64.Parse enum.Current
literal
if enum.MoveNext () then
failwith "too many entries on row"
operationIsPlus, arg
if not (enum.MoveNext ()) then
failwith "Ran out of rows"
let line = enum.Current.Trim ()
let test =
if not (line.StartsWith "Test: divisible by ") then
failwith "bad formatting on test line"
Int32.Parse (line.Slice 19, NumberStyles.None)
if not (enum.MoveNext ()) then
failwith "Ran out of rows"
let line = enum.Current.Trim ()
let ifTrue =
if not (line.StartsWith "If true: throw to monkey ") then
failwith "bad formatting for ifTrue line"
Int32.Parse (line.Slice 25, NumberStyles.None) * 1<monkey>
if not (enum.MoveNext ()) then
failwith "Ran out of rows"
let line = enum.Current.Trim ()
let ifFalse =
if not (line.StartsWith "If false: throw to monkey ") then
failwith "bad formatting for ifFalse line"
Int32.Parse (line.Slice 26, NumberStyles.None) * 1<monkey>
// We may be at the end, in which case there's no empty row.
enum.MoveNext () |> ignore
if ifTrue = monkey then
failwith "assumption broken: throws to self"
if ifFalse = monkey then
failwith "assumption broken: throws to self"
startingItems.Add startItems
{
OperationIsPlus = operationIsPlus
Argument = arg
TestDivisibleBy = test
TrueCase = ifTrue
FalseCase = ifFalse
}
|> output.Add
let totalItemCount = startingItems |> Seq.sumBy (fun x -> x.Count)
let items =
Array.init
startingItems.Count
(fun i ->
for j = 0 to startingItems.[i].Count - 1 do
NativePtr.write (NativePtr.add memory (totalItemCount * i + j)) startingItems.[i].[j]
NativePtr.add memory (totalItemCount * i)
)
let counts = Array.init startingItems.Count (fun i -> startingItems.[i].Count)
output.ToArray (), items, counts
let oneRoundDivThree
(monkeys : IReadOnlyList<Monkey>)
(items : nativeptr<int64>[])
(counts : nativeptr<int>)
(inspections : int array)
=
for i = 0 to monkeys.Count - 1 do
let monkey = monkeys.[i]
let countsI = NativePtr.get counts i
inspections.[i] <- inspections.[i] + countsI
for worryIndex = 0 to countsI - 1 do
let worry = NativePtr.get items.[i] worryIndex
let newWorry =
let arg =
match monkey.Argument with
| -1L -> worry
| l -> l
if monkey.OperationIsPlus then worry + arg else worry * arg
let newWorry = newWorry / 3L
let target =
if newWorry % monkey.TestDivisibleBy = 0 then
monkey.TrueCase
else
monkey.FalseCase
let target = target / 1<monkey>
let targetCount = NativePtr.get counts target
NativePtr.write (NativePtr.add items.[target] targetCount) newWorry
NativePtr.write (NativePtr.add counts target) (targetCount + 1)
NativePtr.write (NativePtr.add counts i) 0
let inline maxTwo (arr : int array) : struct (int * int) =
let mutable best = max arr.[1] arr.[0]
let mutable secondBest = min arr.[1] arr.[0]
for i = 2 to arr.Length - 1 do
if arr.[i] > best then
secondBest <- best
best <- arr.[i]
elif arr.[i] > secondBest then
secondBest <- arr.[i]
struct (secondBest, best)
let part1 (lines : StringSplitEnumerator) : int64 =
let memory = NativePtr.stackalloc<int64> 1000
let monkeys, items, counts = parse memory lines
use counts = fixed counts
let mutable inspections = Array.zeroCreate<int> monkeys.Length
for _round = 1 to 20 do
oneRoundDivThree monkeys items counts inspections
let struct (a, b) = maxTwo inspections
int64 a * int64 b
let oneRound
(modulus : int64)
(monkeys : Monkey array)
(items : nativeptr<nativeptr<int64>>)
(counts : nativeptr<int>)
(inspections : nativeptr<int>)
=
for i = 0 to monkeys.Length - 1 do
let monkey = monkeys.[i]
let entry = NativePtr.add inspections i
let countI = NativePtr.get counts i
NativePtr.write entry (NativePtr.read entry + countI)
for worryIndex = 0 to countI - 1 do
let worry = NativePtr.get (NativePtr.get items i) worryIndex
let newWorry =
let arg =
match monkey.Argument with
| -1L -> worry
| l -> l
if monkey.OperationIsPlus then worry + arg else worry * arg
let newWorry = newWorry % modulus
let target =
if newWorry % monkey.TestDivisibleBy = 0 then
monkey.TrueCase
else
monkey.FalseCase
let target = target / 1<monkey>
NativePtr.write (NativePtr.add (NativePtr.get items target) (NativePtr.get counts target)) newWorry
NativePtr.write (NativePtr.add counts target) (NativePtr.get counts target + 1)
NativePtr.write (NativePtr.add counts i) 0
let inline unsafeMaxTwo< ^a when ^a : unmanaged and ^a : comparison>
(len : int)
(arr : nativeptr<'a>)
: struct ('a * 'a)
=
let arr0 = NativePtr.read arr
let arr1 = NativePtr.get arr 1
let mutable best = LanguagePrimitives.GenericMaximum arr0 arr1
let mutable secondBest = min arr0 arr1
for i = 2 to len - 1 do
let arrI = NativePtr.get arr i
if arrI > best then
secondBest <- best
best <- arrI
elif arrI > secondBest then
secondBest <- arrI
struct (secondBest, best)
let part2 (lines : StringSplitEnumerator) : int64 =
let memory = NativePtr.stackalloc<int64> 1000
let monkeys, items, counts = parse memory lines
use counts = fixed counts
use items = fixed items
let inspections = NativePtr.stackalloc<int> monkeys.Length
let modulus =
(1L, monkeys) ||> Seq.fold (fun i monkey -> i * monkey.TestDivisibleBy)
for _round = 1 to 10000 do
oneRound modulus monkeys items counts inspections
let struct (a, b) = unsafeMaxTwo monkeys.Length inspections
int64 a * int64 b

View File

@@ -1,243 +0,0 @@
namespace AdventOfCode2022
open System
open System.Runtime.CompilerServices
#if DEBUG
open Checked
#endif
#if DEBUG
#else
#nowarn "9"
#endif
[<Struct>]
[<IsReadOnly>]
type Coordinate =
{
X : int
Y : int
}
[<RequireQualifiedAccess>]
module Day12 =
let private charToByte (c : char) = byte c - byte 'a'
let parse (lines : StringSplitEnumerator) : array<byte> * int * Coordinate * Coordinate =
use mutable enum = lines
let output = ResizeArray ()
let mutable startPos = Unchecked.defaultof<Coordinate>
let mutable endPos = Unchecked.defaultof<Coordinate>
let mutable row = 0
while enum.MoveNext () do
if not (enum.Current.IsWhiteSpace ()) then
let current = enum.Current.TrimEnd ()
let arr = Array.zeroCreate current.Length
for i = 0 to arr.Length - 1 do
if current.[i] = 'S' then
startPos <-
{
X = i
Y = row
}
arr.[i] <- 0uy
elif current.[i] = 'E' then
endPos <-
{
X = i
Y = row
}
arr.[i] <- 25uy
else
arr.[i] <- charToByte current.[i]
arr |> output.Add
row <- row + 1
let arr = Array.zeroCreate<byte> (output.Count * output.[0].Length)
for x = 0 to output.[0].Length - 1 do
for y = 0 to output.Count - 1 do
arr.[y * output.[0].Length + x] <- output.[y].[x]
arr, output.[0].Length, startPos, endPos
let inline isEdge (nodes : Arr2D< ^a >) sourceX sourceY destX destY =
Arr2D.get nodes sourceX sourceY
<= LanguagePrimitives.GenericOne + Arr2D.get nodes destX destY
/// The input arrays must all have the same dimensions.
/// `nodes` will not be mutated; `distances` and `isVisited` will be mutated.
/// (As a result of these arguments, `dijkstra` is allocation-free.)
/// Returns the shortest path to the destination, or the min of the shortest path to all
/// destinations.
let dijkstra
(distances : Arr2D<int>)
(isVisited : Arr2D<bool>)
(nodes : Arr2D<byte>)
(start : Coordinate)
(dest : Coordinate option)
: int
=
let mutable currentX = start.X
let mutable currentY = start.Y
let mutable currentDistance = 0
Arr2D.clear isVisited
// A distance of 0 is interpreted as infinite.
Arr2D.clear distances
let mutable stillGoing = true
while stillGoing && currentDistance < Int32.MaxValue do
if currentX < distances.Width - 1 then
if
not (Arr2D.get isVisited (currentX + 1) currentY)
&& isEdge nodes currentX currentY (currentX + 1) currentY
then
let newDistance = 1 + currentDistance
let distanceGuess = Arr2D.get distances (currentX + 1) currentY
if distanceGuess = 0 || newDistance < distanceGuess then
Arr2D.set distances (currentX + 1) currentY newDistance
if currentX > 0 then
if
not (Arr2D.get isVisited (currentX - 1) currentY)
&& isEdge nodes currentX currentY (currentX - 1) currentY
then
let newDistance = 1 + currentDistance
let distanceGuess = Arr2D.get distances (currentX - 1) currentY
if distanceGuess = 0 || newDistance < distanceGuess then
Arr2D.set distances (currentX - 1) currentY newDistance
if currentY > 0 then
if
not (Arr2D.get isVisited currentX (currentY - 1))
&& isEdge nodes currentX currentY currentX (currentY - 1)
then
let newDistance = 1 + currentDistance
let distanceGuess = Arr2D.get distances currentX (currentY - 1)
if distanceGuess = 0 || newDistance < distanceGuess then
Arr2D.set distances currentX (currentY - 1) newDistance
if currentY < distances.Height - 1 then
if
not (Arr2D.get isVisited currentX (currentY + 1))
&& isEdge nodes currentX currentY currentX (currentY + 1)
then
let newDistance = 1 + currentDistance
let distanceGuess = Arr2D.get distances currentX (currentY + 1)
if distanceGuess = 0 || newDistance < distanceGuess then
Arr2D.set distances currentX (currentY + 1) newDistance
Arr2D.set isVisited currentX currentY true
match dest with
| Some dest when currentX = dest.X && currentY = dest.Y -> stillGoing <- false
| _ ->
let mutable smallestDistance = Int32.MaxValue
for nextX = 0 to isVisited.Width - 1 do
for nextY = 0 to isVisited.Height - 1 do
if not (Arr2D.get isVisited nextX nextY) then
let distance = Arr2D.get distances nextX nextY
if distance > 0 && distance <= smallestDistance then
currentX <- nextX
currentY <- nextY
smallestDistance <- distance
currentDistance <- smallestDistance
match dest with
| Some dest -> Arr2D.get distances dest.X dest.Y
| None ->
let mutable minValue = Int32.MaxValue
for y = 0 to nodes.Height - 1 do
for x = 0 to nodes.Width - 1 do
if Arr2D.get nodes x y = 0uy then
let distance = Arr2D.get distances x y
if distance <> 0 then
minValue <- min minValue distance
minValue
let part1 (lines : StringSplitEnumerator) : int =
let data, width, start, endPoint = parse lines
#if DEBUG
let data =
{
Width = width
Elements = data
}
let distances = Arr2D.create data.Width data.Height Int32.MaxValue
let isVisited = Arr2D.zeroCreate<bool> data.Width data.Height
#else
use ptr = fixed data
let data =
{
Width = width
Elements = ptr
Length = data.Length
}
let distanceArr = Array.zeroCreate (data.Width * data.Height)
use ptr = fixed distanceArr
let distances = Arr2D.zeroCreate<int> ptr data.Width data.Height
let visitedArr = Array.zeroCreate (data.Width * data.Height)
use ptr = fixed visitedArr
let isVisited = Arr2D.zeroCreate<bool> ptr data.Width data.Height
#endif
dijkstra distances isVisited data endPoint (Some start)
let part2 (lines : StringSplitEnumerator) : int =
let data, width, _, endPoint = parse lines
#if DEBUG
let data =
{
Width = width
Elements = data
}
let distances = Arr2D.zeroCreate<int32> data.Width data.Height
let isVisited = Arr2D.zeroCreate<bool> data.Width data.Height
#else
use ptr = fixed data
let data =
{
Width = width
Elements = ptr
Length = data.Length
}
let distanceArr = Array.zeroCreate (data.Width * data.Height)
use ptr = fixed distanceArr
let distances = Arr2D.zeroCreate<int32> ptr data.Width data.Height
let visitedArr = Array.zeroCreate (data.Width * data.Height)
use ptr = fixed visitedArr
let isVisited = Arr2D.zeroCreate<bool> ptr data.Width data.Height
#endif
dijkstra distances isVisited data endPoint None

View File

@@ -1,195 +0,0 @@
namespace AdventOfCode2022
open System
open System.Collections.Generic
open System.Globalization
open System.Runtime.CompilerServices
#if DEBUG
open Checked
#endif
[<Struct>]
[<IsReadOnly>]
type Day13Packet =
{
Packet : Day13Packet ResizeArray ValueOption
/// If Packet is None, this is an int.
/// If Packet is Some, this is the start index of a slice.
StartIndexOrInt : int
}
[<RequireQualifiedAccess>]
module Day13 =
/// True if they're in the right order.
let rec cmp (packet1 : Day13Packet) (packet2 : Day13Packet) : bool ValueOption =
match packet1.Packet, packet2.Packet with
| ValueNone, ValueNone ->
if packet1.StartIndexOrInt < packet2.StartIndexOrInt then
ValueSome true
elif packet1.StartIndexOrInt > packet2.StartIndexOrInt then
ValueSome false
else
ValueNone
| ValueSome arr1, ValueSome arr2 ->
if packet1.StartIndexOrInt = arr1.Count then
if packet2.StartIndexOrInt = arr2.Count then
ValueNone
else
ValueSome true
elif packet2.StartIndexOrInt = arr2.Count then
ValueSome false
else
match cmp arr1.[packet1.StartIndexOrInt] arr2.[packet2.StartIndexOrInt] with
| ValueSome v -> ValueSome v
| ValueNone ->
let advanced1 =
{
Packet = ValueSome arr1
StartIndexOrInt = packet1.StartIndexOrInt + 1
}
let advanced2 =
{
Packet = ValueSome arr2
StartIndexOrInt = packet2.StartIndexOrInt + 1
}
cmp advanced1 advanced2
| ValueSome arr1, ValueNone ->
if packet1.StartIndexOrInt = arr1.Count then
ValueSome true
else
match cmp arr1.[packet1.StartIndexOrInt] packet2 with
| ValueSome v -> ValueSome v
| ValueNone ->
if packet1.StartIndexOrInt + 1 = arr1.Count then
ValueNone
else
ValueSome false
| ValueNone, ValueSome arr2 ->
if packet2.StartIndexOrInt = arr2.Count then
ValueSome false
else
match cmp packet1 arr2.[packet2.StartIndexOrInt] with
| ValueSome v -> ValueSome v
| ValueNone ->
if packet2.StartIndexOrInt + 1 = arr2.Count then
ValueNone
else
ValueSome true
let parse (lines : StringSplitEnumerator) : Day13Packet ResizeArray =
use mutable enum = lines
let output = ResizeArray ()
let mutable stack = Stack<_> ()
while enum.MoveNext () do
if not (enum.Current.IsWhiteSpace ()) then
let line = enum.Current.TrimEnd ()
assert (line.[0] = '[')
let mutable elements = StringSplitEnumerator.make' ',' line
while elements.MoveNext () do
let mutable curr = elements.Current
while curr.[0] = '[' do
stack.Push (ResizeArray ())
curr <- curr.Slice 1
if curr.[0] <> ']' then
let int =
{
StartIndexOrInt = Int32.Parse (curr.TrimEnd ']', NumberStyles.None)
Packet = ValueNone
}
stack.Peek().Add int
while curr.Length > 0 && curr.[curr.Length - 1] = ']' do
let closed =
{
Packet = ValueSome (stack.Pop ())
StartIndexOrInt = 0
}
if stack.Count = 0 then
output.Add closed
else
stack.Peek().Add closed
curr <- curr.Slice (0, curr.Length - 1)
output
let part1 (lines : StringSplitEnumerator) : int =
let data = parse lines
let mutable sum = 0
for i in 0..2 .. data.Count - 1 do
match cmp data.[i] data.[i + 1] with
| ValueNone -> failwith "should have decided"
| ValueSome false -> ()
| ValueSome true -> sum <- sum + (i / 2 + 1)
sum
let part2 (lines : StringSplitEnumerator) : int =
let data = parse lines
let marker1 =
let arr = ResizeArray 1
let arr2 = ResizeArray 1
arr2.Add
{
StartIndexOrInt = 2
Packet = ValueNone
}
arr.Add
{
StartIndexOrInt = 0
Packet = ValueSome arr2
}
{
Packet = ValueSome arr
StartIndexOrInt = 0
}
let marker2 =
let arr = ResizeArray 1
let arr2 = ResizeArray 1
arr2.Add
{
StartIndexOrInt = 6
Packet = ValueNone
}
arr.Add
{
StartIndexOrInt = 0
Packet = ValueSome arr2
}
{
Packet = ValueSome arr
StartIndexOrInt = 0
}
let mutable howManyLessThan = 0
let mutable howManyGreaterThan = 0
for i in 0 .. data.Count - 1 do
match cmp data.[i] marker1 with
| ValueSome true -> howManyLessThan <- howManyLessThan + 1
| _ ->
match cmp marker2 data.[i] with
| ValueSome true -> howManyGreaterThan <- howManyGreaterThan + 1
| _ -> ()
(howManyLessThan + 1) * (data.Count - howManyGreaterThan + 2)

View File

@@ -1,187 +0,0 @@
namespace AdventOfCode2022
open System
#if DEBUG
open System.Runtime.InteropServices
open Checked
#endif
#if DEBUG
#else
#nowarn "9"
#endif
type Day14Shape = Coordinate ResizeArray
[<RequireQualifiedAccess>]
type MutableCoordinate =
{
mutable X : int
mutable Y : int
}
[<RequireQualifiedAccess>]
module Day14 =
let parse (lines : StringSplitEnumerator) : Day14Shape ResizeArray =
use mutable enum = lines
let output = ResizeArray ()
while enum.MoveNext () do
if not (enum.Current.IsWhiteSpace ()) then
let line = enum.Current.TrimEnd ()
let thisLine = ResizeArray ()
let mutable components = StringSplitEnumerator.make' ' ' line
while components.MoveNext () do
let mutable coords = StringSplitEnumerator.make' ',' components.Current
let x = StringSplitEnumerator.consumeInt &coords
let y = StringSplitEnumerator.consumeInt &coords
{
Coordinate.X = x
Y = y
}
|> thisLine.Add
// the component '->'
components.MoveNext () |> ignore
output.Add thisLine
output
let setLine (point1 : Coordinate) (point2 : Coordinate) (arr : Arr2D<bool>) : unit =
if point1.X = point2.X then
for y = min point1.Y point2.Y to max point1.Y point2.Y do
Arr2D.set arr point1.X y true
else
assert (point1.Y = point2.Y)
for x = min point1.X point2.X to max point1.X point2.X do
Arr2D.set arr x point1.Y true
let inline fallOnce (sandPos : MutableCoordinate) (arr : Arr2D<bool>) : bool =
if not (Arr2D.get arr sandPos.X (sandPos.Y + 1)) then
sandPos.Y <- sandPos.Y + 1
true
elif not (Arr2D.get arr (sandPos.X - 1) (sandPos.Y + 1)) then
sandPos.X <- sandPos.X - 1
sandPos.Y <- sandPos.Y + 1
true
elif not (Arr2D.get arr (sandPos.X + 1) (sandPos.Y + 1)) then
sandPos.X <- sandPos.X + 1
sandPos.Y <- sandPos.Y + 1
true
else
false
let part1 (lines : StringSplitEnumerator) : int =
let data = parse lines
let minX = data |> Seq.concat |> Seq.map (fun s -> s.X) |> Seq.min
let maxX = data |> Seq.concat |> Seq.map (fun s -> s.X) |> Seq.max
let maxY = data |> Seq.concat |> Seq.map (fun s -> s.Y) |> Seq.max
#if DEBUG
let arr = Arr2D.zeroCreate<bool> (maxX + 1) (maxY + 1)
#else
let board = Array.zeroCreate ((maxX + 1) * (maxY + 1))
use ptr = fixed board
let arr = Arr2D.zeroCreate<bool> ptr (maxX + 1) (maxY + 1)
#endif
for line in data do
for i = 0 to line.Count - 2 do
setLine line.[i] line.[i + 1] arr
let mutable sand = 0
let mutable keepGoing = true
while keepGoing do
let sandPos =
{
MutableCoordinate.X = 500
MutableCoordinate.Y = 0
}
let mutable stillFalling = true
while stillFalling && sandPos.X >= minX && sandPos.X <= maxX && sandPos.Y < maxY do
let movedDown = fallOnce sandPos arr
if not movedDown then
stillFalling <- false
sand <- sand + 1
Arr2D.set arr sandPos.X sandPos.Y true
if stillFalling then
keepGoing <- false
sand
let part2 (lines : StringSplitEnumerator) : int =
let data = parse lines
let maxX = data |> Seq.concat |> Seq.map (fun s -> s.X) |> Seq.max
let maxY = data |> Seq.concat |> Seq.map (fun s -> s.Y) |> Seq.max |> ((+) 2)
#if DEBUG
let arr = Arr2D.zeroCreate<bool> (maxX + 1001) (maxY + 1)
#else
let board = Array.zeroCreate ((maxX + 1001) * (maxY + 1))
use ptr = fixed board
let arr = Arr2D.zeroCreate<bool> ptr (maxX + 1001) (maxY + 1)
#endif
for line in data do
for i = 0 to line.Count - 2 do
let point1 =
{
Coordinate.X = line.[i].X + 500
Y = line.[i].Y
}
let point2 =
{
Coordinate.X = line.[i + 1].X + 500
Y = line.[i + 1].Y
}
setLine point1 point2 arr
setLine
{
X = 0
Y = maxY
}
{
X = maxX + 1000
Y = maxY
}
arr
let mutable sand = 0
let mutable keepGoing = true
while keepGoing do
let sandPos =
{
MutableCoordinate.X = 1000
MutableCoordinate.Y = 0
}
let mutable stillFalling = true
while stillFalling && sandPos.Y < maxY do
let movedDown = fallOnce sandPos arr
if not movedDown then
sand <- sand + 1
Arr2D.set arr sandPos.X sandPos.Y true
if sandPos.X = 1000 && sandPos.Y = 0 then
keepGoing <- false
stillFalling <- false
sand

View File

@@ -1,250 +0,0 @@
namespace AdventOfCode2022
open System
open System.Collections.Generic
#if DEBUG
open Checked
#endif
[<RequireQualifiedAccess>]
module Day15 =
let parse (lines : StringSplitEnumerator) : Coordinate ResizeArray * Coordinate ResizeArray =
use mutable enum = lines
let sensors = ResizeArray ()
let beacons = ResizeArray ()
while enum.MoveNext () do
if not (enum.Current.IsWhiteSpace ()) then
let line = enum.Current.TrimEnd ()
let mutable equalsSplit = StringSplitEnumerator.make' '=' line
StringSplitEnumerator.chomp "Sensor at x" &equalsSplit
if not (equalsSplit.MoveNext ()) then
failwith "expected another entry"
let x = Int32.Parse (equalsSplit.Current.Slice (0, equalsSplit.Current.IndexOf ','))
if not (equalsSplit.MoveNext ()) then
failwith "expected another entry"
let y = Int32.Parse (equalsSplit.Current.Slice (0, equalsSplit.Current.IndexOf ':'))
let sensor =
{
X = x
Y = y
}
if not (equalsSplit.MoveNext ()) then
failwith "expected another entry"
let x = Int32.Parse (equalsSplit.Current.Slice (0, equalsSplit.Current.IndexOf ','))
if not (equalsSplit.MoveNext ()) then
failwith "expected another entry"
let y = Int32.Parse equalsSplit.Current
let closest =
{
X = x
Y = y
}
sensors.Add sensor
beacons.Add closest
sensors, beacons
let inline manhattan (p1 : Coordinate) (p2 : Coordinate) : int = abs (p1.X - p2.X) + abs (p1.Y - p2.Y)
let inline couldBeBeacon
(sensors : ResizeArray<Coordinate>)
(closestManhattans : int[])
(point : Coordinate)
: bool
=
let mutable keepGoing = true
let mutable i = 0
while keepGoing && i < sensors.Count do
if manhattan point sensors.[i] <= closestManhattans.[i] then
keepGoing <- false
i <- i + 1
keepGoing
let toHashSet (arr : Coordinate ResizeArray) : Coordinate HashSet =
let output = HashSet arr.Count
for beacon in arr do
output.Add beacon |> ignore
output
let part1 (y : int) (lines : StringSplitEnumerator) : int =
let sensors, beacons = parse lines
// The ith sensor has no beacons with Manhattan distance smaller than closestManhattans.[i]
let closestManhattans =
Array.init sensors.Count (fun i -> manhattan sensors.[i] beacons.[i])
let mutable minX = Int32.MaxValue
let mutable maxX = Int32.MinValue
let mutable i = 0
for point in sensors do
minX <- min minX (point.X - closestManhattans.[i])
maxX <- max maxX (point.X + closestManhattans.[i])
i <- i + 1
let mutable count = 0
for x = minX to maxX do
let point =
{
X = x
Y = y
}
if not (couldBeBeacon sensors closestManhattans point) then
count <- count + 1
// We've overcounted by the number of beacons in the row - they not only *could* be beacons, they *are* beacons!
let beacons = toHashSet beacons
for beacon in beacons do
if minX <= beacon.X && beacon.X <= maxX && beacon.Y = y then
count <- count - 1
count
let part2 (maxSearch : int) (lines : StringSplitEnumerator) : int64 =
let sensors, beacons = parse lines
let sensorXCoords =
let arr = Array.zeroCreate (sensors.Count + 2)
for i = 0 to sensors.Count - 1 do
arr.[i] <- sensors.[i].X
arr.[sensors.Count] <- maxSearch
Array.sortInPlace arr
arr
let sensorYCoords =
let arr = Array.zeroCreate (sensors.Count + 2)
for i = 0 to sensors.Count - 1 do
arr.[i] <- sensors.[i].Y
arr.[sensors.Count] <- maxSearch
Array.sortInPlace arr
arr
let mutable answer = -1L
let mutable xIndex = 0
while answer <> 1L && xIndex < sensorXCoords.Length - 1 do
let xMin = sensorXCoords.[xIndex]
xIndex <- xIndex + 1
let xMax = sensorXCoords.[xIndex]
let mutable yIndex = 0
while answer <> 1L && yIndex < sensorYCoords.Length - 1 do
let yMin = sensorYCoords.[yIndex]
yIndex <- yIndex + 1
let yMax = sensorYCoords.[yIndex]
let mutable minusXMinusYConstraint = Int32.MaxValue
let mutable minusXPlusYConstraint = Int32.MaxValue
let mutable plusXMinusYConstraint = Int32.MaxValue
let mutable plusXPlusYConstraint = Int32.MaxValue
for i = 0 to sensors.Count - 1 do
let sensor = sensors.[i]
let beacon = beacons.[i]
let manhattan = abs (sensor.X - beacon.X) + abs (sensor.Y - beacon.Y)
if sensor.X <= xMax then
if sensor.Y <= yMax then
minusXMinusYConstraint <- min minusXMinusYConstraint (-manhattan - sensor.X - sensor.Y - 1)
else
minusXPlusYConstraint <- min minusXPlusYConstraint (-manhattan - sensor.X + sensor.Y - 1)
else if sensor.Y <= yMax then
plusXMinusYConstraint <- min plusXMinusYConstraint (-manhattan + sensor.X - sensor.Y - 1)
else
plusXPlusYConstraint <- min plusXPlusYConstraint (-manhattan + sensor.X + sensor.Y - 1)
let yMax =
if
plusXPlusYConstraint <> Int32.MaxValue
&& plusXMinusYConstraint <> Int32.MaxValue
then
min ((plusXPlusYConstraint - plusXMinusYConstraint) / 2) yMax
else
yMax
let xMax =
if
plusXPlusYConstraint <> Int32.MaxValue
&& minusXPlusYConstraint <> Int32.MaxValue
then
min ((plusXPlusYConstraint - minusXPlusYConstraint) / 2) xMax
else
xMax
let xMin =
if
minusXMinusYConstraint <> Int32.MaxValue
&& minusXPlusYConstraint <> Int32.MaxValue
then
max xMin (-(minusXMinusYConstraint + minusXPlusYConstraint) / 2)
else
xMin
let yMin =
if
minusXMinusYConstraint <> Int32.MaxValue
&& plusXMinusYConstraint <> Int32.MaxValue
then
max yMin (-(minusXMinusYConstraint + plusXMinusYConstraint) / 2)
else
yMin
// (fst constraints).{x, y} <= (snd constraints), and also xMin <= x <= xMax and
// yMin <= y <= yMax.
let mutable falsified = false
if minusXMinusYConstraint <> Int32.MaxValue then
// Have -x-y <= upperBound1, i.e. -upperBound1 <= x+y,
// which we could falsify if -upperBound1 > x+y.
if xMax + yMax < -minusXMinusYConstraint then
falsified <- true
if minusXPlusYConstraint <> Int32.MaxValue then
// Have -x + y <= upperBound1, which we could falsify if y > upperBound1 + x
if yMin > minusXPlusYConstraint + xMax then
falsified <- true
if plusXPlusYConstraint <> Int32.MaxValue then
// Have x + y <= upperBound1, which we could falsify always if xMin + yMin > upperBound1.
if xMin + yMin > plusXPlusYConstraint then
falsified <- true
if plusXMinusYConstraint <> Int32.MaxValue then
// Have x - y <= upperBound1, which we could falsify if x > upperBound1 + y
if xMin > plusXMinusYConstraint + yMax then
falsified <- true
if not falsified then
answer <- int64 xMax * 4000000L + int64 yMax
answer

View File

@@ -1,399 +0,0 @@
namespace AdventOfCode2022
open System
open FSharp.Collections.ParallelSeq
#if DEBUG
open Checked
#else
#nowarn "9"
#endif
[<RequireQualifiedAccess>]
module Day16 =
type Node = int
/// Returns the nodes, and also the "AA" node.
let parse (lines : string seq) : Map<Node, int * IntSet> * Node =
let allNodes =
lines
|> Seq.filter (not << String.IsNullOrEmpty)
|> Seq.mapi (fun i line ->
let split = line.Split "tunne" |> Array.last |> (fun s -> s.Trim ())
let split = split.Split(' ').[4..] |> Array.map (fun s -> s.Trim ',') |> Set.ofArray
line.[6..7], (i, (Int32.Parse line.[line.IndexOf '=' + 1 .. line.IndexOf ';' - 1], split))
)
|> Map.ofSeq
let result =
allNodes
|> Map.toSeq
|> Seq.map (fun (key, (node, (weight, outbound))) ->
let outbound =
outbound |> Seq.map (fun x -> Map.find x allNodes |> fst) |> IntSet.ofSeq
node, (weight, outbound)
)
|> Map.ofSeq
result, fst allNodes.["AA"]
let inline tryMax< ^a when ^a : comparison> (s : seq<'a>) : 'a option =
use enum = s.GetEnumerator ()
if not (enum.MoveNext ()) then
None
else
let mutable answer = enum.Current
while enum.MoveNext () do
answer <- max answer enum.Current
Some answer
let tryMin (s : seq<'a>) : 'a ValueOption =
use enum = s.GetEnumerator ()
if not (enum.MoveNext ()) then
ValueNone
else
let mutable answer = enum.Current
while enum.MoveNext () do
answer <- min answer enum.Current
ValueSome answer
let getShortestPathLength (valves : Map<_, _>) : Node -> Node -> int =
let rec go (seenSoFar : IntSet) (v1 : Node) (v2 : Node) : int =
let v2Neighbours = snd valves.[v2]
if v1 = v2 then
0
elif IntSet.contains v2Neighbours v1 then
1
elif IntSet.contains seenSoFar v2 then
-1
else
let mutable best = Int32.MaxValue
let mutable neighbours = v2Neighbours
let mutable neighbour = 0
while neighbours > 0 do
if neighbours % 2L = 1L then
match go (IntSet.set seenSoFar v2) v1 neighbour with
| -1 -> ()
| next ->
if next < best then
best <- next
neighbours <- neighbours >>> 1
neighbour <- neighbour + 1
if best = Int32.MaxValue then -1 else best + 1
fun v1 v2 -> go IntSet.empty v1 v2
let part1 (lines : string seq) : int =
let valves, aaNode = parse lines
let allTaps =
valves |> Map.filter (fun _ (x, _) -> x > 0) |> Map.keys |> IntSet.ofSeq
let getShortestPathLength = getShortestPathLength valves
#if DEBUG
let pathWeights = Arr2D.zeroCreate<int> valves.Count valves.Count
#else
let pathWeightsStorage = Array.zeroCreate (valves.Count * valves.Count)
use ptr = fixed pathWeightsStorage
let pathWeights = Arr2D.zeroCreate<int> ptr valves.Count valves.Count
#endif
for v1 in IntSet.toSeq allTaps do
for v2 in IntSet.toSeq allTaps do
let length = getShortestPathLength v1 v2
Arr2D.set pathWeights v1 v2 length
let rec go
(timeRemainingOnCurrentPath : int)
(headingTo : Node)
(alreadyOn : IntSet)
(currentWeight : int)
(remaining : int)
=
if remaining <= 0 then
currentWeight
elif timeRemainingOnCurrentPath > 0 then
go (timeRemainingOnCurrentPath - 1) headingTo alreadyOn currentWeight (remaining - 1)
else
let alreadyOn = IntSet.set alreadyOn headingTo
let mutable allTaps = allTaps &&& (~~~alreadyOn)
let mutable count = 0
let mutable max = ValueNone
while allTaps > 0 do
if allTaps % 2L = 1 then
let addToWeight = fst valves.[headingTo] * (remaining - 1)
let candidate =
go
(Arr2D.get pathWeights count headingTo)
count
alreadyOn
(currentWeight + addToWeight)
(remaining - 1)
match max with
| ValueNone -> max <- ValueSome candidate
| ValueSome existingMax ->
if existingMax < candidate then
max <- ValueSome candidate
allTaps <- allTaps >>> 1
count <- count + 1
match max with
| ValueSome v -> v
| ValueNone -> currentWeight + (remaining - 1) * (fst valves.[headingTo])
let mutable startChoices = allTaps
let mutable start = 0
let mutable maxValue = Int32.MinValue
while startChoices > 0 do
if startChoices % 2L = 1L then
let distance = getShortestPathLength aaNode start
// By inspecting the graph, I can see that AA is screened off from the rest
// of the graph by the set of valves with distance at most 3 from it.
// Assume that we're going to turn them on when we pass through - this isn't
// actually fully general, but it is enough.
if distance <= 3 then
let candidate = go distance start 0 0 30
maxValue <- max maxValue candidate
startChoices <- startChoices >>> 1
start <- start + 1
maxValue
let part2 (lines : string seq) : int =
let valves, aaNode = parse lines
let valvesIndexed = valves |> Map.values |> Array.ofSeq
let allTaps =
valves |> Map.filter (fun _ (x, _) -> x > 0) |> Map.keys |> IntSet.ofSeq
let getShortestPathLength = getShortestPathLength valves
#if DEBUG
let pathWeights = Arr2D.zeroCreate<int> valves.Count valves.Count
#else
let pathWeightsStorage = Array.zeroCreate (valves.Count * valves.Count)
use ptr = fixed pathWeightsStorage
let pathWeights = Arr2D.zeroCreate<int> ptr valves.Count valves.Count
#endif
for v1 in IntSet.toSeq allTaps do
for v2 in IntSet.toSeq allTaps do
let length = getShortestPathLength v1 v2
Arr2D.set pathWeights v1 v2 length
let rec go
(journey1 : int)
(journey2 : int)
(headingTo1 : Node)
(headingTo2 : Node)
(alreadyOn : IntSet)
(currentWeight : int)
(remaining : int)
=
if remaining <= 0 then
currentWeight
elif journey1 > 0 && journey2 > 0 then
go (journey1 - 1) (journey2 - 1) headingTo1 headingTo2 alreadyOn currentWeight (remaining - 1)
elif journey1 = 0 && journey2 > 0 then
let addToWeight =
if IntSet.contains alreadyOn headingTo1 then
0
else
(remaining - 1) * (fst valvesIndexed.[headingTo1])
let newWeight = addToWeight + currentWeight
let alreadyOn = IntSet.set alreadyOn headingTo1
let mutable allTaps = allTaps &&& ~~~alreadyOn
let mutable node = 0
let mutable max = ValueNone
while allTaps > 0L do
// Strictly speaking we might be able to overtake the other one
// who is heading for their node, but it so happens that the
// test cases don't care about that.
if allTaps % 2L = 1L && node <> headingTo2 then
let next =
go
(Arr2D.get pathWeights node headingTo1)
(journey2 - 1)
node
headingTo2
alreadyOn
newWeight
(remaining - 1)
match max with
| ValueNone -> max <- ValueSome next
| ValueSome existingMax ->
if next > existingMax then
max <- ValueSome next
allTaps <- allTaps >>> 1
node <- node + 1
match max with
| ValueSome v -> v
| ValueNone -> go 1000000 (journey2 - 1) headingTo1 headingTo2 alreadyOn newWeight (remaining - 1)
elif journey2 = 0 && journey1 > 0 then
let addToWeight =
if IntSet.contains alreadyOn headingTo2 then
0
else
fst valvesIndexed.[headingTo2] * (remaining - 1)
let newWeight = addToWeight + currentWeight
let alreadyOn = IntSet.set alreadyOn headingTo2
let mutable allTaps = allTaps &&& ~~~alreadyOn
let mutable node = 0
let mutable max = ValueNone
while allTaps > 0L do
// Strictly speaking we might be able to overtake the other one
// who is heading for their node, but it so happens that the
// test cases don't care about that.
if allTaps % 2L = 1L && node <> headingTo1 then
let next =
go
(journey1 - 1)
(Arr2D.get pathWeights node headingTo2)
headingTo1
node
alreadyOn
newWeight
(remaining - 1)
match max with
| ValueNone -> max <- ValueSome next
| ValueSome existingMax ->
if next > existingMax then
max <- ValueSome next
allTaps <- allTaps >>> 1
node <- node + 1
match max with
| ValueSome v -> v
| ValueNone -> go (journey1 - 1) 1000000 headingTo1 headingTo2 alreadyOn newWeight (remaining - 1)
else
// Both reached destination at same time
let addToWeight1 =
if IntSet.contains alreadyOn headingTo1 then
0
else
(remaining - 1) * fst valvesIndexed.[headingTo1]
let addToWeight2 =
if IntSet.contains alreadyOn headingTo2 then
0
else
(remaining - 1) * fst valvesIndexed.[headingTo2]
let newWeight =
if headingTo1 <> headingTo2 then
addToWeight1 + addToWeight2 + currentWeight
else
addToWeight1 + currentWeight
let alreadyOn = IntSet.set (IntSet.set alreadyOn headingTo1) headingTo2
let nextChoices = allTaps &&& ~~~alreadyOn
if IntSet.count nextChoices >= 2 then
let mutable maxVal = Int32.MinValue
let mutable next1 = nextChoices
let mutable count1 = 0
while next1 > 0 do
if next1 % 2L = 1 then
let mutable next2 = nextChoices
let mutable count2 = 0
while next2 > 0 do
// It's never correct for both to try and turn on the same node.
if next2 % 2L = 1 && next1 <> next2 then
let candidate =
go
(Arr2D.get pathWeights count1 headingTo1)
(Arr2D.get pathWeights count2 headingTo2)
count1
count2
alreadyOn
newWeight
(remaining - 1)
maxVal <- max maxVal candidate
next2 <- next2 >>> 1
count2 <- count2 + 1
next1 <- next1 >>> 1
count1 <- count1 + 1
maxVal
elif nextChoices = 0 then
0
else
// nextChoices.Count = 1
let next = IntSet.first nextChoices
go 100000 (Arr2D.get pathWeights next headingTo2) next next alreadyOn newWeight (remaining - 1)
let startChoices =
allTaps
|> IntSet.toSeq
|> Seq.map (fun startNode -> startNode, getShortestPathLength aaNode startNode)
|> Map.ofSeq
let maxVal = ref Int32.MinValue
Seq.allPairs startChoices startChoices
|> Seq.filter (fun (KeyValue (n1, distance1), KeyValue (n2, distance2)) ->
// By inspecting the graph, I can see that AA is screened off from the rest
// of the graph by the set of valves with distance at most 3 from it.
// Assume that we're going to turn them on when we pass through - this isn't
// actually fully general, but it is enough.
n1 < n2 && distance1 <= 3 && distance2 <= 3
)
|> PSeq.map (fun (KeyValue (start1, distance1), KeyValue (start2, distance2)) ->
go distance1 distance2 start1 start2 0 0 26
)
|> PSeq.iter (fun s ->
lock
maxVal
(fun () ->
if s > maxVal.Value then
maxVal.Value <- s
)
)
maxVal.Value

View File

@@ -1,295 +0,0 @@
namespace AdventOfCode2022
open System
open System.Collections.Generic
open FSharp.Collections.ParallelSeq
#if DEBUG
open Checked
#else
#nowarn "9"
#endif
[<RequireQualifiedAccess>]
module Day17 =
/// Returns the nodes, and also the "AA" node.
let parse (line : string) : Direction array =
Array.init
line.Length
(fun i ->
match line.[i] with
| '<' -> Direction.Left
| '>' -> Direction.Right
| c -> failwithf "unexpected char %c" c
)
let printGrid (arr : Arr2D<int>) (currentTop : int) =
for row in currentTop - 4 .. arr.Height - 1 do
for col = 0 to 6 do
match Arr2D.get arr col row with
| 0 -> printf "."
| 1 -> printf "@"
| 2 -> printf "#"
| _ -> failwith "oh no"
printfn ""
printfn "--------------------"
let towerHeight (maxPossibleHeight : int) (grid : Arr2D<_>) =
let mutable towerHeight = 0
let mutable stillLooking = true
while stillLooking do
let row = maxPossibleHeight - towerHeight - 1
let mutable anyOn = false
for col = 0 to 6 do
if Arr2D.get grid col row <> 0 then
anyOn <- true
if not anyOn then
stillLooking <- false
else
towerHeight <- towerHeight + 1
towerHeight
let introduceRock (shape : bool[][]) startGrid currentBase =
for row = shape.Length - 1 downto 0 do
for col = 0 to shape.[0].Length - 1 do
if shape.[row].[col] then
let x = 2 + col
let y = currentBase + row - shape.Length + 1
Arr2D.set startGrid x y 1
let inline moveJet (direction : Direction) (currentBase : int) (startGrid : Arr2D<int>) : unit =
match direction with
| Direction.Left ->
let mutable canMove = true
let mutable row = currentBase
while row >= currentBase - 3 && canMove do
if Arr2D.get startGrid 0 row = 1 then
canMove <- false
else
for col = 1 to 6 do
if Arr2D.get startGrid col row = 1 && Arr2D.get startGrid (col - 1) row = 2 then
canMove <- false
row <- row - 1
if canMove then
for row = currentBase downto currentBase - 3 do
for col = 0 to 5 do
if Arr2D.get startGrid (col + 1) row = 1 then
Arr2D.set startGrid col row 1
Arr2D.set startGrid (col + 1) row 0
if Arr2D.get startGrid 6 row = 1 then
Arr2D.set startGrid 6 row 0
| Direction.Right ->
let mutable canMove = true
let mutable row = currentBase
while row >= currentBase - 3 && canMove do
if Arr2D.get startGrid 6 row = 1 then
canMove <- false
else
for col = 0 to 5 do
if Arr2D.get startGrid col row = 1 && Arr2D.get startGrid (col + 1) row = 2 then
canMove <- false
row <- row - 1
if canMove then
for row = currentBase downto currentBase - 3 do
for col = 6 downto 1 do
if Arr2D.get startGrid (col - 1) row = 1 then
Arr2D.set startGrid col row 1
Arr2D.set startGrid (col - 1) row 0
if Arr2D.get startGrid 1 row = 1 then
Arr2D.set startGrid 0 row 0
| _ -> failwith "Unexpected direction"
/// Returns the new currentBase if we're still falling, or -1 if we're not
/// still falling. (Allocation of a ValueNone was actually nontrivially slow!)
let fallOnce (currentBase : int) (startGrid : Arr2D<int>) : int =
let mutable isFalling = true
// Fall one place. Can we fall?
if currentBase = startGrid.Height - 1 then
isFalling <- false
else
for row = currentBase downto currentBase - 3 do
for col = 0 to 6 do
if Arr2D.get startGrid col row = 1 && Arr2D.get startGrid col (row + 1) = 2 then
isFalling <- false
if isFalling then
for row = currentBase downto currentBase - 3 do
for col = 0 to 6 do
if Arr2D.get startGrid col row = 1 then
Arr2D.set startGrid col (row + 1) 1
Arr2D.set startGrid col row 0
currentBase + 1
else
for row = currentBase downto currentBase - 3 do
for col = 0 to 6 do
if Arr2D.get startGrid col row = 1 then
// Freeze in place
Arr2D.set startGrid col row 2
-1
let findCurrentTop (currentTop : int) (startGrid : Arr2D<int>) : int =
let mutable currentTop = currentTop
for row = currentTop - 1 downto currentTop - 4 do
for col = 0 to 6 do
if Arr2D.get startGrid col row = 2 then
currentTop <- row
currentTop
let shapes =
[|
[| [| true ; true ; true ; true |] |]
[|
[| false ; true ; false |]
[| true ; true ; true |]
[| false ; true ; false |]
|]
[|
[| false ; false ; true |]
[| false ; false ; true |]
[| true ; true ; true |]
|]
Array.init 4 (fun _ -> [| true |])
Array.init 2 (fun _ -> [| true ; true |])
|]
let part1 (line : string) : int =
let directions = parse line
let maxPossibleHeight =
shapes
|> Array.map Array.length // if each shape stacked perfectly on top
|> Array.sum
|> fun i -> i * (2022 / 5 + 1)
#if DEBUG
let startGrid = Arr2D.zeroCreate<int> 7 maxPossibleHeight
#else
let startGridBacking = Array.zeroCreate (7 * maxPossibleHeight)
use ptr = fixed startGridBacking
let startGrid = Arr2D.zeroCreate<int> ptr 7 maxPossibleHeight
#endif
let mutable currentTop = maxPossibleHeight
let mutable jetCount = 0
for count = 0 to 2022 - 1 do
let shape = shapes.[count % shapes.Length]
let mutable currentBase = currentTop - 4
introduceRock shape startGrid currentBase
// Set it falling
let mutable isFalling = true
while isFalling do
// Move by jet.
moveJet directions.[jetCount % directions.Length] currentBase startGrid
jetCount <- (jetCount + 1) % directions.Length
match fallOnce currentBase startGrid with
| -1 -> isFalling <- false
| newCurrentBase -> currentBase <- newCurrentBase
// Set new currentTop
currentTop <- findCurrentTop currentTop startGrid
towerHeight maxPossibleHeight startGrid
let part2 (line : string) : int64 =
let directions = parse line
let maxPossibleHeight =
shapes
|> Array.map Array.length // if each shape stacked perfectly on top
|> Array.sum
// Massive overkill but :shrug:
|> fun i -> i * (100000 / 5 + 1)
#if DEBUG
let startGrid = Arr2D.zeroCreate<int> 7 maxPossibleHeight
#else
let startGridBacking = Array.zeroCreate (7 * maxPossibleHeight)
use ptr = fixed startGridBacking
let startGrid = Arr2D.zeroCreate<int> ptr 7 maxPossibleHeight
#endif
let mutable currentTop = maxPossibleHeight
let mutable shapeCount = 0
let mutable jetCount = directions.Length
let seenJetCounts = HashSet ()
let mutable fromLastCycle = ValueNone
let mutable skippedFromCycle = -1L
let limit = 1000000000000L
let mutable remainingStones = limit
while remainingStones > 0 do
for count = 0 to shapes.Length - 1 do
shapeCount <- shapeCount + 1
remainingStones <- remainingStones - 1L
let shape = shapes.[count]
let mutable currentBase = currentTop - 4
introduceRock shape startGrid currentBase
// Set it falling
let mutable isFalling = true
while isFalling do
// Move by jet.
moveJet directions.[jetCount % directions.Length] currentBase startGrid
jetCount <- (jetCount + 1) % directions.Length
match fallOnce currentBase startGrid with
| -1 -> isFalling <- false
| newCurrentBase -> currentBase <- newCurrentBase
// Set new currentTop
currentTop <- findCurrentTop currentTop startGrid
// Try and find a duplicate.
if not (seenJetCounts.Add jetCount) then
match fromLastCycle with
| ValueNone ->
let towerHeight = towerHeight maxPossibleHeight startGrid
seenJetCounts.Clear ()
seenJetCounts.Add jetCount |> ignore
fromLastCycle <- ValueSome (shapeCount, towerHeight)
| ValueSome (prevShapeCount, prevTowerHeight) ->
let towerHeight = towerHeight maxPossibleHeight startGrid
let heightGainedPerCycle = towerHeight - prevTowerHeight
let piecesPerCycle = shapeCount - prevShapeCount
let remainingCycles = (limit - int64 shapeCount) / int64 piecesPerCycle
skippedFromCycle <- remainingCycles * int64 heightGainedPerCycle
remainingStones <- (limit - int64 shapeCount) % int64 piecesPerCycle
seenJetCounts.Clear ()
let towerHeight = towerHeight maxPossibleHeight startGrid
int64 towerHeight + skippedFromCycle

View File

@@ -1,194 +0,0 @@
namespace AdventOfCode2022
open System
#if DEBUG
open Checked
#else
#nowarn "9"
#endif
[<RequireQualifiedAccess>]
module Day18 =
/// Returns the points, and also minX, minY, minZ, maxX, maxY, maxZ.
let parse
(line : StringSplitEnumerator)
: struct (int * int * int) ResizeArray * int * int * int * int * int * int
=
use mutable enum = line.GetEnumerator ()
let output = ResizeArray ()
let mutable minX = Int32.MaxValue
let mutable minY = Int32.MaxValue
let mutable minZ = Int32.MaxValue
let mutable maxX = Int32.MinValue
let mutable maxY = Int32.MinValue
let mutable maxZ = Int32.MinValue
while enum.MoveNext () do
if not (enum.Current.IsWhiteSpace ()) then
let mutable split = StringSplitEnumerator.make' ',' enum.Current
let x = StringSplitEnumerator.consumeInt &split
if x < minX then
minX <- x
if x > maxX then
maxX <- x
let y = StringSplitEnumerator.consumeInt &split
if y < minY then
minY <- y
if y > maxY then
maxY <- y
let z = StringSplitEnumerator.consumeInt &split
if z < minZ then
minZ <- z
if z > maxZ then
maxZ <- z
assert (not (split.MoveNext ()))
output.Add (struct (x, y, z))
output, minX, minY, minZ, maxX, maxY, maxZ
let inline private doPart1
(cubes : ResizeArray<_>)
(arr : Arr3D<int>)
(minX : int)
(minY : int)
(minZ : int)
maxX
maxY
maxZ
=
let mutable exposedFaces = 0
let maxX = maxX - minX
let maxY = maxY - minY
let maxZ = maxZ - minZ
for i = 0 to cubes.Count - 1 do
let struct (x, y, z) = cubes.[i]
let x = x - minX
let y = y - minY
let z = z - minZ
if not (x > 0 && Arr3D.get arr (x - 1) y z = 1) then
exposedFaces <- exposedFaces + 1
if not (x < maxX && Arr3D.get arr (x + 1) y z = 1) then
exposedFaces <- exposedFaces + 1
if not (y > 0 && Arr3D.get arr x (y - 1) z = 1) then
exposedFaces <- exposedFaces + 1
if not (y < maxY && Arr3D.get arr x (y + 1) z = 1) then
exposedFaces <- exposedFaces + 1
if not (z > 0 && Arr3D.get arr x y (z - 1) = 1) then
exposedFaces <- exposedFaces + 1
if not (z < maxZ && Arr3D.get arr x y (z + 1) = 1) then
exposedFaces <- exposedFaces + 1
exposedFaces
let part1 (line : StringSplitEnumerator) : int =
let cubes, minX, minY, minZ, maxX, maxY, maxZ = parse line
let xSpan = maxX - minX + 1
let ySpan = maxY - minY + 1
let zSpan = maxZ - minZ + 1
#if DEBUG
let arr = Arr3D.zeroCreate<int> xSpan ySpan zSpan
#else
let backing = Array.zeroCreate<int> (xSpan * ySpan * zSpan)
use ptr = fixed backing
let arr = Arr3D.zeroCreate<int> ptr xSpan ySpan zSpan
#endif
for i = 0 to cubes.Count - 1 do
let struct (x, y, z) = cubes.[i]
Arr3D.set arr (x - minX) (y - minY) (z - minZ) 1
doPart1 cubes arr minX minY minZ maxX maxY maxZ
// Semantics:
// 3 means "in progress",
// 2 means "this definitely flood fills to the outside",
// 1 means "definitely full",
// 0 means "initially empty",
let floodFill (arr : Arr3D<int>) maxX maxY maxZ (x : int) (y : int) (z : int) : unit =
/// Returns true if it hits the outside.
let rec go (x : int) (y : int) (z : int) : bool =
let mutable hitsOutside = false
match Arr3D.get arr x y z with
| 0 ->
Arr3D.set arr x y z 3
hitsOutside <- hitsOutside || (if x > 0 then go (x - 1) y z else true)
hitsOutside <- hitsOutside || (if y > 0 then go x (y - 1) z else true)
hitsOutside <- hitsOutside || (if z > 0 then go x y (z - 1) else true)
hitsOutside <- hitsOutside || (if x < maxX then go (x + 1) y z else true)
hitsOutside <- hitsOutside || (if y < maxY then go x (y + 1) z else true)
hitsOutside <- hitsOutside || (if z < maxZ then go x y (z + 1) else true)
| 2 -> hitsOutside <- true
| _ -> ()
hitsOutside
if go x y z then
// Convert all our "in progress" to "flood fills to outside".
for z = 0 to maxZ do
for y = 0 to maxY do
for x = 0 to maxX do
if Arr3D.get arr x y z = 3 then
Arr3D.set arr x y z 2
else
// Convert all our "in progress" to "does not flood fill to outside".
for z = 0 to maxZ do
for y = 0 to maxY do
for x = 0 to maxX do
if Arr3D.get arr x y z = 3 then
Arr3D.set arr x y z 1
let part2 (line : StringSplitEnumerator) : int =
let cubes, minX, minY, minZ, maxX, maxY, maxZ = parse line
let xSpan = maxX - minX + 1
let ySpan = maxY - minY + 1
let zSpan = maxZ - minZ + 1
#if DEBUG
let arr = Arr3D.zeroCreate<int> xSpan ySpan zSpan
#else
let backing = Array.zeroCreate<int> (xSpan * ySpan * zSpan)
use ptr = fixed backing
let arr = Arr3D.zeroCreate<int> ptr xSpan ySpan zSpan
#endif
for i = 0 to cubes.Count - 1 do
let struct (x, y, z) = cubes.[i]
Arr3D.set arr (x - minX) (y - minY) (z - minZ) 1
// Flood-fill the internals.
for z = 0 to maxZ - minZ do
for y = 0 to maxY - minY do
for x = 0 to maxX - minX do
floodFill arr (maxX - minX) (maxY - minY) (maxZ - minZ) x y z
doPart1 cubes arr minX minY minZ maxX maxY maxZ

View File

@@ -1,256 +0,0 @@
namespace AdventOfCode2022
open System
open FSharp.Collections.ParallelSeq
#if DEBUG
open Checked
#else
#nowarn "9"
#endif
type Day19Blueprint =
{
Index : int
Ore : int
Clay : int
ObsidianOre : int
ObsidianClay : int
GeodeOre : int
GeodeObsidian : int
}
[<RequireQualifiedAccess>]
module Day19 =
//Blueprint 1: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 8 clay. Each geode robot costs 2 ore and 18 obsidian.
let parse (line : StringSplitEnumerator) : Day19Blueprint ResizeArray =
use mutable enum = line.GetEnumerator ()
let output = ResizeArray ()
while enum.MoveNext () do
if not (enum.Current.IsWhiteSpace ()) then
let mutable lineEnum = StringSplitEnumerator.make' ' ' (enum.Current.TrimEnd ())
StringSplitEnumerator.chomp "Blueprint" &lineEnum
if not (lineEnum.MoveNext ()) then
failwith "expected number"
let index = Int32.Parse (lineEnum.Current.TrimEnd ':')
StringSplitEnumerator.chomp "Each" &lineEnum
StringSplitEnumerator.chomp "ore" &lineEnum
StringSplitEnumerator.chomp "robot" &lineEnum
StringSplitEnumerator.chomp "costs" &lineEnum
let oreCost = StringSplitEnumerator.consumeInt &lineEnum
StringSplitEnumerator.chomp "ore." &lineEnum
StringSplitEnumerator.chomp "Each" &lineEnum
StringSplitEnumerator.chomp "clay" &lineEnum
StringSplitEnumerator.chomp "robot" &lineEnum
StringSplitEnumerator.chomp "costs" &lineEnum
let clayCost = StringSplitEnumerator.consumeInt &lineEnum
StringSplitEnumerator.chomp "ore." &lineEnum
StringSplitEnumerator.chomp "Each" &lineEnum
StringSplitEnumerator.chomp "obsidian" &lineEnum
StringSplitEnumerator.chomp "robot" &lineEnum
StringSplitEnumerator.chomp "costs" &lineEnum
let obsidianOreCost = StringSplitEnumerator.consumeInt &lineEnum
StringSplitEnumerator.chomp "ore" &lineEnum
StringSplitEnumerator.chomp "and" &lineEnum
let obsidianClayCost = StringSplitEnumerator.consumeInt &lineEnum
StringSplitEnumerator.chomp "clay." &lineEnum
StringSplitEnumerator.chomp "Each" &lineEnum
StringSplitEnumerator.chomp "geode" &lineEnum
StringSplitEnumerator.chomp "robot" &lineEnum
StringSplitEnumerator.chomp "costs" &lineEnum
let geodeOreCost = StringSplitEnumerator.consumeInt &lineEnum
StringSplitEnumerator.chomp "ore" &lineEnum
StringSplitEnumerator.chomp "and" &lineEnum
let geodeObsidianCost = StringSplitEnumerator.consumeInt &lineEnum
StringSplitEnumerator.chomp "obsidian." &lineEnum
{
Ore = oreCost
Clay = clayCost
ObsidianOre = obsidianOreCost
ObsidianClay = obsidianClayCost
GeodeOre = geodeOreCost
GeodeObsidian = geodeObsidianCost
Index = index
}
|> output.Add
output
/// If we started only creating new geode creators right now, how many geodes could we
/// mine by the end?
let inline bestPossible (timeRemaining : int) = timeRemaining * (timeRemaining - 1) / 2
let rec go
(blueprint : Day19Blueprint)
(bestSoFar : int)
(timeRemaining : int)
(oreCount : int)
(clayCount : int)
(obsidianCount : int)
(geodeCount : int)
(oreRobotCount : int)
(clayRobotCount : int)
(obsidianRobotCount : int)
=
if timeRemaining = 1 then
max bestSoFar geodeCount
else
// A weak overestimate at how many more geodes we'd get if we started building geode
// producers and nothing else, right now.
let bestPossible =
let neededBeforeGeodeBuild = blueprint.GeodeObsidian - obsidianCount
if neededBeforeGeodeBuild <= 0 then
timeRemaining
elif neededBeforeGeodeBuild <= obsidianRobotCount then
// Wait one timestep, then build
timeRemaining - 1
elif neededBeforeGeodeBuild <= 2 * obsidianRobotCount + 1 then
// Build an obsidian robot, then wait one timestep, then build geodes
timeRemaining - 2
else
timeRemaining - 3
|> bestPossible
if bestSoFar > geodeCount + bestPossible then
bestSoFar
else
let newOreCount = oreCount + oreRobotCount
let newClayCount = clayCount + clayRobotCount
let newObsidianCount = obsidianCount + obsidianRobotCount
let mutable best = bestSoFar
// If there are fewer than 10 turns remaining, it's always correct to create a geode
// builder if we can. Indeed, ore is not the limiting factor, so if we instead chose
// to make an obsidian builder, we'd lose 1 geode of opportunity cost, and then
// would have to wait at least 7 turns for the new obsidian builder to produce enough
// obsidian to make a replacement geode builder, then build the new geode builder on
// the 8th turn, then it produces a replacement geode on the 9th turn, breaking even.
if
timeRemaining < 10
&& oreCount >= blueprint.GeodeOre
&& obsidianCount >= blueprint.GeodeObsidian
then
go
blueprint
best
(timeRemaining - 1)
(newOreCount - blueprint.GeodeOre)
newClayCount
(newObsidianCount - blueprint.GeodeObsidian)
(geodeCount + timeRemaining - 1)
oreRobotCount
clayRobotCount
obsidianRobotCount
else
if oreCount >= blueprint.GeodeOre && obsidianCount >= blueprint.GeodeObsidian then
best <-
go
blueprint
best
(timeRemaining - 1)
(newOreCount - blueprint.GeodeOre)
newClayCount
(newObsidianCount - blueprint.GeodeObsidian)
(geodeCount + timeRemaining - 1)
oreRobotCount
clayRobotCount
obsidianRobotCount
// Can we build an obsidian robot?
// Note that if we have enough obsidian robots, then we're producing it as fast as we can consume it.
if
obsidianRobotCount < blueprint.GeodeObsidian
&& oreCount >= blueprint.ObsidianOre
&& clayCount >= blueprint.ObsidianClay
then
best <-
go
blueprint
best
(timeRemaining - 1)
(newOreCount - blueprint.ObsidianOre)
(newClayCount - blueprint.ObsidianClay)
newObsidianCount
geodeCount
oreRobotCount
clayRobotCount
(obsidianRobotCount + 1)
// Can we build an ore robot?
// Note that the biggest ore cost of anything is 4 ore, so if we have 4 ore-collecting robots then we
// are already producing ore as fast as we can consume it.
if oreRobotCount < 4 && oreCount >= blueprint.Ore then
best <-
go
blueprint
best
(timeRemaining - 1)
(newOreCount - blueprint.Ore)
newClayCount
newObsidianCount
geodeCount
(oreRobotCount + 1)
clayRobotCount
obsidianRobotCount
// Can we build a clay robot?
if clayRobotCount < blueprint.ObsidianClay && oreCount >= blueprint.Clay then
best <-
go
blueprint
best
(timeRemaining - 1)
(newOreCount - blueprint.Clay)
newClayCount
newObsidianCount
geodeCount
oreRobotCount
(clayRobotCount + 1)
obsidianRobotCount
go
blueprint
best
(timeRemaining - 1)
newOreCount
newClayCount
newObsidianCount
geodeCount
oreRobotCount
clayRobotCount
obsidianRobotCount
let doPart1 (blueprint : Day19Blueprint) : int =
let minOreCost = min blueprint.Ore blueprint.Clay
go blueprint 0 (24 - minOreCost) minOreCost 0 0 0 1 0 0
let part1 (line : StringSplitEnumerator) : int =
let blueprints = parse line
seq { 0 .. blueprints.Count - 1 }
|> PSeq.map (fun i -> blueprints.[i].Index * doPart1 blueprints.[i])
|> Seq.sum
let doPart2 (blueprint : Day19Blueprint) : int =
let minOreCost = min blueprint.Ore blueprint.Clay
go blueprint 0 (32 - minOreCost) minOreCost 0 0 0 1 0 0
let part2 (line : StringSplitEnumerator) : int =
let blueprints = parse line
let blueprints = Array.init (min blueprints.Count 3) (fun i -> blueprints.[i])
blueprints :> seq<_> |> PSeq.map doPart2 |> Seq.fold (*) 1

View File

@@ -1,96 +0,0 @@
namespace AdventOfCode2022
open System
#if DEBUG
open Checked
#else
#nowarn "9"
#endif
[<RequireQualifiedAccess>]
module Day20 =
let parse (line : StringSplitEnumerator) : int[] =
use mutable enum = line.GetEnumerator ()
let output = ResizeArray ()
while enum.MoveNext () do
if not (enum.Current.IsWhiteSpace ()) then
output.Add (Int32.Parse enum.Current)
output.ToArray ()
let inline clone< ^T when ^T : struct> (arr : ^T[]) : ^T[] =
let newArr = Array.zeroCreate arr.Length
Buffer.BlockCopy (arr, 0, newArr, 0, arr.Length * sizeof< ^T>)
newArr
let inline swapDown< ^T> (arr : 'T[]) (smaller : int) (bigger : int) : unit =
let tmp = arr.[smaller]
for j = smaller to bigger - 1 do
arr.[j] <- arr.[j + 1]
arr.[bigger] <- tmp
let inline swapUp< ^T> (arr : 'T[]) (bigger : int) (smaller : int) : unit =
let tmp = arr.[bigger]
for j = bigger downto smaller + 1 do
arr.[j] <- arr.[j - 1]
arr.[smaller] <- tmp
let inline performPart1Round (original : int[]) (currentValues : int[]) (currentLayout : int[]) =
for i in 0 .. original.Length - 1 do
let currentLocation = Array.IndexOf<_> (currentLayout, i, 0, currentLayout.Length)
let modulus = currentLayout.Length - 1
let moveBy = ((original.[i] % modulus) + modulus) % modulus
let newPos = (currentLocation + moveBy) % modulus
if newPos > currentLocation then
swapDown currentValues currentLocation newPos
swapDown currentLayout currentLocation newPos
elif newPos <> currentLocation then
swapUp currentValues currentLocation newPos
swapUp currentLayout currentLocation newPos
let part1 (lines : StringSplitEnumerator) : int =
let original = parse lines
let currentValues = clone original
let currentLayout = Array.init original.Length id
performPart1Round original currentValues currentLayout
let zeroIndex = Array.IndexOf<_> (currentValues, 0)
currentValues.[(zeroIndex + 1000) % currentValues.Length]
+ currentValues.[(zeroIndex + 2000) % currentValues.Length]
+ currentValues.[(zeroIndex + 3000) % currentValues.Length]
let part2 (lines : StringSplitEnumerator) : int64 =
let key = 811589153
let original = parse lines
let modded = original |> Array.map (fun i -> (key % (original.Length - 1)) * i)
let currentValues = clone modded
let currentLayout = Array.init modded.Length id
for _ = 1 to 10 do
performPart1Round modded currentValues currentLayout
let zeroIndex = Array.IndexOf<_> (currentValues, 0)
let result =
let first = currentLayout.[(zeroIndex + 1000) % currentLayout.Length]
let second = currentLayout.[(zeroIndex + 2000) % currentLayout.Length]
let third = currentLayout.[(zeroIndex + 3000) % currentLayout.Length]
original.[first] + original.[second] + original.[third]
int64 result * int64 key

View File

@@ -1,206 +0,0 @@
namespace AdventOfCode2022
open System
open System.Collections.Generic
#if DEBUG
open Checked
#else
#nowarn "9"
#endif
[<RequireQualifiedAccess>]
module Day21 =
type Day21Operation =
| Add = 0
| Times = 1
| Divide = 2
| Minus = 3
let inline parseOp (c : char) =
match c with
| '+' -> Day21Operation.Add
| '*' -> Day21Operation.Times
| '/' -> Day21Operation.Divide
| '-' -> Day21Operation.Minus
| _ -> failwithf "bad op char: %c" c
type Day21Name = string
type Day21Input =
| Literal of int
| Operation of Day21Name * Day21Name * Day21Operation
/// Returns the name of the root node and human node, too.
let parse (line : StringSplitEnumerator) : Dictionary<Day21Name, Day21Input> * Day21Name * Day21Name =
use mutable enum = line.GetEnumerator ()
let output = Dictionary ()
while enum.MoveNext () do
if not (enum.Current.IsWhiteSpace ()) then
let colon = enum.Current.IndexOf ':'
let name = enum.Current.Slice(0, colon).ToString ()
let rhs = enum.Current.Slice(colon + 2).TrimEnd ()
let expr =
match Int32.TryParse rhs with
| true, v -> Day21Input.Literal v
| false, _ ->
let space1 = rhs.IndexOf ' '
let space2 = rhs.LastIndexOf ' '
let s1 = rhs.Slice(0, space1).ToString ()
let op =
let op = rhs.Slice (space1 + 1, space2 - space1 - 1)
if op.Length <> 1 then
failwithf "Expected exactly one char for op, got %i" op.Length
parseOp op.[0]
let s2 = rhs.Slice(space2 + 1).ToString ()
Day21Input.Operation (s1, s2, op)
output.Add (name, expr)
output, "root", "humn"
let inline compute (v1 : float) (v2 : float) (op : Day21Operation) : float =
match op with
| Day21Operation.Add -> v1 + v2
| Day21Operation.Times -> v1 * v2
| Day21Operation.Minus -> v1 - v2
| Day21Operation.Divide -> v1 / v2
| _ -> failwith "bad enum"
let rec evaluate
(calculated : Dictionary<Day21Name, float>)
(d : Dictionary<Day21Name, Day21Input>)
(s : Day21Name)
: float
=
match calculated.TryGetValue s with
| true, v -> v
| false, _ ->
match d.[s] with
| Day21Input.Literal v ->
let result = float v
calculated.[s] <- result
result
| Day21Input.Operation (s1, s2, op) ->
let v1 = evaluate calculated d s1
let v2 = evaluate calculated d s2
let result = compute v1 v2 op
calculated.[s] <- result
result
let inline round (v : float) : int64 =
let rounded = int64 v
if abs (float rounded - v) > 0.00000001 then
failwith "not an int"
rounded
let part1 (lines : StringSplitEnumerator) : int64 =
let original, root, _ = parse lines
let calculated = Dictionary original.Count
let result = evaluate calculated original root
round result
type Day21Expr =
| Literal of float
| Variable
| Calc of Day21Expr * Day21Expr * Day21Operation
let rec convert
(human : Day21Name)
(key : Day21Name)
(d : Dictionary<Day21Name, Day21Input>)
(result : Dictionary<Day21Name, Day21Expr>)
: Day21Expr
=
match result.TryGetValue key with
| true, v -> v
| false, _ ->
if key = human then
let answer = Day21Expr.Variable
result.[human] <- answer
answer
else
match d.[key] with
| Day21Input.Literal v ->
let answer = Day21Expr.Literal (float v)
result.[key] <- answer
answer
| Day21Input.Operation (s1, s2, op) ->
let v1 = convert human s1 d result
let v2 = convert human s2 d result
// One wave of simplification
let answer =
match v1, v2 with
| Day21Expr.Literal l1, Day21Expr.Literal l2 -> Day21Expr.Literal (compute l1 l2 op)
| _, _ -> Day21Expr.Calc (v1, v2, op)
result.[key] <- answer
answer
let part2 (lines : StringSplitEnumerator) : int64 =
let original, root, human = parse lines
let lhs, rhs =
match original.[root] with
| Day21Input.Literal _ -> failwith "expected operation"
| Day21Input.Operation (s1, s2, _) -> s1, s2
let converted = Dictionary original.Count
let mutable lhs = convert human lhs original converted
let mutable rhs = convert human rhs original converted
let mutable answer = nan
while Double.IsNaN answer do
match lhs, rhs with
| Day21Expr.Literal l, Day21Expr.Variable
| Day21Expr.Variable, Day21Expr.Literal l -> answer <- l
| Day21Expr.Literal l, Day21Expr.Calc (v1, v2, op)
| Day21Expr.Calc (v1, v2, op), Day21Expr.Literal l ->
match v1, v2 with
| v1, Day21Expr.Literal v2 ->
lhs <- v1
rhs <-
match op with
| Day21Operation.Add -> Day21Expr.Literal (l - v2)
| Day21Operation.Times -> Day21Expr.Literal (l / v2)
| Day21Operation.Divide -> Day21Expr.Literal (l * v2)
| Day21Operation.Minus -> Day21Expr.Literal (l + v2)
| _ -> failwith "bad op"
| Day21Expr.Literal v1, v2 ->
lhs <- v2
rhs <-
match op with
| Day21Operation.Add -> Day21Expr.Literal (l - v1)
| Day21Operation.Times -> Day21Expr.Literal (l / v1)
| Day21Operation.Divide -> Day21Expr.Literal (v1 / l)
| Day21Operation.Minus -> Day21Expr.Literal (v1 - l)
| _ -> failwith "bad op"
| _, _ -> failwith "problem is too hard: had variables on both sides"
| Day21Expr.Variable, Day21Expr.Variable
| Day21Expr.Variable, Day21Expr.Calc _
| Day21Expr.Calc _, Day21Expr.Calc _
| Day21Expr.Calc _, Day21Expr.Variable -> failwith "one side is always a literal"
| Day21Expr.Literal _, Day21Expr.Literal _ -> failwith "can't both be literals"
round answer

View File

@@ -1,550 +0,0 @@
namespace AdventOfCode2022
open System
#if DEBUG
open Checked
#else
#nowarn "9"
#endif
[<RequireQualifiedAccess>]
module Day22 =
/// Returns the board (where 0 means "nothing here", 1 means "space", 2 means "wall"),
/// the set of instructions (move * change-direction), and the final trailing instruction to move.
let parse (line : StringSplitEnumerator) : int[][] * ResizeArray<struct (int * Direction)> * int =
use mutable enum = line.GetEnumerator ()
let output = ResizeArray ()
let mutable maxBoardLength = 0
let row = ResizeArray ()
// 2 here in case there's a trailing \r
while enum.MoveNext () && enum.Current.Length >= 2 do
for i = 0 to enum.Current.Length - 1 do
match enum.Current.[i] with
| ' ' -> row.Add 0
| '.' -> row.Add 1
| '#' -> row.Add 2
| '\r' -> ()
| c -> failwithf "unexpected char: %c" c
output.Add (row.ToArray ())
maxBoardLength <- max maxBoardLength row.Count
row.Clear ()
if not (enum.MoveNext ()) then
failwith "expected instruction line"
let directions = ResizeArray ()
let line = enum.Current.TrimEnd ()
let mutable i = 0
for count = 0 to line.Length - 1 do
if '0' <= line.[count] && line.[count] <= '9' then
i <- i * 10 + (int line.[count] - int '0')
else
let dir =
match line.[count] with
| 'L' -> Direction.Left
| 'R' -> Direction.Right
| c -> failwithf "Unexpected: %c" c
directions.Add (struct (i, dir))
i <- 0
let finalOutput =
Array.init
output.Count
(fun i -> Array.append output.[i] (Array.zeroCreate (maxBoardLength - output.[i].Length)))
finalOutput, directions, i
let inline rotateRight (dir : Direction) =
match dir with
| Direction.Up -> Direction.Right
| Direction.Right -> Direction.Down
| Direction.Down -> Direction.Left
| Direction.Left -> Direction.Up
| _ -> failwith "bad direction"
let inline rotateLeft (dir : Direction) =
match dir with
| Direction.Up -> Direction.Left
| Direction.Right -> Direction.Up
| Direction.Down -> Direction.Right
| Direction.Left -> Direction.Down
| _ -> failwith "bad direction"
/// Returns false if we got stuck due to a wall.
let private moveOneStep (currPos : MutableCoordinate) (direction : Direction) (board : int[][]) : bool =
let answer =
{
MutableCoordinate.X = currPos.X
MutableCoordinate.Y = currPos.Y
}
match direction with
| Direction.Up ->
if answer.Y = 0 then
answer.Y <- board.Length - 1
else
answer.Y <- answer.Y - 1
while board.[answer.Y].[answer.X] = 0 do
if answer.Y = 0 then
answer.Y <- board.Length - 1
else
answer.Y <- answer.Y - 1
| Direction.Down ->
if answer.Y = board.Length - 1 then
answer.Y <- 0
else
answer.Y <- answer.Y + 1
while board.[answer.Y].[answer.X] = 0 do
if answer.Y = board.Length - 1 then
answer.Y <- 0
else
answer.Y <- answer.Y + 1
| Direction.Left ->
if answer.X = 0 then
answer.X <- board.[0].Length - 1
else
answer.X <- answer.X - 1
while board.[answer.Y].[answer.X] = 0 do
if answer.X = 0 then
answer.X <- board.[0].Length - 1
else
answer.X <- answer.X - 1
| Direction.Right ->
if answer.X = board.[0].Length - 1 then
answer.X <- 0
else
answer.X <- answer.X + 1
while board.[answer.Y].[answer.X] = 0 do
if answer.X = board.[0].Length - 1 then
answer.X <- 0
else
answer.X <- answer.X + 1
| _ -> failwith "noooo"
if board.[answer.Y].[answer.X] <> 2 then
currPos.X <- answer.X
currPos.Y <- answer.Y
true
else
false
let moveDistance (currPos : MutableCoordinate) (direction : Direction) (distance : int) (board : int[][]) : unit =
let mutable i = 0
let mutable keepGoing = true
while keepGoing && i < distance do
keepGoing <- moveOneStep currPos direction board
i <- i + 1
let inline answer (position : Coordinate) (direction : Direction) =
let finalFacing =
match direction with
| Direction.Right -> 0
| Direction.Down -> 1
| Direction.Left -> 2
| Direction.Up -> 3
| _ -> failwith "oh no"
1000 * (position.Y + 1) + 4 * (position.X + 1) + finalFacing
let part1 (lines : StringSplitEnumerator) : int =
let board, instructions, finalDistance = parse lines
let position =
{
MutableCoordinate.Y = 0
MutableCoordinate.X = Array.IndexOf (board.[0], 1)
}
let mutable direction = Direction.Right
for struct (distance, rotation) in instructions do
moveDistance position direction distance board
direction <-
match rotation with
| Direction.Right -> rotateRight direction
| Direction.Left -> rotateLeft direction
| _ -> failwith "bad rotation"
moveDistance position direction finalDistance board
answer
{
X = position.X
Y = position.Y
}
direction
/// If we walk off the given number of face in the given direction, where do we end up?
/// Returns an additional "true" if we need to interchange Y and X.
let newFaceOnExample
(cubeSize : int)
(face : int)
(direction : Direction)
: int * Direction * (struct (int * int) -> struct (int * int))
=
match face, direction with
| 1, Direction.Up -> 2, Direction.Down, (fun (struct (x, y)) -> struct (cubeSize - x - 1, 0))
| 1, Direction.Down -> 4, Direction.Down, (fun (struct (x, _)) -> struct (x, 0))
| 1, Direction.Left -> 3, Direction.Down, (fun (struct (_, y)) -> struct (y, 0))
| 1, Direction.Right -> 6, Direction.Left, (fun (struct (x, y)) -> struct (cubeSize - 1, cubeSize - y - 1))
| 2, Direction.Up -> 1, Direction.Down, (fun (struct (x, y)) -> struct (cubeSize - x - 1, 0))
| 2, Direction.Down -> 5, Direction.Up, (fun (struct (x, y)) -> struct (cubeSize - x - 1, cubeSize - 1))
| 2, Direction.Left -> 6, Direction.Up, (fun (struct (_, y)) -> struct (cubeSize - y - 1, cubeSize - 1))
| 2, Direction.Right -> 3, Direction.Right, (fun (struct (x, y)) -> struct (0, y))
| 3, Direction.Up -> 1, Direction.Right, (fun (struct (x, y)) -> struct (0, x))
| 3, Direction.Down -> 5, Direction.Right, (fun (struct (x, y)) -> struct (0, cubeSize - 1 - y))
| 3, Direction.Left -> 2, Direction.Left, (fun (struct (x, y)) -> struct (cubeSize - 1, y))
| 3, Direction.Right -> 4, Direction.Right, (fun (struct (x, y)) -> struct (0, y))
| 4, Direction.Up -> 1, Direction.Up, (fun (struct (x, _)) -> struct (x, cubeSize - 1))
| 4, Direction.Down -> 5, Direction.Down, (fun (struct (x, _)) -> struct (x, 0))
| 4, Direction.Left -> 3, Direction.Left, (fun (struct (x, _)) -> struct (x, cubeSize - 1))
| 4, Direction.Right -> 6, Direction.Down, (fun (struct (_, y)) -> struct (cubeSize - 1 - y, 0))
| 5, Direction.Up -> 4, Direction.Up, (fun (struct (x, y)) -> struct (x, cubeSize - 1))
| 5, Direction.Down -> 2, Direction.Up, (fun (struct (x, y)) -> struct (cubeSize - x - 1, cubeSize - 1))
| 5, Direction.Left -> 3, Direction.Up, (fun (struct (x, y)) -> struct (cubeSize - y - 1, cubeSize - 1))
| 5, Direction.Right -> 6, Direction.Right, (fun (struct (x, y)) -> struct (0, y))
| 6, Direction.Up -> 4, Direction.Left, (fun (struct (x, y)) -> struct (cubeSize - 1, cubeSize - x - 1))
| 6, Direction.Down -> 2, Direction.Right, (fun (struct (x, y)) -> failwith "TODO")
| 6, Direction.Left -> 5, Direction.Left, (fun (struct (x, y)) -> struct (cubeSize - 1, y))
| 6, Direction.Right -> 1, Direction.Left, (fun (struct (x, y)) -> failwith "TODO")
| _ -> failwith "bad face"
let inline toArrayElementOnExample (faceSize : int) (face : int) (position : Coordinate) : Coordinate =
match face with
| 1 ->
{
X = position.X + 2 * faceSize
Y = position.Y
}
| 2 ->
{
X = position.X
Y = position.Y + faceSize
}
| 3 ->
{
X = position.X + faceSize
Y = position.Y + faceSize
}
| 4 ->
{
X = position.X + 2 * faceSize
Y = position.Y + faceSize
}
| 5 ->
{
X = position.X + 2 * faceSize
Y = position.Y + 2 * faceSize
}
| 6 ->
{
X = position.X + 3 * faceSize
Y = position.Y + 2 * faceSize
}
| _ -> failwith "bad face"
/// Returns false if we got stuck due to a wall.
/// The position is referring to the position within the given face.
let inline private moveOneStepCube
(cubeSize : int)
([<InlineIfLambda>] toArrayElement : int -> Coordinate -> Coordinate)
([<InlineIfLambda>] newFace : int -> Direction -> int * Direction * (struct (int * int) -> struct (int * int)))
(currFace : byref<int>)
(currPos : MutableCoordinate)
(direction : byref<Direction>)
(board : int[][])
: bool
=
// If we do walk off this face, where do we end up?
let faceAfterSpill, directionAfterSpill, transformPosition =
newFace currFace direction
let intendedDest, face, newDirection =
match direction with
| Direction.Up ->
if currPos.Y = 0 then
let struct (x, y) = transformPosition (struct (currPos.X, currPos.Y))
{
X = x
Y = y
},
faceAfterSpill,
directionAfterSpill
else
{
X = currPos.X
Y = currPos.Y - 1
},
currFace,
direction
| Direction.Down ->
if currPos.Y = cubeSize - 1 then
let struct (x, y) = transformPosition (struct (currPos.X, currPos.Y))
{
X = x
Y = y
},
faceAfterSpill,
directionAfterSpill
else
{
X = currPos.X
Y = currPos.Y + 1
},
currFace,
direction
| Direction.Left ->
if currPos.X = 0 then
let struct (x, y) = transformPosition (struct (currPos.X, currPos.Y))
{
X = x
Y = y
},
faceAfterSpill,
directionAfterSpill
else
{
X = currPos.X - 1
Y = currPos.Y
},
currFace,
direction
| Direction.Right ->
if currPos.X = cubeSize - 1 then
let struct (x, y) = transformPosition (struct (currPos.X, currPos.Y))
{
X = x
Y = y
},
faceAfterSpill,
directionAfterSpill
else
{
X = currPos.X + 1
Y = currPos.Y
},
currFace,
direction
| _ -> failwith "noooo"
let pos = toArrayElement face intendedDest
if board.[pos.Y].[pos.X] <> 2 then
currPos.X <- intendedDest.X
currPos.Y <- intendedDest.Y
currFace <- face
direction <- newDirection
true
else
false
let inline moveCubeDistance
(cubeSize : int)
([<InlineIfLambda>] toArrayElement : int -> Coordinate -> Coordinate)
([<InlineIfLambda>] newFace : int -> Direction -> int * Direction * (struct (int * int) -> struct (int * int)))
(currFace : byref<int>)
(currPos : MutableCoordinate)
(direction : byref<Direction>)
(distance : int)
(board : int[][])
: unit
=
let mutable i = 0
let mutable keepGoing = true
while keepGoing && i < distance do
keepGoing <- moveOneStepCube cubeSize toArrayElement newFace &currFace currPos &direction board
i <- i + 1
let part2Example (lines : StringSplitEnumerator) : int =
let board, instructions, finalDistance = parse lines
let faceSize = 4
let position =
{
MutableCoordinate.X = 0
MutableCoordinate.Y = 0
}
let mutable direction = Direction.Right
let mutable face = 1
for struct (distance, rotation) in instructions do
moveCubeDistance
faceSize
(toArrayElementOnExample faceSize)
(newFaceOnExample faceSize)
&face
position
&direction
distance
board
direction <-
match rotation with
| Direction.Right -> rotateRight direction
| Direction.Left -> rotateLeft direction
| _ -> failwith "bad rotation"
moveCubeDistance
faceSize
(toArrayElementOnExample faceSize)
(newFaceOnExample faceSize)
&face
position
&direction
finalDistance
board
let faceDimension = board.Length / 3
let position =
toArrayElementOnExample
faceDimension
face
{
X = position.X
Y = position.Y
}
answer position direction
// The real thing has shape:
// _12
// _3_
// 45_
// 6__
let inline toArrayElement (faceSize : int) (face : int) (position : Coordinate) : Coordinate =
match face with
| 1 ->
{
X = position.X + faceSize
Y = position.Y
}
| 2 ->
{
X = position.X + 2 * faceSize
Y = position.Y
}
| 3 ->
{
X = position.X + faceSize
Y = position.Y + faceSize
}
| 4 ->
{
X = position.X
Y = position.Y + 2 * faceSize
}
| 5 ->
{
X = position.X + faceSize
Y = position.Y + 2 * faceSize
}
| 6 ->
{
X = position.X
Y = position.Y + 3 * faceSize
}
| _ -> failwith "bad face"
let inline newFace
(cubeSize : int)
(face : int)
(direction : Direction)
: int * Direction * (struct (int * int) -> struct (int * int))
=
match face, direction with
| 1, Direction.Up -> 6, Direction.Right, (fun (struct (x, y)) -> struct (0, x))
| 1, Direction.Down -> 3, Direction.Down, (fun (struct (x, _)) -> struct (x, 0))
| 1, Direction.Left -> 4, Direction.Right, (fun (struct (x, y)) -> struct (0, cubeSize - 1 - y))
| 1, Direction.Right -> 2, Direction.Right, (fun (struct (x, y)) -> struct (0, y))
| 2, Direction.Up -> 6, Direction.Up, (fun (struct (x, y)) -> (x, cubeSize - 1))
| 2, Direction.Down -> 3, Direction.Left, (fun (struct (x, y)) -> struct (cubeSize - 1, x))
| 2, Direction.Left -> 1, Direction.Left, (fun (struct (_, y)) -> struct (cubeSize - 1, y))
| 2, Direction.Right -> 5, Direction.Left, (fun (struct (x, y)) -> struct (cubeSize - 1, cubeSize - 1 - y))
| 3, Direction.Up -> 1, Direction.Up, (fun (struct (x, y)) -> struct (x, cubeSize - 1))
| 3, Direction.Down -> 5, Direction.Down, (fun (struct (x, y)) -> struct (x, 0))
| 3, Direction.Left -> 4, Direction.Down, (fun (struct (x, y)) -> struct (y, 0))
| 3, Direction.Right -> 2, Direction.Up, (fun (struct (x, y)) -> struct (y, cubeSize - 1))
| 4, Direction.Up -> 3, Direction.Right, (fun (struct (x, _)) -> struct (0, x))
| 4, Direction.Down -> 6, Direction.Down, (fun (struct (x, _)) -> struct (x, 0))
| 4, Direction.Left -> 1, Direction.Right, (fun (struct (x, y)) -> struct (0, cubeSize - 1 - y))
| 4, Direction.Right -> 5, Direction.Right, (fun (struct (_, y)) -> struct (0, y))
| 5, Direction.Up -> 3, Direction.Up, (fun (struct (x, y)) -> struct (x, cubeSize - 1))
| 5, Direction.Down -> 6, Direction.Left, (fun (struct (x, y)) -> struct (cubeSize - 1, x))
| 5, Direction.Left -> 4, Direction.Left, (fun (struct (x, y)) -> struct (cubeSize - 1, y))
| 5, Direction.Right -> 2, Direction.Left, (fun (struct (x, y)) -> struct (cubeSize - 1, cubeSize - 1 - y))
| 6, Direction.Up -> 4, Direction.Up, (fun (struct (x, y)) -> struct (x, cubeSize - 1))
| 6, Direction.Down -> 2, Direction.Down, (fun (struct (x, y)) -> struct (x, 0))
| 6, Direction.Left -> 1, Direction.Down, (fun (struct (x, y)) -> struct (y, 0))
| 6, Direction.Right -> 5, Direction.Up, (fun (struct (x, y)) -> struct (y, cubeSize - 1))
| _ -> failwith "bad face"
let part2 (lines : StringSplitEnumerator) : int =
let board, instructions, finalDistance = parse lines
let faceSize = board.[0].Length / 3
let position =
{
MutableCoordinate.X = 0
MutableCoordinate.Y = 0
}
let mutable direction = Direction.Right
let mutable face = 1
for struct (distance, rotation) in instructions do
moveCubeDistance
faceSize
(toArrayElement faceSize)
(newFace faceSize)
&face
position
&direction
distance
board
direction <-
match rotation with
| Direction.Right -> rotateRight direction
| Direction.Left -> rotateLeft direction
| _ -> failwith "bad rotation"
moveCubeDistance
faceSize
(toArrayElement faceSize)
(newFace faceSize)
&face
position
&direction
finalDistance
board
let position =
toArrayElement
faceSize
face
{
X = position.X
Y = position.Y
}
answer position direction

View File

@@ -1,182 +0,0 @@
namespace AdventOfCode2022
open System
open System.Collections.Generic
#if DEBUG
open Checked
#else
#nowarn "9"
#endif
[<RequireQualifiedAccess>]
module Day23 =
let parse (line : StringSplitEnumerator) : Coordinate HashSet =
use mutable enum = line.GetEnumerator ()
let output = HashSet ()
let mutable y = 0
while enum.MoveNext () do
if not (enum.Current.IsWhiteSpace ()) then
let mutable x = 0
for c in enum.Current.TrimEnd () do
if c = '#' then
output.Add
{
X = x
Y = y
}
|> ignore
x <- x + 1
y <- y + 1
output
// proposedEndSteps will be cleared on input; it's just to save allocation.
// All inputs will be mutated.
// Returns true if an elf moved.
let inline oneRound
(board : HashSet<Coordinate>)
(proposedEndSteps : Dictionary<Coordinate, Coordinate>)
(proposedDirections : _ array)
: bool
=
proposedEndSteps.Clear ()
for elf in board do
let mutable adjacentElfOffsetX = Int32.MinValue
let mutable adjacentElfOffsetY = Int32.MinValue
for xOffset = -1 to 1 do
for yOffset = -1 to 1 do
if adjacentElfOffsetX = Int32.MinValue && (xOffset <> 0 || yOffset <> 0) then
let adjacentElf =
{
X = elf.X + xOffset
Y = elf.Y + yOffset
}
if board.Contains adjacentElf then
adjacentElfOffsetX <- xOffset
adjacentElfOffsetY <- yOffset
if adjacentElfOffsetX <> Int32.MinValue then
let mutable proposedEndPlace = ValueNone
for struct (proposedX, proposedY) in proposedDirections do
if proposedX = 0 && proposedY = adjacentElfOffsetY then
()
elif proposedY = 0 && proposedX = adjacentElfOffsetX then
()
else
let mutable hasElfInDestination = false
if proposedEndPlace.IsNone then
if proposedX = 0 then
for proposedX' = -1 to 1 do
if not hasElfInDestination then
let proposal =
{
X = elf.X + proposedX'
Y = elf.Y + proposedY
}
if board.Contains proposal then
hasElfInDestination <- true
else
for proposedY' = -1 to 1 do
if not hasElfInDestination then
let proposal =
{
X = elf.X + proposedX
Y = elf.Y + proposedY'
}
if board.Contains proposal then
hasElfInDestination <- true
if not hasElfInDestination then
proposedEndPlace <-
ValueSome
{
X = elf.X + proposedX
Y = elf.Y + proposedY
}
match proposedEndPlace with
| ValueNone -> ()
| ValueSome loc ->
if not (proposedEndSteps.TryAdd (loc, elf)) then
// It's not possible for more than two elves to want to move into the same position.
// Indeed, otherwise that position would be surrounded by three elves orthogonally,
// but then the two of those elves who oppose each other would not want to move in this
// direction because of the third elf lying diagonal to them.
proposedEndSteps.Remove loc |> ignore
for KeyValue (dest, source) in proposedEndSteps do
board.Remove source |> ignore
board.Add dest |> ignore
let tmp = proposedDirections.[0]
for i = 0 to proposedDirections.Length - 2 do
proposedDirections.[i] <- proposedDirections.[i + 1]
proposedDirections.[proposedDirections.Length - 1] <- tmp
proposedEndSteps.Count > 0
let part1 (lines : StringSplitEnumerator) : int =
let board = parse lines
let proposedEndSteps = Dictionary board.Count
let proposedDirections =
[| struct (0, -1) ; struct (0, 1) ; struct (-1, 0) ; struct (1, 0) |]
for _round = 0 to 9 do
oneRound board proposedEndSteps proposedDirections |> ignore
let mutable minX = Int32.MaxValue
let mutable maxX = Int32.MinValue
let mutable minY = Int32.MaxValue
let mutable maxY = Int32.MinValue
let mutable count = 0
for elf in board do
if elf.X < minX then
minX <- elf.X
if elf.X > maxX then
maxX <- elf.X
if elf.Y < minY then
minY <- elf.Y
if elf.Y > maxY then
maxY <- elf.Y
count <- count + 1
(maxX - minX + 1) * (maxY - minY + 1) - count
let part2 (lines : StringSplitEnumerator) : int =
let board = parse lines
let proposedEndSteps = Dictionary board.Count
let proposedDirections =
[| struct (0, -1) ; struct (0, 1) ; struct (-1, 0) ; struct (1, 0) |]
let mutable count = 1
while oneRound board proposedEndSteps proposedDirections do
count <- count + 1
count

View File

@@ -1,251 +0,0 @@
namespace AdventOfCode2022
open System
open Microsoft.FSharp.NativeInterop
#if DEBUG
open Checked
#else
#nowarn "9"
#endif
[<RequireQualifiedAccess>]
module Day24 =
// byte % 2 is whether Up is in;
// byte % 4 is whether Down is in;
// byte % 8 is whether Left is in;
// byte % 16 is whether Right is in.
// This is logically a 2D array, but without having to give up ownership.
type Day24Board = byte[]
/// Returns the width and the height too. The resulting array is suitable to become an Arr2D.
let parse (line : StringSplitEnumerator) : byte[] * int * int =
use mutable enum = line.GetEnumerator ()
let output = ResizeArray ()
let mutable y = 0
let mutable width = 0
while enum.MoveNext () do
if not (enum.Current.IsWhiteSpace ()) then
let mutable x = 0
for c in enum.Current.TrimEnd () do
match c with
| '>' -> output.Add 8uy
| '^' -> output.Add 1uy
| 'v' -> output.Add 2uy
| '<' -> output.Add 4uy
| '.'
| '#' -> output.Add 0uy
| _ -> failwithf "unexpected char: %c" c
x <- x + 1
width <- x
y <- y + 1
output.ToArray (), width, y
let moveBlizzards (width : int) (height : int) (board : Arr2D<Byte>) : unit =
for y = 1 to height - 2 do
for x = 1 to width - 2 do
let directions = Arr2D.get board x y
if directions % 2uy = 1uy then
let y = if y = 1 then height - 2 else y - 1
let prev = Arr2D.get board x y
Arr2D.set board x y (prev + 16uy)
if (directions / 2uy) % 2uy = 1uy then
let y = if y = height - 2 then 1 else y + 1
let prev = Arr2D.get board x y
Arr2D.set board x y (prev + 32uy)
if (directions / 4uy) % 2uy = 1uy then
let x = if x = 1 then width - 2 else x - 1
let prev = Arr2D.get board x y
Arr2D.set board x y (prev + 64uy)
if (directions / 8uy) % 2uy = 1uy then
let x = if x = width - 2 then 1 else x + 1
let prev = Arr2D.get board x y
Arr2D.set board x y (prev + 128uy)
for y = 1 to height - 2 do
for x = 1 to width - 2 do
let prev = Arr2D.get board x y
Arr2D.set board x y (prev >>> 4)
let inline coordToInt' (width : int) (x : int) (y : int) : int = x + y * width
let inline coordToInt (width : int) (coord : Coordinate) : int = coordToInt' width coord.X coord.Y
let inline intToCoord (width : int) (coord : int) : Coordinate =
let x = coord % width
{
X = x
Y = (coord - x) / width
}
/// The buffer is an array of at least 5 Coordinates, except it's had coordToInt called on it.
let inline populateAvailableMoves
(buffer : int[])
(width : int)
(height : int)
(current : Coordinate)
(board : Arr2D<byte>)
: int
=
let mutable bufLen = 0
if current.X > 1 && current.Y <> 0 && current.Y <> height - 1 then
if Arr2D.get board (current.X - 1) current.Y = 0uy then
buffer.[bufLen] <- coordToInt' width (current.X - 1) current.Y
bufLen <- bufLen + 1
if Arr2D.get board current.X current.Y = 0uy then
buffer.[bufLen] <- coordToInt width current
bufLen <- bufLen + 1
if current.X < width - 2 && current.Y <> 0 then
if Arr2D.get board (current.X + 1) current.Y = 0uy then
buffer.[bufLen] <- coordToInt' width (current.X + 1) current.Y
bufLen <- bufLen + 1
if current.Y > 1 && current.X <> 0 then
if Arr2D.get board current.X (current.Y - 1) = 0uy then
buffer.[bufLen] <- coordToInt' width current.X (current.Y - 1)
bufLen <- bufLen + 1
if current.Y < height - 2 && current.X <> 0 then
if Arr2D.get board current.X (current.Y + 1) = 0uy then
buffer.[bufLen] <- coordToInt' width current.X (current.Y + 1)
bufLen <- bufLen + 1
bufLen
let inline goFrom
(start : Coordinate)
(dest : Coordinate)
(width : int)
(height : int)
(board : Arr2D<byte>)
(timeStep : int)
=
let mutable buffer = ResizeArray ()
let movesBuffer = Array.zeroCreate 5
let dest = coordToInt width dest
let rec go (timeStep : int) (toExplore : int ResizeArray) =
moveBlizzards width height board
if toExplore.BinarySearch dest >= 0 then
timeStep + 1
else
buffer.Clear ()
do
let bufLen =
populateAvailableMoves movesBuffer width height (intToCoord width toExplore.[0]) board
for move = 0 to bufLen - 1 do
let move = movesBuffer.[move]
buffer.Add move
for currPosIndex = 1 to toExplore.Count - 1 do
let currPos = toExplore.[currPosIndex]
if toExplore.[currPosIndex - 1] <> currPos then
let bufLen =
populateAvailableMoves movesBuffer width height (intToCoord width currPos) board
for move = 0 to bufLen - 1 do
let move = movesBuffer.[move]
buffer.Add move
buffer.Sort ()
let continueWith = buffer
buffer <- toExplore
go (timeStep + 1) continueWith
let set = ResizeArray ()
coordToInt width start |> set.Add
go timeStep set
let goToEnd width height =
goFrom
{
X = 1
Y = 0
}
{
X = width - 2
Y = height - 2
}
width
height
let goToStart width height =
goFrom
{
X = width - 2
Y = height - 1
}
{
X = 1
Y = 1
}
width
height
let part1 (lines : StringSplitEnumerator) : int =
let board, width, height = parse lines
#if DEBUG
let board =
{
Elements = board
Width = width
}
#else
use ptr = fixed board
let board =
{
Elements = ptr
Width = width
Length = width * height
}
#endif
goToEnd width height board 0
let part2 (lines : StringSplitEnumerator) : int =
let board, width, height = parse lines
#if DEBUG
let board =
{
Elements = board
Width = width
}
#else
use ptr = fixed board
let board =
{
Elements = ptr
Width = width
Length = width * height
}
#endif
let toEnd = goToEnd width height board 0
let backToStart = goToStart width height board toEnd
goToEnd width height board backToStart

View File

@@ -1,81 +0,0 @@
namespace AdventOfCode2022
open System
open System.Text
open Microsoft.FSharp.NativeInterop
#if DEBUG
open Checked
#else
#nowarn "9"
#endif
[<RequireQualifiedAccess>]
module Day25 =
let toInt (s : ReadOnlySpan<char>) : int64 =
let mutable i = 0L
let mutable fivePow = 1L
for c = s.Length - 1 downto 0 do
match s.[c] with
| '2' -> i <- i + 2L * fivePow
| '1' -> i <- i + fivePow
| '0' -> ()
| '-' -> i <- i - fivePow
| '=' -> i <- i - 2L * fivePow
| c -> failwithf "unrecognised: %c" c
fivePow <- fivePow * 5L
i
let ofInt (i : int64) : string =
let rec go (i : int64) (sb : ResizeArray<char>) =
if i = 0 then
sb.Add '0'
elif i = 1 then
sb.Add '1'
elif i = 2 then
sb.Add '2'
else
match i % 5L with
| 0L ->
sb.Add '0'
go (i / 5L) sb
| 1L ->
sb.Add '1'
go (i / 5L) sb
| 2L ->
sb.Add '2'
go (i / 5L) sb
| 3L ->
sb.Add '='
go (i / 5L + 1L) sb
| 4L ->
sb.Add '-'
go (i / 5L + 1L) sb
| _ -> failwith "maths doesn't work"
let sb = ResizeArray 27
go i sb
sb.Reverse ()
String (sb.ToArray ())
/// Returns the width and the height too. The resulting array is suitable to become an Arr2D.
let parse (line : StringSplitEnumerator) : int64 ResizeArray =
use mutable enum = line.GetEnumerator ()
let output = ResizeArray ()
while enum.MoveNext () do
if not (enum.Current.IsWhiteSpace ()) then
let line = enum.Current.Trim ()
output.Add (toInt line)
output
let part1 (lines : StringSplitEnumerator) : string =
let numbers = parse lines
numbers |> Seq.map int64 |> Seq.sum |> ofInt

View File

@@ -1,7 +1,6 @@
namespace AdventOfCode2022 namespace AdventOfCode2022
open System open System
open System.Globalization
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module Day4 = module Day4 =
@@ -11,9 +10,6 @@ module Day4 =
let inline overlaps (a, b) (c, d) : bool = b >= c && a <= d let inline overlaps (a, b) (c, d) : bool = b >= c && a <= d
let inline private parseInt (c : ReadOnlySpan<char>) : int =
Int32.Parse (c, NumberStyles.AllowTrailingWhite)
let parse (s : ReadOnlySpan<char>) : (int * int) * (int * int) = let parse (s : ReadOnlySpan<char>) : (int * int) * (int * int) =
let commaIndex = s.IndexOf ',' let commaIndex = s.IndexOf ','
let firstElf = s.Slice (0, commaIndex) let firstElf = s.Slice (0, commaIndex)
@@ -24,7 +20,7 @@ module Day4 =
let secondDashIndex = secondElf.IndexOf '-' let secondDashIndex = secondElf.IndexOf '-'
let secondElf1 = secondElf.Slice (0, secondDashIndex) let secondElf1 = secondElf.Slice (0, secondDashIndex)
let secondElf2 = secondElf.Slice (secondDashIndex + 1) let secondElf2 = secondElf.Slice (secondDashIndex + 1)
(parseInt firstElf1, parseInt firstElf2), (parseInt secondElf1, parseInt secondElf2) (Int32.Parse firstElf1, Int32.Parse firstElf2), (Int32.Parse secondElf1, Int32.Parse secondElf2)
let part1 (lines : StringSplitEnumerator) : int = let part1 (lines : StringSplitEnumerator) : int =
let mutable count = 0 let mutable count = 0

View File

@@ -1,7 +1,6 @@
namespace AdventOfCode2022 namespace AdventOfCode2022
open System open System
open System.Collections.Generic
type Day5Instruction = type Day5Instruction =
{ {
@@ -18,7 +17,7 @@ module Day5 =
while enumerator.MoveNext () && not (enumerator.Current.IsWhiteSpace ()) do while enumerator.MoveNext () && not (enumerator.Current.IsWhiteSpace ()) do
let s = enumerator.Current let s = enumerator.Current
if s.IndexOf ']' >= 0 then if s.Contains ']' then
for i in 1..4 .. s.Length - 1 do for i in 1..4 .. s.Length - 1 do
let pile = (i - 1) / 4 let pile = (i - 1) / 4
@@ -31,7 +30,7 @@ module Day5 =
Array.init piles.Count (fun i -> List.init piles.[i].Count (fun j -> piles.[i].[j])) Array.init piles.Count (fun i -> List.init piles.[i].Count (fun j -> piles.[i].[j]))
let rec private parseInstruction (enumerator : byref<StringSplitEnumerator>) : Day5Instruction IReadOnlyList = let rec private parseInstruction (enumerator : byref<StringSplitEnumerator>) =
let outputs = ResizeArray () let outputs = ResizeArray ()
while (enumerator.MoveNext ()) && (not (enumerator.Current.IsWhiteSpace ())) do while (enumerator.MoveNext ()) && (not (enumerator.Current.IsWhiteSpace ())) do
@@ -60,9 +59,9 @@ module Day5 =
} }
|> outputs.Add |> outputs.Add
outputs List.init outputs.Count (fun i -> outputs.[i])
let parse (s : StringSplitEnumerator) : char list array * Day5Instruction IReadOnlyList = let parse (s : StringSplitEnumerator) : char list array * Day5Instruction list =
use mutable enumerator = s use mutable enumerator = s
let piles = parseDrawing &enumerator let piles = parseDrawing &enumerator
@@ -72,23 +71,26 @@ module Day5 =
let part1 (lines : StringSplitEnumerator) : string = let part1 (lines : StringSplitEnumerator) : string =
let piles, instructions = parse lines let piles, instructions = parse lines
let go (instructions : _ IReadOnlyList) (piles : _ list array) = let rec go (instructions : _ list) (piles : _ list array) =
for instr in instructions do match instructions with
| [] -> piles
| instr :: rest ->
piles.[instr.To - 1] <- List.rev piles.[instr.From - 1].[0 .. instr.Count - 1] @ piles.[instr.To - 1] piles.[instr.To - 1] <- List.rev piles.[instr.From - 1].[0 .. instr.Count - 1] @ piles.[instr.To - 1]
piles.[instr.From - 1] <- piles.[instr.From - 1].[instr.Count ..] piles.[instr.From - 1] <- piles.[instr.From - 1].[instr.Count ..]
piles go rest piles
String (go instructions piles |> Array.map List.head) String (go instructions piles |> Array.map List.head)
let part2 (lines : StringSplitEnumerator) : string = let part2 (lines : StringSplitEnumerator) : string =
let piles, instructions = parse lines let piles, instructions = parse lines
let rec go (instructions : _ IReadOnlyList) (piles : _ list array) = let rec go (instructions : _ list) (piles : _ list array) =
for instr in instructions do match instructions with
| [] -> piles
| instr :: rest ->
piles.[instr.To - 1] <- piles.[instr.From - 1].[0 .. instr.Count - 1] @ piles.[instr.To - 1] piles.[instr.To - 1] <- piles.[instr.From - 1].[0 .. instr.Count - 1] @ piles.[instr.To - 1]
piles.[instr.From - 1] <- piles.[instr.From - 1].[instr.Count ..] piles.[instr.From - 1] <- piles.[instr.From - 1].[instr.Count ..]
go rest piles
piles
String (go instructions piles |> Array.map List.head) String (go instructions piles |> Array.map List.head)

View File

@@ -5,7 +5,7 @@ open System
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module Day6 = module Day6 =
let inline findDuplicateSorted< ^a when ^a : equality> (a : 'a array) : int ValueOption = let findDuplicateSorted (a : 'a array) : int ValueOption =
let mutable i = 0 let mutable i = 0
let mutable result = ValueNone let mutable result = ValueNone

View File

@@ -177,5 +177,5 @@ module Day7 =
let required = 30000000 - unused let required = 30000000 - unused
results results
|> Seq.choose (fun (KeyValue (_, size)) -> if size >= required then Some size else None) |> Seq.choose (fun (KeyValue (path, size)) -> if size >= required then Some size else None)
|> Seq.min |> Seq.min

View File

@@ -1,66 +1,37 @@
namespace AdventOfCode2022 namespace AdventOfCode2022
open System.Collections.Generic
open System open System
#if DEBUG
#else
#nowarn "9"
#endif
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module Day8 = module Day8 =
let parse (lines : StringSplitEnumerator) : byte array * int = let parse (lines : StringSplitEnumerator) : byte[] IReadOnlyList =
use mutable enum = lines use mutable enum = lines
let output = ResizeArray () let output = ResizeArray ()
let mutable lineCount = 0
for line in enum do for line in enum do
let line = line.TrimEnd () let line = line.TrimEnd ()
if not (line.IsWhiteSpace ()) then if not (line.IsWhiteSpace ()) then
lineCount <- lineCount + 1 let arr = Array.zeroCreate line.Length
let mutable i = 0
for c in line do for c in line do
output.Add (byte c - byte '0') arr.[i] <- byte c - byte '0'
i <- i + 1
output.ToArray (), lineCount output.Add arr
let isVisible (board : Arr2D<byte>) (x : int) (y : int) : bool = output :> _
// From the left?
let mutable isVisible = true
let mutable i = 0
while i < x && isVisible do
if Arr2D.get board i y >= Arr2D.get board x y then
isVisible <- false
i <- i + 1
if isVisible then
true
else
// From the right?
let mutable isVisible = true
let mutable i = board.Height - 1
while i > x && isVisible do
if Arr2D.get board i y >= Arr2D.get board x y then
isVisible <- false
i <- i - 1
if isVisible then
true
else
let isVisible (board : byte[] IReadOnlyList) (x : int) (y : int) : bool =
// From the top? // From the top?
let mutable isVisible = true let mutable isVisible = true
let mutable i = 0 let mutable i = 0
while i < y && isVisible do while i < y && isVisible do
if Arr2D.get board x i >= Arr2D.get board x y then if board.[i].[x] >= board.[y].[x] then
isVisible <- false isVisible <- false
i <- i + 1 i <- i + 1
@@ -71,45 +42,57 @@ module Day8 =
// From the bottom? // From the bottom?
let mutable isVisible = true let mutable isVisible = true
let mutable i = board.Width - 1 let mutable i = board.Count - 1
while i > y && isVisible do while i > y && isVisible do
if Arr2D.get board x i >= Arr2D.get board x y then if board.[i].[x] >= board.[y].[x] then
isVisible <- false isVisible <- false
i <- i - 1 i <- i - 1
isVisible if isVisible then
true
else
// From the left?
let mutable isVisible = true
let mutable i = 0
while i < x && isVisible do
if board.[y].[i] >= board.[y].[x] then
isVisible <- false
i <- i + 1
if isVisible then
true
else
// From the right?
let mutable isVisible = true
let mutable i = board.[0].Length - 1
while i > x && isVisible do
if board.[y].[i] >= board.[y].[x] then
isVisible <- false
i <- i - 1
isVisible
let part1 (lines : StringSplitEnumerator) : int = let part1 (lines : StringSplitEnumerator) : int =
let board, height = parse lines let board = parse lines
#if DEBUG
let board =
{
Arr2D.Elements = board
Width = board.Length / height
}
#else
use p = fixed board
let board =
{
Arr2D.Elements = p
Length = board.Length
Width = board.Length / height
}
#endif
let mutable visibleCount = 0 let mutable visibleCount = 0
for y = 0 to board.Height - 1 do for y in 0 .. board.Count - 1 do
for x = 0 to board.Width - 1 do for x in 0 .. board.[0].Length - 1 do
if isVisible board x y then if isVisible board x y then
visibleCount <- visibleCount + 1 visibleCount <- visibleCount + 1
visibleCount visibleCount
let scenicScore (board : Arr2D<byte>) (x : int) (y : int) : int = let scenicScore (board : byte[] IReadOnlyList) (x : int) (y : int) : int =
let mutable scenicCount = 0 let mutable scenicCount = 0
do do
@@ -117,7 +100,7 @@ module Day8 =
let mutable i = y - 1 let mutable i = y - 1
while i >= 0 && isVisible do while i >= 0 && isVisible do
if Arr2D.get board x i >= Arr2D.get board x y then if board.[i].[x] >= board.[y].[x] then
isVisible <- false isVisible <- false
scenicCount <- scenicCount + 1 scenicCount <- scenicCount + 1
@@ -129,8 +112,8 @@ module Day8 =
let mutable i = y + 1 let mutable i = y + 1
let mutable subCount = 0 let mutable subCount = 0
while i < board.Height && isVisible do while i < board.Count && isVisible do
if Arr2D.get board x i >= Arr2D.get board x y then if board.[i].[x] >= board.[y].[x] then
isVisible <- false isVisible <- false
subCount <- subCount + 1 subCount <- subCount + 1
@@ -145,7 +128,7 @@ module Day8 =
let mutable subCount = 0 let mutable subCount = 0
while i >= 0 && isVisible do while i >= 0 && isVisible do
if Arr2D.get board i y >= Arr2D.get board x y then if board.[y].[i] >= board.[y].[x] then
isVisible <- false isVisible <- false
subCount <- subCount + 1 subCount <- subCount + 1
@@ -159,8 +142,8 @@ module Day8 =
let mutable i = x + 1 let mutable i = x + 1
let mutable subCount = 0 let mutable subCount = 0
while i < board.Width && isVisible do while i < board.[0].Length && isVisible do
if Arr2D.get board i y >= Arr2D.get board x y then if board.[y].[i] >= board.[y].[x] then
isVisible <- false isVisible <- false
subCount <- subCount + 1 subCount <- subCount + 1
@@ -173,28 +156,11 @@ module Day8 =
let part2 (lines : StringSplitEnumerator) : int = let part2 (lines : StringSplitEnumerator) : int =
let board, height = parse lines let board = parse lines
#if DEBUG
let board =
{
Arr2D.Elements = board
Width = board.Length / height
}
#else
use p = fixed board
let board =
{
Arr2D.Elements = p
Length = board.Length
Width = board.Length / height
}
#endif
let mutable scenicMax = 0 let mutable scenicMax = 0
for y = 0 to board.Height - 1 do for y in 0 .. board.Count - 1 do
for x = 0 to board.Width - 1 do for x in 0 .. board.[0].Length - 1 do
scenicMax <- max scenicMax (scenicScore board x y) scenicMax <- max scenicMax (scenicScore board x y)
scenicMax scenicMax

View File

@@ -74,11 +74,11 @@ module Day9 =
tailVisits.Add (struct (0, 0)) |> ignore tailVisits.Add (struct (0, 0)) |> ignore
for direction, distance in directions do for direction, distance in directions do
for _ = 1 to int distance do for _ in 1uy .. distance do
let newHead = newHead (fst knots.[0]) (snd knots.[0]) direction let newHead = newHead (fst knots.[0]) (snd knots.[0]) direction
knots.[0] <- newHead knots.[0] <- newHead
for knot = 1 to knots.Length - 2 do for knot in 1 .. knots.Length - 2 do
knots.[knot] <- bringTailTogether knots.[knot - 1] knots.[knot] knots.[knot] <- bringTailTogether knots.[knot - 1] knots.[knot]
let newTail = bringTailTogether knots.[knots.Length - 2] knots.[knots.Length - 1] let newTail = bringTailTogether knots.[knots.Length - 2] knots.[knots.Length - 1]

View File

@@ -1,7 +1,7 @@
namespace AdventOfCode2022 namespace AdventOfCode2022
open System open System
open System.Globalization open System.Collections.Generic
open System.Runtime.CompilerServices open System.Runtime.CompilerServices
type EfficientString = System.ReadOnlySpan<char> type EfficientString = System.ReadOnlySpan<char>
@@ -82,16 +82,147 @@ module StringSplitEnumerator =
SplitOn = splitChar SplitOn = splitChar
} }
let chomp (s : string) (e : byref<StringSplitEnumerator>) : unit = let chomp (s : string) (e : byref<StringSplitEnumerator>) =
#if DEBUG
if not (e.MoveNext ()) || not (EfficientString.equals s e.Current) then if not (e.MoveNext ()) || not (EfficientString.equals s e.Current) then
failwithf "expected '%s', got '%s'" s (e.Current.ToString ()) failwithf "expected '%s'" s
#else
e.MoveNext () |> ignore
#endif
let consumeInt (e : byref<StringSplitEnumerator>) : int = let consumeInt (e : byref<StringSplitEnumerator>) : int =
if not (e.MoveNext ()) then if not (e.MoveNext ()) then
failwith "expected an int, got nothing" failwith "expected an int, got nothing"
Int32.Parse e.Current Int32.Parse e.Current
[<Struct>]
[<IsByRefLike>]
type MapEnumerator<'a, 'b> =
internal
{
F : 'a -> 'b
Seq : 'a IEnumerator
mutable CurrentInternal : 'b
}
interface IDisposable with
member this.Dispose () = this.Seq.Dispose ()
interface IEnumerator<'b> with
member this.Current = this.CurrentInternal
member this.get_Current () = box this.CurrentInternal
member this.Reset () = this.Seq.Reset ()
member this.MoveNext () =
if this.Seq.MoveNext () then
this.CurrentInternal <- this.F this.Seq.Current
true
else
false
member this.Current = this.CurrentInternal
member this.MoveNext () =
if this.Seq.MoveNext () then
this.CurrentInternal <- this.F this.Seq.Current
true
else
false
member this.GetEnumerator () = this
[<RequireQualifiedAccess>]
module MapEnumerator =
let make<'a, 'b> (f : 'a -> 'b) (s : 'a IEnumerator) =
{
F = f
Seq = s
CurrentInternal = Unchecked.defaultof<_>
}
[<Struct>]
[<IsByRefLike>]
type ChooseEnumerator<'a, 'b> =
internal
{
F : 'a -> 'b ValueOption
Seq : 'a IEnumerator
mutable CurrentOutput : 'b
}
interface IDisposable with
member this.Dispose () = this.Seq.Dispose ()
member this.Current : 'b = this.CurrentOutput
member this.Reset () =
this.Seq.Reset ()
this.CurrentOutput <- Unchecked.defaultof<_>
member this.MoveNext () : bool =
let mutable keepGoing = true
let mutable toRet = true
while keepGoing do
if this.Seq.MoveNext () then
match this.F this.Seq.Current with
| ValueNone -> ()
| ValueSome v ->
this.CurrentOutput <- v
keepGoing <- false
else
keepGoing <- false
toRet <- false
toRet
member this.GetEnumerator () = this
[<RequireQualifiedAccess>]
module ChooseEnumerator =
let make<'a, 'b> (f : 'a -> 'b ValueOption) (s : 'a IEnumerator) : ChooseEnumerator<'a, 'b> =
{
F = f
Seq = s
CurrentOutput = Unchecked.defaultof<_>
}
[<Struct>]
[<IsByRefLike>]
type RangeEnumerator<'T
when 'T : (static member (+) : 'T -> 'T -> 'T) and 'T : (static member One : 'T) and 'T : equality> =
{
/// Do not mutate this!
mutable Started : bool
/// Do not mutate this!
mutable CurrentOutput : 'T
Start : 'T
End : 'T
}
member inline this.Current : 'T = this.CurrentOutput
member inline this.MoveNext () =
if not this.Started then
this.Started <- true
true
elif this.End = this.CurrentOutput then
false
else
this.CurrentOutput <- this.CurrentOutput + LanguagePrimitives.GenericOne
true
member inline this.GetEnumerator () = this
[<RequireQualifiedAccess>]
module RangeEnumerator =
let inline make<'T
when 'T : equality and 'T : (static member (+) : 'T -> 'T -> 'T) and 'T : (static member One : 'T)>
(start : 'T)
(endAtInclusive : 'T)
: RangeEnumerator<'T>
=
{
Started = false
Start = start
End = endAtInclusive
CurrentOutput = Unchecked.defaultof<_>
}

View File

@@ -1,53 +0,0 @@
namespace AdventOfCode2022
type IntSet = int64
[<RequireQualifiedAccess>]
module IntSet =
let inline set (set : IntSet) (nodeId : int) : IntSet = set ||| (1L <<< nodeId)
let inline contains (set : IntSet) (nodeId : int) : bool = set &&& (1L <<< nodeId) <> 0
let ofSeq (nodes : int seq) : IntSet = (0L, nodes) ||> Seq.fold set
let empty : IntSet = 0L
let toSeq (nodes : IntSet) : int seq =
seq {
let mutable nodes = nodes
let mutable count = 0
while nodes > 0 do
if nodes % 2L = 1L then
yield count
nodes <- nodes >>> 1
count <- count + 1
}
let count (nodes : IntSet) : int =
let mutable nodes = nodes
let mutable ans = 0
while nodes > 0 do
if nodes % 2L = 1L then
ans <- ans + 1
nodes <- nodes >>> 1
ans
let first (nodes : IntSet) : int =
let mutable nodes = nodes
let mutable count = 0
let mutable ans = 0
let mutable keepGoing = true
while keepGoing && nodes > 0 do
if nodes % 2L = 1L then
ans <- count
keepGoing <- false
nodes <- nodes >>> 1
count <- count + 1
ans

View File

@@ -1,22 +0,0 @@
``` ini
BenchmarkDotNet=v0.13.2, OS=macOS 13.1 (22C65) [Darwin 22.2.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD DEBUG
DefaultJob : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD
```
| Method | Day | IsPartOne | Mean | Error | StdDev |
|---------- |---- |---------- |---------------:|------------:|------------:|
| **Benchmark** | **11** | **False** | **2,816.897 μs** | **3.4524 μs** | **2.8829 μs** |
| **Benchmark** | **11** | **True** | **7.143 μs** | **0.0171 μs** | **0.0152 μs** |
| **Benchmark** | **12** | **False** | **20,082.913 μs** | **58.7261 μs** | **52.0592 μs** |
| **Benchmark** | **12** | **True** | **20,100.938 μs** | **35.8436 μs** | **27.9844 μs** |
| **Benchmark** | **13** | **False** | **388.554 μs** | **1.4083 μs** | **1.3173 μs** |
| **Benchmark** | **13** | **True** | **370.303 μs** | **0.8468 μs** | **0.7921 μs** |
| **Benchmark** | **14** | **False** | **4,047.039 μs** | **6.5252 μs** | **5.7845 μs** |
| **Benchmark** | **14** | **True** | **336.346 μs** | **1.2479 μs** | **1.1062 μs** |
| **Benchmark** | **15** | **False** | **51.410 μs** | **0.2912 μs** | **0.2724 μs** |
| **Benchmark** | **15** | **True** | **176,371.580 μs** | **855.0546 μs** | **714.0093 μs** |

View File

@@ -1,11 +0,0 @@
Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Day,IsPartOne,Mean,Error,StdDev
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,11,False,"2,816.897 μs",3.4524 μs,2.8829 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,11,True,7.143 μs,0.0171 μs,0.0152 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,12,False,"20,082.913 μs",58.7261 μs,52.0592 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,12,True,"20,100.938 μs",35.8436 μs,27.9844 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,13,False,388.554 μs,1.4083 μs,1.3173 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,13,True,370.303 μs,0.8468 μs,0.7921 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,14,False,"4,047.039 μs",6.5252 μs,5.7845 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,14,True,336.346 μs,1.2479 μs,1.1062 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,15,False,51.410 μs,0.2912 μs,0.2724 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,15,True,"176,371.580 μs",855.0546 μs,714.0093 μs
1 Method Job AnalyzeLaunchVariance EvaluateOverhead MaxAbsoluteError MaxRelativeError MinInvokeCount MinIterationTime OutlierMode Affinity EnvironmentVariables Jit Platform PowerPlanMode Runtime AllowVeryLargeObjects Concurrent CpuGroups Force HeapAffinitizeMask HeapCount NoAffinitize RetainVm Server Arguments BuildConfiguration Clock EngineFactory NuGetReferences Toolchain IsMutator InvocationCount IterationCount IterationTime LaunchCount MaxIterationCount MaxWarmupIterationCount MemoryRandomization MinIterationCount MinWarmupIterationCount RunStrategy UnrollFactor WarmupCount Day IsPartOne Mean Error StdDev
2 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 11 False 2,816.897 μs 3.4524 μs 2.8829 μs
3 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 11 True 7.143 μs 0.0171 μs 0.0152 μs
4 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 12 False 20,082.913 μs 58.7261 μs 52.0592 μs
5 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 12 True 20,100.938 μs 35.8436 μs 27.9844 μs
6 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 13 False 388.554 μs 1.4083 μs 1.3173 μs
7 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 13 True 370.303 μs 0.8468 μs 0.7921 μs
8 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 14 False 4,047.039 μs 6.5252 μs 5.7845 μs
9 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 14 True 336.346 μs 1.2479 μs 1.1062 μs
10 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 15 False 51.410 μs 0.2912 μs 0.2724 μs
11 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 15 True 176,371.580 μs 855.0546 μs 714.0093 μs

View File

@@ -1,39 +0,0 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>AdventOfCode2022.App.Benchmarks.Benchmark11To15-20221225-093433</title>
<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; text-align: right; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
tr:nth-child(even) { background: #f8f8f8; }
</style>
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.13.2, OS=macOS 13.1 (22C65) [Darwin 22.2.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD DEBUG
DefaultJob : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD
</code></pre>
<pre><code></code></pre>
<table>
<thead><tr><th>Method</th><th>Day</th><th>IsPartOne</th><th> Mean</th><th>Error</th><th>StdDev</th>
</tr>
</thead><tbody><tr><td>Benchmark</td><td>11</td><td>False</td><td>2,816.897 &mu;s</td><td>3.4524 &mu;s</td><td>2.8829 &mu;s</td>
</tr><tr><td>Benchmark</td><td>11</td><td>True</td><td>7.143 &mu;s</td><td>0.0171 &mu;s</td><td>0.0152 &mu;s</td>
</tr><tr><td>Benchmark</td><td>12</td><td>False</td><td>20,082.913 &mu;s</td><td>58.7261 &mu;s</td><td>52.0592 &mu;s</td>
</tr><tr><td>Benchmark</td><td>12</td><td>True</td><td>20,100.938 &mu;s</td><td>35.8436 &mu;s</td><td>27.9844 &mu;s</td>
</tr><tr><td>Benchmark</td><td>13</td><td>False</td><td>388.554 &mu;s</td><td>1.4083 &mu;s</td><td>1.3173 &mu;s</td>
</tr><tr><td>Benchmark</td><td>13</td><td>True</td><td>370.303 &mu;s</td><td>0.8468 &mu;s</td><td>0.7921 &mu;s</td>
</tr><tr><td>Benchmark</td><td>14</td><td>False</td><td>4,047.039 &mu;s</td><td>6.5252 &mu;s</td><td>5.7845 &mu;s</td>
</tr><tr><td>Benchmark</td><td>14</td><td>True</td><td>336.346 &mu;s</td><td>1.2479 &mu;s</td><td>1.1062 &mu;s</td>
</tr><tr><td>Benchmark</td><td>15</td><td>False</td><td>51.410 &mu;s</td><td>0.2912 &mu;s</td><td>0.2724 &mu;s</td>
</tr><tr><td>Benchmark</td><td>15</td><td>True</td><td>176,371.580 &mu;s</td><td>855.0546 &mu;s</td><td>714.0093 &mu;s</td>
</tr></tbody></table>
</body>
</html>

View File

@@ -1,22 +0,0 @@
``` ini
BenchmarkDotNet=v0.13.2, OS=macOS 13.1 (22C65) [Darwin 22.2.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD DEBUG
DefaultJob : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD
```
| Method | Day | IsPartOne | Mean | Error | StdDev |
|---------- |---- |---------- |---------------:|-------------:|-------------:|
| **Benchmark** | **16** | **False** | **3,374,503.8 μs** | **52,507.02 μs** | **49,115.10 μs** |
| **Benchmark** | **16** | **True** | **327,698.3 μs** | **600.56 μs** | **501.49 μs** |
| **Benchmark** | **17** | **False** | **2,998.1 μs** | **6.00 μs** | **5.01 μs** |
| **Benchmark** | **17** | **True** | **1,558.3 μs** | **4.51 μs** | **4.22 μs** |
| **Benchmark** | **18** | **False** | **42,879.1 μs** | **61.32 μs** | **54.36 μs** |
| **Benchmark** | **18** | **True** | **128.1 μs** | **0.71 μs** | **0.67 μs** |
| **Benchmark** | **19** | **False** | **560,825.7 μs** | **715.96 μs** | **597.86 μs** |
| **Benchmark** | **19** | **True** | **679,746.9 μs** | **5,022.34 μs** | **4,697.90 μs** |
| **Benchmark** | **20** | **False** | **117,412.5 μs** | **126.43 μs** | **112.07 μs** |
| **Benchmark** | **20** | **True** | **12,717.7 μs** | **11.25 μs** | **9.39 μs** |

View File

@@ -1,11 +0,0 @@
Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Day,IsPartOne,Mean,Error,StdDev
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,16,False,"3,374,503.8 μs","52,507.02 μs","49,115.10 μs"
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,16,True,"327,698.3 μs",600.56 μs,501.49 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,17,False,"2,998.1 μs",6.00 μs,5.01 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,17,True,"1,558.3 μs",4.51 μs,4.22 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,18,False,"42,879.1 μs",61.32 μs,54.36 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,18,True,128.1 μs,0.71 μs,0.67 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,19,False,"560,825.7 μs",715.96 μs,597.86 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,19,True,"679,746.9 μs","5,022.34 μs","4,697.90 μs"
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,20,False,"117,412.5 μs",126.43 μs,112.07 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,20,True,"12,717.7 μs",11.25 μs,9.39 μs
1 Method Job AnalyzeLaunchVariance EvaluateOverhead MaxAbsoluteError MaxRelativeError MinInvokeCount MinIterationTime OutlierMode Affinity EnvironmentVariables Jit Platform PowerPlanMode Runtime AllowVeryLargeObjects Concurrent CpuGroups Force HeapAffinitizeMask HeapCount NoAffinitize RetainVm Server Arguments BuildConfiguration Clock EngineFactory NuGetReferences Toolchain IsMutator InvocationCount IterationCount IterationTime LaunchCount MaxIterationCount MaxWarmupIterationCount MemoryRandomization MinIterationCount MinWarmupIterationCount RunStrategy UnrollFactor WarmupCount Day IsPartOne Mean Error StdDev
2 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 16 False 3,374,503.8 μs 52,507.02 μs 49,115.10 μs
3 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 16 True 327,698.3 μs 600.56 μs 501.49 μs
4 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 17 False 2,998.1 μs 6.00 μs 5.01 μs
5 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 17 True 1,558.3 μs 4.51 μs 4.22 μs
6 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 18 False 42,879.1 μs 61.32 μs 54.36 μs
7 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 18 True 128.1 μs 0.71 μs 0.67 μs
8 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 19 False 560,825.7 μs 715.96 μs 597.86 μs
9 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 19 True 679,746.9 μs 5,022.34 μs 4,697.90 μs
10 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 20 False 117,412.5 μs 126.43 μs 112.07 μs
11 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 20 True 12,717.7 μs 11.25 μs 9.39 μs

View File

@@ -1,39 +0,0 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>AdventOfCode2022.App.Benchmarks.Benchmark16To20-20221225-093737</title>
<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; text-align: right; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
tr:nth-child(even) { background: #f8f8f8; }
</style>
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.13.2, OS=macOS 13.1 (22C65) [Darwin 22.2.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD DEBUG
DefaultJob : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD
</code></pre>
<pre><code></code></pre>
<table>
<thead><tr><th>Method</th><th>Day</th><th>IsPartOne</th><th> Mean</th><th> Error</th><th>StdDev</th>
</tr>
</thead><tbody><tr><td>Benchmark</td><td>16</td><td>False</td><td>3,374,503.8 &mu;s</td><td>52,507.02 &mu;s</td><td>49,115.10 &mu;s</td>
</tr><tr><td>Benchmark</td><td>16</td><td>True</td><td>327,698.3 &mu;s</td><td>600.56 &mu;s</td><td>501.49 &mu;s</td>
</tr><tr><td>Benchmark</td><td>17</td><td>False</td><td>2,998.1 &mu;s</td><td>6.00 &mu;s</td><td>5.01 &mu;s</td>
</tr><tr><td>Benchmark</td><td>17</td><td>True</td><td>1,558.3 &mu;s</td><td>4.51 &mu;s</td><td>4.22 &mu;s</td>
</tr><tr><td>Benchmark</td><td>18</td><td>False</td><td>42,879.1 &mu;s</td><td>61.32 &mu;s</td><td>54.36 &mu;s</td>
</tr><tr><td>Benchmark</td><td>18</td><td>True</td><td>128.1 &mu;s</td><td>0.71 &mu;s</td><td>0.67 &mu;s</td>
</tr><tr><td>Benchmark</td><td>19</td><td>False</td><td>560,825.7 &mu;s</td><td>715.96 &mu;s</td><td>597.86 &mu;s</td>
</tr><tr><td>Benchmark</td><td>19</td><td>True</td><td>679,746.9 &mu;s</td><td>5,022.34 &mu;s</td><td>4,697.90 &mu;s</td>
</tr><tr><td>Benchmark</td><td>20</td><td>False</td><td>117,412.5 &mu;s</td><td>126.43 &mu;s</td><td>112.07 &mu;s</td>
</tr><tr><td>Benchmark</td><td>20</td><td>True</td><td>12,717.7 &mu;s</td><td>11.25 &mu;s</td><td>9.39 &mu;s</td>
</tr></tbody></table>
</body>
</html>

View File

@@ -1,22 +0,0 @@
``` ini
BenchmarkDotNet=v0.13.2, OS=macOS 13.1 (22C65) [Darwin 22.2.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD DEBUG
DefaultJob : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD
```
| Method | Day | IsPartOne | Mean | Error | StdDev |
|---------- |---- |---------- |---------:|---------:|---------:|
| **Benchmark** | **1** | **False** | **31.92 μs** | **0.103 μs** | **0.091 μs** |
| **Benchmark** | **1** | **True** | **31.86 μs** | **0.049 μs** | **0.044 μs** |
| **Benchmark** | **2** | **False** | **79.57 μs** | **0.094 μs** | **0.078 μs** |
| **Benchmark** | **2** | **True** | **81.06 μs** | **0.315 μs** | **0.295 μs** |
| **Benchmark** | **3** | **False** | **65.75 μs** | **0.546 μs** | **0.510 μs** |
| **Benchmark** | **3** | **True** | **31.96 μs** | **0.439 μs** | **0.411 μs** |
| **Benchmark** | **4** | **False** | **52.70 μs** | **0.155 μs** | **0.130 μs** |
| **Benchmark** | **4** | **True** | **63.71 μs** | **0.230 μs** | **0.204 μs** |
| **Benchmark** | **5** | **False** | **78.74 μs** | **0.781 μs** | **0.692 μs** |
| **Benchmark** | **5** | **True** | **91.26 μs** | **0.278 μs** | **0.247 μs** |

View File

@@ -1,11 +0,0 @@
Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Day,IsPartOne,Mean,Error,StdDev
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,1,False,31.92 μs,0.103 μs,0.091 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,1,True,31.86 μs,0.049 μs,0.044 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,2,False,79.57 μs,0.094 μs,0.078 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,2,True,81.06 μs,0.315 μs,0.295 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,3,False,65.75 μs,0.546 μs,0.510 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,3,True,31.96 μs,0.439 μs,0.411 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,4,False,52.70 μs,0.155 μs,0.130 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,4,True,63.71 μs,0.230 μs,0.204 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,5,False,78.74 μs,0.781 μs,0.692 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,5,True,91.26 μs,0.278 μs,0.247 μs
1 Method Job AnalyzeLaunchVariance EvaluateOverhead MaxAbsoluteError MaxRelativeError MinInvokeCount MinIterationTime OutlierMode Affinity EnvironmentVariables Jit Platform PowerPlanMode Runtime AllowVeryLargeObjects Concurrent CpuGroups Force HeapAffinitizeMask HeapCount NoAffinitize RetainVm Server Arguments BuildConfiguration Clock EngineFactory NuGetReferences Toolchain IsMutator InvocationCount IterationCount IterationTime LaunchCount MaxIterationCount MaxWarmupIterationCount MemoryRandomization MinIterationCount MinWarmupIterationCount RunStrategy UnrollFactor WarmupCount Day IsPartOne Mean Error StdDev
2 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 1 False 31.92 μs 0.103 μs 0.091 μs
3 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 1 True 31.86 μs 0.049 μs 0.044 μs
4 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 2 False 79.57 μs 0.094 μs 0.078 μs
5 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 2 True 81.06 μs 0.315 μs 0.295 μs
6 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 3 False 65.75 μs 0.546 μs 0.510 μs
7 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 3 True 31.96 μs 0.439 μs 0.411 μs
8 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 4 False 52.70 μs 0.155 μs 0.130 μs
9 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 4 True 63.71 μs 0.230 μs 0.204 μs
10 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 5 False 78.74 μs 0.781 μs 0.692 μs
11 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 5 True 91.26 μs 0.278 μs 0.247 μs

View File

@@ -1,39 +0,0 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>AdventOfCode2022.App.Benchmarks.Benchmark1To5-20221225-092842</title>
<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; text-align: right; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
tr:nth-child(even) { background: #f8f8f8; }
</style>
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.13.2, OS=macOS 13.1 (22C65) [Darwin 22.2.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD DEBUG
DefaultJob : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD
</code></pre>
<pre><code></code></pre>
<table>
<thead><tr><th>Method</th><th>Day</th><th>IsPartOne</th><th>Mean</th><th>Error</th><th>StdDev</th>
</tr>
</thead><tbody><tr><td>Benchmark</td><td>1</td><td>False</td><td>31.92 &mu;s</td><td>0.103 &mu;s</td><td>0.091 &mu;s</td>
</tr><tr><td>Benchmark</td><td>1</td><td>True</td><td>31.86 &mu;s</td><td>0.049 &mu;s</td><td>0.044 &mu;s</td>
</tr><tr><td>Benchmark</td><td>2</td><td>False</td><td>79.57 &mu;s</td><td>0.094 &mu;s</td><td>0.078 &mu;s</td>
</tr><tr><td>Benchmark</td><td>2</td><td>True</td><td>81.06 &mu;s</td><td>0.315 &mu;s</td><td>0.295 &mu;s</td>
</tr><tr><td>Benchmark</td><td>3</td><td>False</td><td>65.75 &mu;s</td><td>0.546 &mu;s</td><td>0.510 &mu;s</td>
</tr><tr><td>Benchmark</td><td>3</td><td>True</td><td>31.96 &mu;s</td><td>0.439 &mu;s</td><td>0.411 &mu;s</td>
</tr><tr><td>Benchmark</td><td>4</td><td>False</td><td>52.70 &mu;s</td><td>0.155 &mu;s</td><td>0.130 &mu;s</td>
</tr><tr><td>Benchmark</td><td>4</td><td>True</td><td>63.71 &mu;s</td><td>0.230 &mu;s</td><td>0.204 &mu;s</td>
</tr><tr><td>Benchmark</td><td>5</td><td>False</td><td>78.74 &mu;s</td><td>0.781 &mu;s</td><td>0.692 &mu;s</td>
</tr><tr><td>Benchmark</td><td>5</td><td>True</td><td>91.26 &mu;s</td><td>0.278 &mu;s</td><td>0.247 &mu;s</td>
</tr></tbody></table>
</body>
</html>

View File

@@ -1,21 +0,0 @@
``` ini
BenchmarkDotNet=v0.13.2, OS=macOS 13.1 (22C65) [Darwin 22.2.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD DEBUG
DefaultJob : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD
```
| Method | args | Mean | Error | StdDev |
|---------- |------------ |---------------:|--------------:|--------------:|
| **Benchmark** | **(21, False)** | **637.049 μs** | **1.0056 μs** | **0.8397 μs** |
| **Benchmark** | **(21, True)** | **575.965 μs** | **6.5023 μs** | **5.4297 μs** |
| **Benchmark** | **(22, False)** | **329.169 μs** | **1.9539 μs** | **1.8277 μs** |
| **Benchmark** | **(22, True)** | **216.176 μs** | **0.5694 μs** | **0.5327 μs** |
| **Benchmark** | **(23, False)** | **318,432.306 μs** | **5,235.8275 μs** | **4,897.5963 μs** |
| **Benchmark** | **(23, True)** | **2,694.296 μs** | **4.5002 μs** | **3.7579 μs** |
| **Benchmark** | **(24, False)** | **47,718.692 μs** | **106.8933 μs** | **89.2607 μs** |
| **Benchmark** | **(24, True)** | **15,540.162 μs** | **23.0957 μs** | **19.2860 μs** |
| **Benchmark** | **(25, True)** | **4.388 μs** | **0.0072 μs** | **0.0056 μs** |

View File

@@ -1,10 +0,0 @@
Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,args,Mean,Error,StdDev
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,"(21, False)",637.049 μs,1.0056 μs,0.8397 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,"(21, True)",575.965 μs,6.5023 μs,5.4297 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,"(22, False)",329.169 μs,1.9539 μs,1.8277 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,"(22, True)",216.176 μs,0.5694 μs,0.5327 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,"(23, False)","318,432.306 μs","5,235.8275 μs","4,897.5963 μs"
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,"(23, True)","2,694.296 μs",4.5002 μs,3.7579 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,"(24, False)","47,718.692 μs",106.8933 μs,89.2607 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,"(24, True)","15,540.162 μs",23.0957 μs,19.2860 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,"(25, True)",4.388 μs,0.0072 μs,0.0056 μs
1 Method Job AnalyzeLaunchVariance EvaluateOverhead MaxAbsoluteError MaxRelativeError MinInvokeCount MinIterationTime OutlierMode Affinity EnvironmentVariables Jit Platform PowerPlanMode Runtime AllowVeryLargeObjects Concurrent CpuGroups Force HeapAffinitizeMask HeapCount NoAffinitize RetainVm Server Arguments BuildConfiguration Clock EngineFactory NuGetReferences Toolchain IsMutator InvocationCount IterationCount IterationTime LaunchCount MaxIterationCount MaxWarmupIterationCount MemoryRandomization MinIterationCount MinWarmupIterationCount RunStrategy UnrollFactor WarmupCount args Mean Error StdDev
2 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default (21, False) 637.049 μs 1.0056 μs 0.8397 μs
3 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default (21, True) 575.965 μs 6.5023 μs 5.4297 μs
4 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default (22, False) 329.169 μs 1.9539 μs 1.8277 μs
5 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default (22, True) 216.176 μs 0.5694 μs 0.5327 μs
6 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default (23, False) 318,432.306 μs 5,235.8275 μs 4,897.5963 μs
7 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default (23, True) 2,694.296 μs 4.5002 μs 3.7579 μs
8 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default (24, False) 47,718.692 μs 106.8933 μs 89.2607 μs
9 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default (24, True) 15,540.162 μs 23.0957 μs 19.2860 μs
10 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default (25, True) 4.388 μs 0.0072 μs 0.0056 μs

View File

@@ -1,38 +0,0 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>AdventOfCode2022.App.Benchmarks.Benchmark21To25-20221225-114355</title>
<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; text-align: right; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
tr:nth-child(even) { background: #f8f8f8; }
</style>
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.13.2, OS=macOS 13.1 (22C65) [Darwin 22.2.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD DEBUG
DefaultJob : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD
</code></pre>
<pre><code></code></pre>
<table>
<thead><tr><th>Method</th><th> args</th><th> Mean</th><th> Error</th><th> StdDev</th>
</tr>
</thead><tbody><tr><td>Benchmark</td><td>(21, False)</td><td>637.049 &mu;s</td><td>1.0056 &mu;s</td><td>0.8397 &mu;s</td>
</tr><tr><td>Benchmark</td><td>(21, True)</td><td>575.965 &mu;s</td><td>6.5023 &mu;s</td><td>5.4297 &mu;s</td>
</tr><tr><td>Benchmark</td><td>(22, False)</td><td>329.169 &mu;s</td><td>1.9539 &mu;s</td><td>1.8277 &mu;s</td>
</tr><tr><td>Benchmark</td><td>(22, True)</td><td>216.176 &mu;s</td><td>0.5694 &mu;s</td><td>0.5327 &mu;s</td>
</tr><tr><td>Benchmark</td><td>(23, False)</td><td>318,432.306 &mu;s</td><td>5,235.8275 &mu;s</td><td>4,897.5963 &mu;s</td>
</tr><tr><td>Benchmark</td><td>(23, True)</td><td>2,694.296 &mu;s</td><td>4.5002 &mu;s</td><td>3.7579 &mu;s</td>
</tr><tr><td>Benchmark</td><td>(24, False)</td><td>47,718.692 &mu;s</td><td>106.8933 &mu;s</td><td>89.2607 &mu;s</td>
</tr><tr><td>Benchmark</td><td>(24, True)</td><td>15,540.162 &mu;s</td><td>23.0957 &mu;s</td><td>19.2860 &mu;s</td>
</tr><tr><td>Benchmark</td><td>(25, True)</td><td>4.388 &mu;s</td><td>0.0072 &mu;s</td><td>0.0056 &mu;s</td>
</tr></tbody></table>
</body>
</html>

View File

@@ -1,22 +0,0 @@
``` ini
BenchmarkDotNet=v0.13.2, OS=macOS 13.1 (22C65) [Darwin 22.2.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD DEBUG
DefaultJob : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD
```
| Method | Day | IsPartOne | Mean | Error | StdDev |
|---------- |---- |---------- |-----------:|----------:|----------:|
| **Benchmark** | **6** | **False** | **53.708 μs** | **1.0291 μs** | **1.3015 μs** |
| **Benchmark** | **6** | **True** | **16.920 μs** | **0.1420 μs** | **0.1108 μs** |
| **Benchmark** | **7** | **False** | **442.469 μs** | **1.3215 μs** | **1.2362 μs** |
| **Benchmark** | **7** | **True** | **442.077 μs** | **1.1099 μs** | **1.0382 μs** |
| **Benchmark** | **8** | **False** | **278.609 μs** | **1.9329 μs** | **1.8080 μs** |
| **Benchmark** | **8** | **True** | **552.077 μs** | **4.2246 μs** | **3.9517 μs** |
| **Benchmark** | **9** | **False** | **877.123 μs** | **3.1055 μs** | **2.9049 μs** |
| **Benchmark** | **9** | **True** | **453.615 μs** | **1.6385 μs** | **1.5327 μs** |
| **Benchmark** | **10** | **False** | **8.216 μs** | **0.0179 μs** | **0.0150 μs** |
| **Benchmark** | **10** | **True** | **7.433 μs** | **0.0146 μs** | **0.0129 μs** |

View File

@@ -1,11 +0,0 @@
Method,Job,AnalyzeLaunchVariance,EvaluateOverhead,MaxAbsoluteError,MaxRelativeError,MinInvokeCount,MinIterationTime,OutlierMode,Affinity,EnvironmentVariables,Jit,Platform,PowerPlanMode,Runtime,AllowVeryLargeObjects,Concurrent,CpuGroups,Force,HeapAffinitizeMask,HeapCount,NoAffinitize,RetainVm,Server,Arguments,BuildConfiguration,Clock,EngineFactory,NuGetReferences,Toolchain,IsMutator,InvocationCount,IterationCount,IterationTime,LaunchCount,MaxIterationCount,MaxWarmupIterationCount,MemoryRandomization,MinIterationCount,MinWarmupIterationCount,RunStrategy,UnrollFactor,WarmupCount,Day,IsPartOne,Mean,Error,StdDev
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,6,False,53.708 μs,1.0291 μs,1.3015 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,6,True,16.920 μs,0.1420 μs,0.1108 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,7,False,442.469 μs,1.3215 μs,1.2362 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,7,True,442.077 μs,1.1099 μs,1.0382 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,8,False,278.609 μs,1.9329 μs,1.8080 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,8,True,552.077 μs,4.2246 μs,3.9517 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,9,False,877.123 μs,3.1055 μs,2.9049 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,9,True,453.615 μs,1.6385 μs,1.5327 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,10,False,8.216 μs,0.0179 μs,0.0150 μs
Benchmark,DefaultJob,False,Default,Default,Default,Default,Default,Default,0000000000,Empty,RyuJit,Arm64,8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c,.NET 7.0,False,True,False,True,Default,Default,False,False,False,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,Default,16,Default,10,True,7.433 μs,0.0146 μs,0.0129 μs
1 Method Job AnalyzeLaunchVariance EvaluateOverhead MaxAbsoluteError MaxRelativeError MinInvokeCount MinIterationTime OutlierMode Affinity EnvironmentVariables Jit Platform PowerPlanMode Runtime AllowVeryLargeObjects Concurrent CpuGroups Force HeapAffinitizeMask HeapCount NoAffinitize RetainVm Server Arguments BuildConfiguration Clock EngineFactory NuGetReferences Toolchain IsMutator InvocationCount IterationCount IterationTime LaunchCount MaxIterationCount MaxWarmupIterationCount MemoryRandomization MinIterationCount MinWarmupIterationCount RunStrategy UnrollFactor WarmupCount Day IsPartOne Mean Error StdDev
2 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 6 False 53.708 μs 1.0291 μs 1.3015 μs
3 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 6 True 16.920 μs 0.1420 μs 0.1108 μs
4 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 7 False 442.469 μs 1.3215 μs 1.2362 μs
5 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 7 True 442.077 μs 1.1099 μs 1.0382 μs
6 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 8 False 278.609 μs 1.9329 μs 1.8080 μs
7 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 8 True 552.077 μs 4.2246 μs 3.9517 μs
8 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 9 False 877.123 μs 3.1055 μs 2.9049 μs
9 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 9 True 453.615 μs 1.6385 μs 1.5327 μs
10 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 10 False 8.216 μs 0.0179 μs 0.0150 μs
11 Benchmark DefaultJob False Default Default Default Default Default Default 0000000000 Empty RyuJit Arm64 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c .NET 7.0 False True False True Default Default False False False Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default Default 16 Default 10 True 7.433 μs 0.0146 μs 0.0129 μs

View File

@@ -1,39 +0,0 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>AdventOfCode2022.App.Benchmarks.Benchmark6To10-20221225-093119</title>
<style type="text/css">
table { border-collapse: collapse; display: block; width: 100%; overflow: auto; }
td, th { padding: 6px 13px; border: 1px solid #ddd; text-align: right; }
tr { background-color: #fff; border-top: 1px solid #ccc; }
tr:nth-child(even) { background: #f8f8f8; }
</style>
</head>
<body>
<pre><code>
BenchmarkDotNet=v0.13.2, OS=macOS 13.1 (22C65) [Darwin 22.2.0]
Apple M1 Max, 1 CPU, 10 logical and 10 physical cores
.NET SDK=7.0.100
[Host] : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD DEBUG
DefaultJob : .NET 7.0.0 (7.0.22.51805), Arm64 RyuJIT AdvSIMD
</code></pre>
<pre><code></code></pre>
<table>
<thead><tr><th>Method</th><th>Day</th><th>IsPartOne</th><th>Mean</th><th>Error</th><th>StdDev</th>
</tr>
</thead><tbody><tr><td>Benchmark</td><td>6</td><td>False</td><td>53.708 &mu;s</td><td>1.0291 &mu;s</td><td>1.3015 &mu;s</td>
</tr><tr><td>Benchmark</td><td>6</td><td>True</td><td>16.920 &mu;s</td><td>0.1420 &mu;s</td><td>0.1108 &mu;s</td>
</tr><tr><td>Benchmark</td><td>7</td><td>False</td><td>442.469 &mu;s</td><td>1.3215 &mu;s</td><td>1.2362 &mu;s</td>
</tr><tr><td>Benchmark</td><td>7</td><td>True</td><td>442.077 &mu;s</td><td>1.1099 &mu;s</td><td>1.0382 &mu;s</td>
</tr><tr><td>Benchmark</td><td>8</td><td>False</td><td>278.609 &mu;s</td><td>1.9329 &mu;s</td><td>1.8080 &mu;s</td>
</tr><tr><td>Benchmark</td><td>8</td><td>True</td><td>552.077 &mu;s</td><td>4.2246 &mu;s</td><td>3.9517 &mu;s</td>
</tr><tr><td>Benchmark</td><td>9</td><td>False</td><td>877.123 &mu;s</td><td>3.1055 &mu;s</td><td>2.9049 &mu;s</td>
</tr><tr><td>Benchmark</td><td>9</td><td>True</td><td>453.615 &mu;s</td><td>1.6385 &mu;s</td><td>1.5327 &mu;s</td>
</tr><tr><td>Benchmark</td><td>10</td><td>False</td><td>8.216 &mu;s</td><td>0.0179 &mu;s</td><td>0.0150 &mu;s</td>
</tr><tr><td>Benchmark</td><td>10</td><td>True</td><td>7.433 &mu;s</td><td>0.0146 &mu;s</td><td>0.0129 &mu;s</td>
</tr></tbody></table>
</body>
</html>

View File

@@ -1 +0,0 @@
Feel free to send me PRs or raise issues, but don't have any expectation at all that I will look at them :P

View File

@@ -1,14 +0,0 @@
<Project>
<PropertyGroup>
<Authors>Patrick Stevens</Authors>
<Copyright>Patrick Stevens</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/Smaug123/AdventOfCode2022</PackageProjectUrl>
</PropertyGroup>
<PropertyGroup>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>
</Project>

View File

@@ -2,12 +2,3 @@
Advent of Code 2022, in F#. Advent of Code 2022, in F#.
Just `dotnet build` and `dotnet test`. Just `dotnet build` and `dotnet test`.
## Perf
BenchmarkDotNet reports:
* [Day 1 through Day 5](./BenchmarkDotNet.Artifacts/results/AdventOfCode2022.App.Benchmarks.Benchmark1To5-report-github.md).
* [Day 6 through Day 10](./BenchmarkDotNet.Artifacts/results/AdventOfCode2022.App.Benchmarks.Benchmark6To10-report-github.md).
* [Day 11 through Day 15](./BenchmarkDotNet.Artifacts/results/AdventOfCode2022.App.Benchmarks.Benchmark11To15-report-github.md).
* [Day 16 through Day 20](./BenchmarkDotNet.Artifacts/results/AdventOfCode2022.App.Benchmarks.Benchmark16To20-report-github.md).
* [Day 21 through Day 25](./BenchmarkDotNet.Artifacts/results/AdventOfCode2022.App.Benchmarks.Benchmark21To25-report-github.md).

View File

@@ -1,9 +0,0 @@
# Security Policy
… Why are you using this project?
But feel free to find and tell me about security problems, I guess.
## Reporting a Vulnerability
Raise a GitHub issue.
I might or might not ever look at it.

42
flake.lock generated
View File

@@ -1,42 +0,0 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1671548329,
"narHash": "sha256-OrC6R6zihRjFqdKFF3/vD3bkz44poONSII8ncre1Wh0=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ba6ba2b90096dc49f448aa4d4d783b5081b1cc87",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixpkgs-unstable",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

View File

@@ -1,89 +0,0 @@
{
description = "Advent of Code 2022";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
};
outputs = {
self,
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
projectFile = "./AdventOfCode2022.App/AdventOfCode2022.App.fsproj";
testProjectFile = "./AdventOfCode2022.Test/AdventOfCode2022.Test.fsproj";
pname = "AdventOfCode2022";
dotnet-sdk = pkgs.dotnet-sdk_7;
dotnet-runtime = pkgs.dotnetCorePackages.runtime_7_0;
version = "0.0.1";
dotnetTool = toolName: toolVersion: sha256:
pkgs.stdenvNoCC.mkDerivation rec {
name = toolName;
version = toolVersion;
nativeBuildInputs = [pkgs.makeWrapper];
src = pkgs.fetchNuGet {
pname = name;
version = version;
sha256 = sha256;
installPhase = ''mkdir -p $out/bin && cp -r tools/net6.0/any/* $out/bin'';
};
installPhase = ''
runHook preInstall
mkdir -p "$out/lib"
cp -r ./bin/* "$out/lib"
makeWrapper "${dotnet-runtime}/bin/dotnet" "$out/bin/${name}" --add-flags "$out/lib/${name}.dll"
runHook postInstall
'';
};
in {
packages = {
fantomas = dotnetTool "fantomas" "5.2.0-alpha-008" "sha256-1egphbWXTjs2I5aFaWibFDKgu3llP1o32o1X5vab6v4=";
fetchDeps = let
flags = [];
runtimeIds = map (system: pkgs.dotnetCorePackages.systemToDotnetRid system) dotnet-sdk.meta.platforms;
in
pkgs.writeShellScript "fetch-${pname}-deps" (builtins.readFile (pkgs.substituteAll {
src = ./nix/fetchDeps.sh;
pname = pname;
binPath = pkgs.lib.makeBinPath [pkgs.coreutils dotnet-sdk (pkgs.nuget-to-nix.override {inherit dotnet-sdk;})];
projectFiles = toString (pkgs.lib.toList projectFile);
testProjectFiles = toString (pkgs.lib.toList testProjectFile);
rids = pkgs.lib.concatStringsSep "\" \"" runtimeIds;
packages = dotnet-sdk.packages;
storeSrc = pkgs.srcOnly {
src = ./.;
pname = pname;
version = version;
};
}));
default = pkgs.buildDotnetModule {
pname = pname;
version = version;
src = ./.;
projectFile = projectFile;
nugetDeps = ./nix/deps.nix;
doCheck = true;
dotnet-sdk = dotnet-sdk;
dotnet-runtime = dotnet-runtime;
};
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
(with dotnetCorePackages;
combinePackages [
dotnet-sdk_7
dotnetPackages.Nuget
])
];
packages = [
pkgs.alejandra
pkgs.nodePackages.markdown-link-check
pkgs.shellcheck
];
};
});
}

View File

@@ -1,574 +0,0 @@
# This file was automatically generated by passthru.fetch-deps.
# Please don't edit it manually, your changes might get overwritten!
{fetchNuGet}: [
(fetchNuGet {
pname = "BenchmarkDotNet";
version = "0.13.2";
sha256 = "197dn76za0dvpa1gv819m9qrhri1ppcmvgd7qgc6kmqwcrqrzwx4";
})
(fetchNuGet {
pname = "BenchmarkDotNet.Annotations";
version = "0.13.2";
sha256 = "05r2jv4z5awwd3c9ih3f0zkyh24k5hh9fa54r2d2bgj0g4fiwrq1";
})
(fetchNuGet {
pname = "CommandLineParser";
version = "2.4.3";
sha256 = "1aca3q25n3dg55v4j3kzlzfzd5k2jpy6zhp8x7g74pdfdqzrhg55";
})
(fetchNuGet {
pname = "coverlet.collector";
version = "3.1.2";
sha256 = "0gsk2q93qw7pqxwd4pdyq5364wz0lvldcqqnf4amz13jaq86idmz";
})
(fetchNuGet {
pname = "DotNet.ReproducibleBuilds";
version = "1.1.1";
sha256 = "0wa0xwbwv1lzjmqwg1vq06vrpb9kkbv3xw5nq50savj0dzhqakzq";
})
(fetchNuGet {
pname = "FSharp.Collections.ParallelSeq";
version = "1.2.0";
sha256 = "0nsji0w089fhs6xa6m7w8r8zqdi3gm29nzpl386kk5r1vfrw3zfv";
})
(fetchNuGet {
pname = "FSharp.Core";
version = "7.0.0";
sha256 = "1pgk3qk9p1s53wvja17744x4bf7zs3a3wf0dmxi66w1w06z7i85x";
})
(fetchNuGet {
pname = "FsUnit";
version = "5.1.0";
sha256 = "07pc3qba6b7ljsdgxhjn5lx6jvzqx5rc20aibhpm1m195kmq097l";
})
(fetchNuGet {
pname = "Iced";
version = "1.17.0";
sha256 = "1999xavgpy2h83rh4indiq5mx5l509swqdi1raxj3ab6zvk49zpb";
})
(fetchNuGet {
pname = "Microsoft.Bcl.AsyncInterfaces";
version = "1.1.0";
sha256 = "1dq5yw7cy6s42193yl4iqscfw5vzkjkgv0zyy32scr4jza6ni1a1";
})
(fetchNuGet {
pname = "Microsoft.Build.Tasks.Git";
version = "1.1.1";
sha256 = "1bb5p4zlnfn88skkvymxfsn0jybqncl4356hwnic9jxdq2d4fz1w";
})
(fetchNuGet {
pname = "Microsoft.CodeAnalysis.Analyzers";
version = "2.6.2-beta2";
sha256 = "152b2v012mpac5yjcwij4ja8lgmqfiwhcvnbhmqi00wp2jimqsc5";
})
(fetchNuGet {
pname = "Microsoft.CodeAnalysis.Common";
version = "3.0.0";
sha256 = "0q6v1z0zy33x8bx20dxpm8s6ikdykz32zyy1zf4dzknqsl451imr";
})
(fetchNuGet {
pname = "Microsoft.CodeAnalysis.CSharp";
version = "3.0.0";
sha256 = "1dbbh3pwq3qycmr7xisyhl5ik6fl3sanpacwyf1c1j0xdva56g91";
})
(fetchNuGet {
pname = "Microsoft.CodeCoverage";
version = "17.1.0";
sha256 = "1ijl3w14lnj15hi052jlshf5k8vb90x0py7yrs897mf126qp8ivy";
})
(fetchNuGet {
pname = "Microsoft.CSharp";
version = "4.0.1";
sha256 = "0zxc0apx1gcx361jlq8smc9pfdgmyjh6hpka8dypc9w23nlsh6yj";
})
(fetchNuGet {
pname = "Microsoft.Diagnostics.NETCore.Client";
version = "0.2.251802";
sha256 = "0h4mc6gx95l1mwcxhj7m7drsfgbhp0ssr6l8wr7k42y0nypgi4gm";
})
(fetchNuGet {
pname = "Microsoft.Diagnostics.Runtime";
version = "2.2.332302";
sha256 = "1n64ya4fq6305xv8ybk7f22v0f39rylkqap7n9blhr1h98mp27z5";
})
(fetchNuGet {
pname = "Microsoft.Diagnostics.Tracing.TraceEvent";
version = "3.0.2";
sha256 = "14swfz2myqv4zxznf5450b3485q629pk0zc483yszvq0956a4yq4";
})
(fetchNuGet {
pname = "Microsoft.DotNet.PlatformAbstractions";
version = "3.1.6";
sha256 = "0b9myd7gqbpaw9pkd2bx45jhik9mwj0f1ss57sk2cxmag2lkdws5";
})
(fetchNuGet {
pname = "Microsoft.Extensions.Configuration";
version = "2.1.1";
sha256 = "0244czr3jflvzcj6axq61j10dkl0f16ad34rw81ryg57v4cvlwx6";
})
(fetchNuGet {
pname = "Microsoft.Extensions.Configuration.Abstractions";
version = "2.1.1";
sha256 = "0b4bn0cf39c6jlc8xnpi1d8f3pz0qhf8ng440yb95y5jv5q4fdyw";
})
(fetchNuGet {
pname = "Microsoft.Extensions.Configuration.Binder";
version = "2.1.1";
sha256 = "0n91s6cjfv8plf5swhr307s849jmq2pa3i1rbpb0cb0grxml0mqm";
})
(fetchNuGet {
pname = "Microsoft.Extensions.DependencyInjection.Abstractions";
version = "2.1.1";
sha256 = "0rn0925aqm1fsbaf0n8jy6ng2fm1cy97lp7yikvx31m6178k9i84";
})
(fetchNuGet {
pname = "Microsoft.Extensions.Logging";
version = "2.1.1";
sha256 = "12pag6rf01xfa8x1h30mf4czfhlhg2kgi5q712jicy3h12c02w8y";
})
(fetchNuGet {
pname = "Microsoft.Extensions.Logging.Abstractions";
version = "2.1.1";
sha256 = "1sgpwj0sa0ac7m5fnkb482mnch8fsv8hfbvk53c6lyh47s1xhdjg";
})
(fetchNuGet {
pname = "Microsoft.Extensions.Options";
version = "2.1.1";
sha256 = "0wgpsi874gzzjj099xbdmmsifslkbdjkxd5xrzpc5xdglpkw08vl";
})
(fetchNuGet {
pname = "Microsoft.Extensions.Primitives";
version = "2.1.1";
sha256 = "033rkqdffybq5prhc7nn6v68zij393n00s5a82yf2n86whwvdfwx";
})
(fetchNuGet {
pname = "Microsoft.NET.Test.Sdk";
version = "17.1.0";
sha256 = "1jaq11fhcfiylnn6wvbp2k9hrgq4cz755sfqjqjqcdxlkiyj2dkw";
})
(fetchNuGet {
pname = "Microsoft.NETCore.Platforms";
version = "1.0.1";
sha256 = "01al6cfxp68dscl15z7rxfw9zvhm64dncsw09a1vmdkacsa2v6lr";
})
(fetchNuGet {
pname = "Microsoft.NETCore.Platforms";
version = "1.1.0";
sha256 = "08vh1r12g6ykjygq5d3vq09zylgb84l63k49jc4v8faw9g93iqqm";
})
(fetchNuGet {
pname = "Microsoft.NETCore.Platforms";
version = "2.0.0";
sha256 = "1fk2fk2639i7nzy58m9dvpdnzql4vb8yl8vr19r2fp8lmj9w2jr0";
})
(fetchNuGet {
pname = "Microsoft.NETCore.Targets";
version = "1.0.1";
sha256 = "0ppdkwy6s9p7x9jix3v4402wb171cdiibq7js7i13nxpdky7074p";
})
(fetchNuGet {
pname = "Microsoft.SourceLink.AzureRepos.Git";
version = "1.1.1";
sha256 = "059c8i2vybprn63sw2jr7xma4yyl2syx6hzygfdpr0zd5jlgy9rz";
})
(fetchNuGet {
pname = "Microsoft.SourceLink.Bitbucket.Git";
version = "1.1.1";
sha256 = "1p7di7lihraqisd4yfslvhpwlb9zf2casssjhyad1a0hcqmgw7n9";
})
(fetchNuGet {
pname = "Microsoft.SourceLink.Common";
version = "1.1.1";
sha256 = "0xkdqs7az2cprar7jzjlgjpd64l6f8ixcmwmpkdm03fyb4s5m0bg";
})
(fetchNuGet {
pname = "Microsoft.SourceLink.GitHub";
version = "1.1.1";
sha256 = "099y35f2npvva3jk1zp8hn0vb9pwm2l0ivjasdly6y2idv53s5yy";
})
(fetchNuGet {
pname = "Microsoft.SourceLink.GitLab";
version = "1.1.1";
sha256 = "0fm50cc05fmkz77xnl6qvawkx43asdklzxhz65jnbkjp633zvx41";
})
(fetchNuGet {
pname = "Microsoft.TestPlatform.ObjectModel";
version = "17.1.0";
sha256 = "0jw577vbrplv9kga22lsipz91ww9iqi6j1wgpwga0vrayhggjsk2";
})
(fetchNuGet {
pname = "Microsoft.TestPlatform.TestHost";
version = "17.1.0";
sha256 = "0j9i078hv4qqrg2433p20pykmcjvmzarc1cy1k5f7kc7739q6vx5";
})
(fetchNuGet {
pname = "NETStandard.Library";
version = "2.0.0";
sha256 = "1bc4ba8ahgk15m8k4nd7x406nhi0kwqzbgjk2dmw52ss553xz7iy";
})
(fetchNuGet {
pname = "Newtonsoft.Json";
version = "9.0.1";
sha256 = "0mcy0i7pnfpqm4pcaiyzzji4g0c8i3a5gjz28rrr28110np8304r";
})
(fetchNuGet {
pname = "NuGet.Frameworks";
version = "5.11.0";
sha256 = "0wv26gq39hfqw9md32amr5771s73f5zn1z9vs4y77cgynxr73s4z";
})
(fetchNuGet {
pname = "NUnit";
version = "3.13.3";
sha256 = "0wdzfkygqnr73s6lpxg5b1pwaqz9f414fxpvpdmf72bvh4jaqzv6";
})
(fetchNuGet {
pname = "NUnit.Analyzers";
version = "3.3.0";
sha256 = "00wp5q361f845aywrhhfbrpwd2srgygiam30pvn846b5dbl41vy0";
})
(fetchNuGet {
pname = "NUnit3TestAdapter";
version = "4.2.1";
sha256 = "0gildh4xcb6gkxcrrgh5a1j7lq0a7l670jpbs71akl5b5bgy5gc3";
})
(fetchNuGet {
pname = "Perfolizer";
version = "0.2.1";
sha256 = "012aqqi3y3nfikqmn26yajpwd52c04zlzp0p91iyslw7mf26qncy";
})
(fetchNuGet {
pname = "runtime.any.System.Collections";
version = "4.0.11";
sha256 = "1x44bm1cgv28zmrp095wf9mn8a6a0ivnzp9v14dcbhx06igxzgg0";
})
(fetchNuGet {
pname = "runtime.any.System.Diagnostics.Tools";
version = "4.0.1";
sha256 = "0qcpm90hrm9gx9pmxlvfml65jm0bwpr5dg3r7l7xm9nvmibvc7n7";
})
(fetchNuGet {
pname = "runtime.any.System.Globalization";
version = "4.0.11";
sha256 = "0240rp66pi5bw1xklmh421hj7arwcdmjmgfkiq1cbc6nrm8ah286";
})
(fetchNuGet {
pname = "runtime.any.System.IO";
version = "4.1.0";
sha256 = "0kasfkjiml2kk8prnyn1990nhsahnjggvqwszqjdsfwfl43vpcb5";
})
(fetchNuGet {
pname = "runtime.any.System.Reflection";
version = "4.1.0";
sha256 = "06kcs059d5czyakx75rvlwa2mr86156w18fs7chd03f7084l7mq6";
})
(fetchNuGet {
pname = "runtime.any.System.Reflection.Extensions";
version = "4.0.1";
sha256 = "05k34ijz9g9csh0vbbv3g3lrxl163izwcfncmbcl7k073h32rzkr";
})
(fetchNuGet {
pname = "runtime.any.System.Reflection.Primitives";
version = "4.0.1";
sha256 = "1zxrpvixr5fqzkxpnin6g6gjq6xajy1snghz99ds2dwbhm276rhz";
})
(fetchNuGet {
pname = "runtime.any.System.Resources.ResourceManager";
version = "4.0.1";
sha256 = "1jmgs7hynb2rff48623wnyb37558bbh1q28k9c249j5r5sgsr5kr";
})
(fetchNuGet {
pname = "runtime.any.System.Runtime";
version = "4.1.0";
sha256 = "0mjr2bi7wvnkphfjqgkyf8vfyvy15a829jz6mivl6jmksh2bx40m";
})
(fetchNuGet {
pname = "runtime.any.System.Runtime.Handles";
version = "4.0.1";
sha256 = "1kswgqhy34qvc49i981fk711s7knd6z13bp0rin8ms6axkh98nas";
})
(fetchNuGet {
pname = "runtime.any.System.Runtime.InteropServices";
version = "4.1.0";
sha256 = "0gm8if0hcmp1qys1wmx4970k2x62pqvldgljsyzbjhiy5644vl8z";
})
(fetchNuGet {
pname = "runtime.any.System.Text.Encoding";
version = "4.0.11";
sha256 = "0m4vgmzi1ky8xlj0r7xcyazxln3j9dlialnk6d2gmgrfnzf8f9m7";
})
(fetchNuGet {
pname = "runtime.any.System.Text.Encoding.Extensions";
version = "4.0.11";
sha256 = "0d1rxxpvg9v7wlibsfgz0r4hwigpadas822qf8m8fs1gma9gs877";
})
(fetchNuGet {
pname = "runtime.any.System.Threading.Tasks";
version = "4.0.11";
sha256 = "1qzdp09qs8br5qxzlm1lgbjn4n57fk8vr1lzrmli2ysdg6x1xzvk";
})
(fetchNuGet {
pname = "runtime.native.System";
version = "4.0.0";
sha256 = "1ppk69xk59ggacj9n7g6fyxvzmk1g5p4fkijm0d7xqfkig98qrkf";
})
(fetchNuGet {
pname = "runtime.native.System.Security.Cryptography";
version = "4.0.0";
sha256 = "0k57aa2c3b10wl3hfqbgrl7xq7g8hh3a3ir44b31dn5p61iiw3z9";
})
(fetchNuGet {
pname = "runtime.unix.System.Diagnostics.Debug";
version = "4.0.11";
sha256 = "05ndbai4vpqrry0ghbfgqc8xblmplwjgndxmdn1zklqimczwjg2d";
})
(fetchNuGet {
pname = "runtime.unix.System.IO.FileSystem";
version = "4.0.1";
sha256 = "02wnlydnbhai0zy7c3kihg0cis0l1b2z78kyi1ci47c5v0jklwha";
})
(fetchNuGet {
pname = "runtime.unix.System.Private.Uri";
version = "4.0.1";
sha256 = "0ic5dgc45jkhcr1g9xmmzjm7ffiw4cymm0fprczlx4fnww4783nm";
})
(fetchNuGet {
pname = "runtime.unix.System.Runtime.Extensions";
version = "4.1.0";
sha256 = "0x1cwd7cvifzmn5x1wafvj75zdxlk3mxy860igh3x1wx0s8167y4";
})
(fetchNuGet {
pname = "System.CodeDom";
version = "6.0.0";
sha256 = "1i55cxp8ycc03dmxx4n22qi6jkwfl23cgffb95izq7bjar8avxxq";
})
(fetchNuGet {
pname = "System.Collections";
version = "4.0.11";
sha256 = "1ga40f5lrwldiyw6vy67d0sg7jd7ww6kgwbksm19wrvq9hr0bsm6";
})
(fetchNuGet {
pname = "System.Collections.Immutable";
version = "1.5.0";
sha256 = "1d5gjn5afnrf461jlxzawcvihz195gayqpcfbv6dd7pxa9ialn06";
})
(fetchNuGet {
pname = "System.Collections.Immutable";
version = "5.0.0";
sha256 = "1kvcllagxz2q92g81zkz81djkn2lid25ayjfgjalncyc68i15p0r";
})
(fetchNuGet {
pname = "System.Diagnostics.Debug";
version = "4.0.11";
sha256 = "0gmjghrqmlgzxivd2xl50ncbglb7ljzb66rlx8ws6dv8jm0d5siz";
})
(fetchNuGet {
pname = "System.Diagnostics.Tools";
version = "4.0.1";
sha256 = "19cknvg07yhakcvpxg3cxa0bwadplin6kyxd8mpjjpwnp56nl85x";
})
(fetchNuGet {
pname = "System.Dynamic.Runtime";
version = "4.0.11";
sha256 = "1pla2dx8gkidf7xkciig6nifdsb494axjvzvann8g2lp3dbqasm9";
})
(fetchNuGet {
pname = "System.Globalization";
version = "4.0.11";
sha256 = "070c5jbas2v7smm660zaf1gh0489xanjqymkvafcs4f8cdrs1d5d";
})
(fetchNuGet {
pname = "System.IO";
version = "4.1.0";
sha256 = "1g0yb8p11vfd0kbkyzlfsbsp5z44lwsvyc0h3dpw6vqnbi035ajp";
})
(fetchNuGet {
pname = "System.IO.FileSystem";
version = "4.0.1";
sha256 = "0kgfpw6w4djqra3w5crrg8xivbanh1w9dh3qapb28q060wb9flp1";
})
(fetchNuGet {
pname = "System.IO.FileSystem.Primitives";
version = "4.0.1";
sha256 = "1s0mniajj3lvbyf7vfb5shp4ink5yibsx945k6lvxa96r8la1612";
})
(fetchNuGet {
pname = "System.Linq";
version = "4.1.0";
sha256 = "1ppg83svb39hj4hpp5k7kcryzrf3sfnm08vxd5sm2drrijsla2k5";
})
(fetchNuGet {
pname = "System.Linq.Expressions";
version = "4.1.0";
sha256 = "1gpdxl6ip06cnab7n3zlcg6mqp7kknf73s8wjinzi4p0apw82fpg";
})
(fetchNuGet {
pname = "System.Management";
version = "6.0.0";
sha256 = "0ra1g75ykapg6i5y0za721kpjd6xcq6dalijkdm6fsxxmz8iz4dr";
})
(fetchNuGet {
pname = "System.Memory";
version = "4.5.1";
sha256 = "0f07d7hny38lq9w69wx4lxkn4wszrqf9m9js6fh9is645csm167c";
})
(fetchNuGet {
pname = "System.Memory";
version = "4.5.3";
sha256 = "0naqahm3wljxb5a911d37mwjqjdxv9l0b49p5dmfyijvni2ppy8a";
})
(fetchNuGet {
pname = "System.ObjectModel";
version = "4.0.12";
sha256 = "1sybkfi60a4588xn34nd9a58png36i0xr4y4v4kqpg8wlvy5krrj";
})
(fetchNuGet {
pname = "System.Private.Uri";
version = "4.0.1";
sha256 = "0k57qhawjysm4cpbfpc49kl4av7lji310kjcamkl23bwgij5ld9j";
})
(fetchNuGet {
pname = "System.Reflection";
version = "4.1.0";
sha256 = "1js89429pfw79mxvbzp8p3q93il6rdff332hddhzi5wqglc4gml9";
})
(fetchNuGet {
pname = "System.Reflection.Emit";
version = "4.0.1";
sha256 = "0ydqcsvh6smi41gyaakglnv252625hf29f7kywy2c70nhii2ylqp";
})
(fetchNuGet {
pname = "System.Reflection.Emit";
version = "4.7.0";
sha256 = "121l1z2ypwg02yz84dy6gr82phpys0njk7yask3sihgy214w43qp";
})
(fetchNuGet {
pname = "System.Reflection.Emit.ILGeneration";
version = "4.0.1";
sha256 = "1pcd2ig6bg144y10w7yxgc9d22r7c7ww7qn1frdfwgxr24j9wvv0";
})
(fetchNuGet {
pname = "System.Reflection.Emit.Lightweight";
version = "4.0.1";
sha256 = "1s4b043zdbx9k39lfhvsk68msv1nxbidhkq6nbm27q7sf8xcsnxr";
})
(fetchNuGet {
pname = "System.Reflection.Emit.Lightweight";
version = "4.7.0";
sha256 = "0mbjfajmafkca47zr8v36brvknzks5a7pgb49kfq2d188pyv6iap";
})
(fetchNuGet {
pname = "System.Reflection.Extensions";
version = "4.0.1";
sha256 = "0m7wqwq0zqq9gbpiqvgk3sr92cbrw7cp3xn53xvw7zj6rz6fdirn";
})
(fetchNuGet {
pname = "System.Reflection.Metadata";
version = "1.6.0";
sha256 = "1wdbavrrkajy7qbdblpbpbalbdl48q3h34cchz24gvdgyrlf15r4";
})
(fetchNuGet {
pname = "System.Reflection.Primitives";
version = "4.0.1";
sha256 = "1bangaabhsl4k9fg8khn83wm6yial8ik1sza7401621jc6jrym28";
})
(fetchNuGet {
pname = "System.Reflection.TypeExtensions";
version = "4.1.0";
sha256 = "1bjli8a7sc7jlxqgcagl9nh8axzfl11f4ld3rjqsyxc516iijij7";
})
(fetchNuGet {
pname = "System.Resources.ResourceManager";
version = "4.0.1";
sha256 = "0b4i7mncaf8cnai85jv3wnw6hps140cxz8vylv2bik6wyzgvz7bi";
})
(fetchNuGet {
pname = "System.Runtime";
version = "4.1.0";
sha256 = "02hdkgk13rvsd6r9yafbwzss8kr55wnj8d5c7xjnp8gqrwc8sn0m";
})
(fetchNuGet {
pname = "System.Runtime.CompilerServices.Unsafe";
version = "4.5.0";
sha256 = "17labczwqk3jng3kkky73m0jhi8wc21vbl7cz5c0hj2p1dswin43";
})
(fetchNuGet {
pname = "System.Runtime.CompilerServices.Unsafe";
version = "4.5.3";
sha256 = "1afi6s2r1mh1kygbjmfba6l4f87pi5sg13p4a48idqafli94qxln";
})
(fetchNuGet {
pname = "System.Runtime.CompilerServices.Unsafe";
version = "5.0.0";
sha256 = "02k25ivn50dmqx5jn8hawwmz24yf0454fjd823qk6lygj9513q4x";
})
(fetchNuGet {
pname = "System.Runtime.Extensions";
version = "4.1.0";
sha256 = "0rw4rm4vsm3h3szxp9iijc3ksyviwsv6f63dng3vhqyg4vjdkc2z";
})
(fetchNuGet {
pname = "System.Runtime.Handles";
version = "4.0.1";
sha256 = "1g0zrdi5508v49pfm3iii2hn6nm00bgvfpjq1zxknfjrxxa20r4g";
})
(fetchNuGet {
pname = "System.Runtime.InteropServices";
version = "4.1.0";
sha256 = "01kxqppx3dr3b6b286xafqilv4s2n0gqvfgzfd4z943ga9i81is1";
})
(fetchNuGet {
pname = "System.Runtime.Serialization.Primitives";
version = "4.1.1";
sha256 = "042rfjixknlr6r10vx2pgf56yming8lkjikamg3g4v29ikk78h7k";
})
(fetchNuGet {
pname = "System.Text.Encoding";
version = "4.0.11";
sha256 = "1dyqv0hijg265dwxg6l7aiv74102d6xjiwplh2ar1ly6xfaa4iiw";
})
(fetchNuGet {
pname = "System.Text.Encoding.CodePages";
version = "4.5.0";
sha256 = "19x38911pawq4mrxrm04l2bnxwxxlzq8v8rj4cbxnfjj8pnd3vj3";
})
(fetchNuGet {
pname = "System.Text.Encoding.Extensions";
version = "4.0.11";
sha256 = "08nsfrpiwsg9x5ml4xyl3zyvjfdi4mvbqf93kjdh11j4fwkznizs";
})
(fetchNuGet {
pname = "System.Text.RegularExpressions";
version = "4.1.0";
sha256 = "1mw7vfkkyd04yn2fbhm38msk7dz2xwvib14ygjsb8dq2lcvr18y7";
})
(fetchNuGet {
pname = "System.Threading";
version = "4.0.11";
sha256 = "19x946h926bzvbsgj28csn46gak2crv2skpwsx80hbgazmkgb1ls";
})
(fetchNuGet {
pname = "System.Threading.Tasks";
version = "4.0.11";
sha256 = "0nr1r41rak82qfa5m0lhk9mp0k93bvfd7bbd9sdzwx9mb36g28p5";
})
(fetchNuGet {
pname = "System.Threading.Tasks.Extensions";
version = "4.0.0";
sha256 = "1cb51z062mvc2i8blpzmpn9d9mm4y307xrwi65di8ri18cz5r1zr";
})
(fetchNuGet {
pname = "System.Threading.Tasks.Extensions";
version = "4.5.4";
sha256 = "0y6ncasgfcgnjrhynaf0lwpkpkmv4a07sswwkwbwb5h7riisj153";
})
(fetchNuGet {
pname = "System.Xml.ReaderWriter";
version = "4.0.11";
sha256 = "0c6ky1jk5ada9m94wcadih98l6k1fvf6vi7vhn1msjixaha419l5";
})
(fetchNuGet {
pname = "System.Xml.XDocument";
version = "4.0.11";
sha256 = "0n4lvpqzy9kc7qy1a4acwwd7b7pnvygv895az5640idl2y9zbz18";
})
]

View File

@@ -1,73 +0,0 @@
#!/bin/bash
# This file was adapted from
# https://github.com/NixOS/nixpkgs/blob/b981d811453ab84fb3ea593a9b33b960f1ab9147/pkgs/build-support/dotnet/build-dotnet-module/default.nix#L173
set -euo pipefail
export PATH="@binPath@"
for arg in "$@"; do
case "$arg" in
--keep-sources|-k)
keepSources=1
shift
;;
--help|-h)
echo "usage: $0 [--keep-sources] [--help] <output path>"
echo " <output path> The path to write the lockfile to. A temporary file is used if this is not set"
echo " --keep-sources Don't remove temporary directories upon exit, useful for debugging"
echo " --help Show this help message"
exit
;;
esac
done
tmp=$(mktemp -td "@pname@-tmp-XXXXXX")
export tmp
HOME=$tmp/home
exitTrap() {
test -n "${ranTrap-}" && return
ranTrap=1
if test -n "${keepSources-}"; then
echo -e "Path to the source: $tmp/src\nPath to the fake home: $tmp/home"
else
rm -rf "$tmp"
fi
# Since mktemp is used this will be empty if the script didnt succesfully complete
if ! test -s "$depsFile"; then
rm -rf "$depsFile"
fi
}
trap exitTrap EXIT INT TERM
dotnetRestore() {
local -r project="${1-}"
local -r rid="$2"
dotnet restore "${project-}" \
-p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \
--packages "$tmp/nuget_pkgs" \
--runtime "$rid" \
--no-cache \
--force
}
declare -a projectFiles=( @projectFiles@ )
declare -a testProjectFiles=( @testProjectFiles@ )
export DOTNET_NOLOGO=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
depsFile=$(realpath "${1:-$(mktemp -t "@pname@-deps-XXXXXX.nix")}")
mkdir -p "$tmp/nuget_pkgs"
storeSrc="@storeSrc@"
src="$tmp/src"
cp -rT "$storeSrc" "$src"
chmod -R +w "$src"
cd "$src"
echo "Restoring project..."
rids=(@rids@)
for rid in "${rids[@]}"; do
(( ${#projectFiles[@]} == 0 )) && dotnetRestore "" "$rid"
for project in "${projectFiles[@]-}" "${testProjectFiles[@]-}"; do
dotnetRestore "$project" "$rid"
done
done
echo "Successfully restored project"
echo "Writing lockfile..."
echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please don't edit it manually, your changes might get overwritten!\n" > "$depsFile"
nuget-to-nix "$tmp/nuget_pkgs" "@packages@" >> "$depsFile"
echo "Successfully wrote lockfile to $depsFile"