Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

2023-03

2023-03.livemd

2023-03

Mix.install(
  [
    {:benchee, "~> 1.2"},
    # {:exla, "~> 0.6.0"},
    # {:explorer, "~> 0.7"},
    {:kino, "~> 0.11.0"},
    {:kino_aoc, "~> 0.1.5"}
    # {:kino_vega_lite, "~> 0.1.11"},
    # {:nimble_parsec, "~> 1.4"},
    # {:nx, "~> 0.6.0"}
  ]
  # config: [
  #   nx: [
  #     default_backend: EXLA.Backend,
  #     default_defn_options: [compiler: EXLA]
  #   ],
  #   exla: [
  #     default_client: :cuda,
  #     clients: [
  #       host: [platform: :host],
  #       cuda: [platform: :cuda]
  #     ]
  #   ]
  # ],
  # system_env: [
  #   XLA_TARGET: "cuda120"
  # ]
)

# Nx.global_default_backend(EXLA.Backend)

Problem

{:ok, input} = KinoAOC.download_puzzle("2023", "3", System.fetch_env!("LB_AOC_SESSION"))
{:ok,
 ".....664...998........343...............851............................2............414.....................3....................948.164....\n......*..................*617....885...*....................-......250.........536..........470...#..................../4......=.....*......\n...407...570..218................-.....654........776.....920.........*753...........566......*..347.....61.-979..786........935...42.......\n.......%....*...$..311.102..........................*.907.....723...............622-....*..354..............................................\n.....266..............*....987.554...........&....288...#......#.......................69......41..........486..-...........................\n.849................................&........781...........978......724*..196..../767................725..../...892.....*355.....815.390....\n....*......@.....*988......%........704...............*......&...........*...................826.....................243.......#....*.......\n...796......729.9.........490..721....................438.=....272..54&...926..481..............*..523......&.785...........766.......*493..\n........281.........706...........=.666.......505.........579.*................./...669.........73...*...639...*.......479.........514......\n...........*...386.......375..................................525.926..$120............&.580.........457........325.......*829..............\n.....758..662.......937....%...661.24......749*323...444.............*.............583....*.........................................223.....\n.......*........665....*...........*................@.................154......965..*....119.......620*............347.................*470.\n........391.........183.........75..783../....................209.312............*...362........./.....667..........*....77.................\n...379=..........................$......261..228........907......*.......+591...178.........227.704........@771..667..........268......543..\n.......................#.....................*..........*....................................-........*581...........101........*.....*.....\n................471...545..135........432..178....$225..143...973#..322............2.................................*...........239...985..\n......728*612...*.........*.....65....................................*...........*................&..............527....255+../............\n..255.........435.304....854...................-............=........261......&...749....+......196....694......................779..271.374\n......604.........*.....................708.....922.......76..82*554......991..19........456............*..582.........597@.................\n.................374..*........*707........................................*....................609...52....%.................483...........\n..../..................739......................$..........649...973.*511.861..20%.................=.....................148....*......343..\n...978.................................282&...401......961....-.*.........................................499%.........../.....347..........\n.................+..174..315.-819.................841.....*66......820.836......8....60....456........*........434..........................\n....62%.......908......./.................770....../..................*.....852......&.....*........317...%......@.......+.......691........\n........793......../......411......963.......*594..................@........@......*.......45.............729...........306.148....*..@.....\n626.......$......35..........*........*...........................77.134........584.....23....35................589........./...482..853....\n.......................366..668.........................238...........*..265.........*..........*...........&......*...471..................\n..741.............679.................@.807...76....185*...........211..%.........507....178..583....*.561...521..620...*....865.$247.494...\n.....*.....383.....%..183..876......179..$..................254.........................$..........697.*..............935...*...............\n...50.." <> ...}

Solvers

defmodule PartOne do
  @numbers ~r/[0-9]+/
  @symbols ~r/[%&#=@\?\*\+\$\-\/]/

  @doc ~S"""
      iex> PartOne.parse("617*......")
      [617]

      iex> PartOne.parse("617.......\n..$.......")
      [617]
  """
  def parse(input) do
    input = String.split(input, "\n", trim: true)

    symbols = extract_symbol_coords(input)

    for {line, y} <- Enum.with_index(input),
        matches <- Regex.scan(@numbers, line, capture: :first, return: :index),
        {x, width} <- matches,
        reduce: [] do
      acc ->
        if symbol_adjacent?(x, x + width - 1, y, symbols) do
          s = String.slice(line, x, width)
          n = String.to_integer(s)
          [n | acc]
        else
          acc
        end
    end
  end

  def process(input) do
    Enum.sum(input)
  end

  def solve(input) do
    input
    |> parse()
    |> process()
  end

  @doc ~S"""
      iex> PartOne.extract_symbol_coords(["*..",".$.",".?.","..+"])
      MapSet.new([{0, 0}, {1, 1}, {1, 2}, {2, 3}])
  """
  def extract_symbol_coords(inputs, rx \\ @symbols) do
    for {line, y} <- Enum.with_index(inputs),
        matches <- Regex.scan(rx, line, capture: :first, return: :index),
        {x, 1} <- matches,
        reduce: MapSet.new() do
      acc ->
        MapSet.put(acc, {x, y})
    end
  end

  # determine a bounding box
  def surrounding_coords(x1, x2, y) do
    for x <- (x1 - 1)..(x2 + 1),
        ny <- (y - 1)..(y + 1),
        x >= 0,
        y >= 0,
        not (x in x1..x2 and ny == y) do
      {x, ny}
    end
  end

  def symbol_adjacent?(x1, x2, y, symbols) do
    Enum.any?(surrounding_coords(x1, x2, y), &amp;MapSet.member?(symbols, &amp;1))
  end
end
{:module, PartOne, <<70, 79, 82, 49, 0, 0, 24, ...>>, {:symbol_adjacent?, 4}}
defmodule PartTwo do
  @numbers ~r/\d+/
  @gears ~r/\*/

  def parse(input) do
    input = String.split(input, "\n", trim: true)

    gears = extract_gear_coords(input)
    numbers = extract_number_coords(input)

    find_gear_ratios(gears, numbers)
  end

  def process(input) do
    Enum.sum(input)
  end

  def solve(input) do
    input
    |> parse()
    |> process()
  end

  def extract_gear_coords(inputs), do: PartOne.extract_symbol_coords(inputs, @gears)

  def extract_number_coords(inputs) do
    for {line, y} <- Enum.with_index(inputs),
        numbers <- Regex.scan(@numbers, line, capture: :first, return: :index),
        {x, width} <- numbers,
        s = String.slice(line, x, width),
        n = String.to_integer(s),
        x <- x..(x + width - 1),
        into: %{} do
      {{x, y}, n}
    end
  end

  def find_gear_ratios(gears, numbers) do
    for {gx, gy} <- gears, reduce: [] do
      acc ->
        adj = PartOne.surrounding_coords(gx, gx, gy)
        adj_numbers = numbers |> Map.take(adj) |> Map.values() |> Enum.uniq()

        case adj_numbers do
          [l, r] -> [l * r | acc]
          _ -> acc
        end
    end
  end
end
{:module, PartTwo, <<70, 79, 82, 49, 0, 0, 19, ...>>, {:find_gear_ratios, 2}}

Solutions

PartOne.solve(input)
509115
PartTwo.solve(input)
75220503

Tests

ExUnit.start(auto_run: false, seed: 12345, timeout: 5000)

defmodule PartOneTest do
  use ExUnit.Case, async: true

  doctest PartOne

  describe "Part One" do
    @test_input """
    467..114..
    ...*......
    ..35..633.
    ......#...
    617*......
    .....+.58.
    ..592.....
    ......755.
    ...$.*....
    .664.598..
    """
    test "sums part numbers" do
      assert PartOne.solve(@test_input) == 4361
    end
  end
end

defmodule PartTwoTest do
  use ExUnit.Case, async: true

  doctest PartOne

  describe "Part Two" do
    @test_input """
    467..114..
    ...*......
    ..35..633.
    ......#...
    617*......
    .....+.58.
    ..592.....
    ......755.
    ...$.*....
    .664.598..
    """
    test "sums gear ratios" do
      assert PartTwo.solve(@test_input) == 467_835
    end
  end
end

ExUnit.run()
........
Finished in 0.00 seconds (0.00s async, 0.00s sync)
6 doctests, 2 tests, 0 failures

Randomized with seed 12345
%{total: 8, skipped: 0, failures: 0, excluded: 0}

Golfing

Benchmarks

Benchee.run(
  %{
    "PartOne" => &amp;PartOne.solve/1,
    "PartTwo" => &amp;PartTwo.solve/1
  },
  inputs: %{
    input: input,
    test_input: """
    467..114..
    ...*......
    ..35..633.
    ......#...
    617*......
    .....+.58.
    ..592.....
    ......755.
    ...$.*....
    .664.598..
    """
  },
  warmup: 2,
  time: 3,
  memory_time: 3,
  reduction_time: 3
)
Operating System: Linux
CPU Information: AMD Ryzen 9 5950X 16-Core Processor
Number of Available Cores: 32
Available memory: 62.71 GB
Elixir 1.15.7
Erlang 26.1.2

Benchmark suite executing with the following configuration:
warmup: 2 s
time: 3 s
memory time: 3 s
reduction time: 3 s
parallel: 1
inputs: input, test_input
Estimated total run time: 44 s

Benchmarking PartOne with input input ...
Benchmarking PartOne with input test_input ...
Benchmarking PartTwo with input input ...
Benchmarking PartTwo with input test_input ...

##### With input input #####
Name              ips        average  deviation         median         99th %
PartTwo        238.80        4.19 ms     ±6.37%        4.02 ms        4.97 ms
PartOne        194.77        5.13 ms     ±5.64%        5.00 ms        6.16 ms

Comparison: 
PartTwo        238.80
PartOne        194.77 - 1.23x slower +0.95 ms

Memory usage statistics:

Name       Memory usage
PartTwo         9.96 MB
PartOne        10.88 MB - 1.09x memory usage +0.92 MB

**All measurements for memory usage were the same**

Reduction count statistics:

Name            average  deviation         median         99th %
PartTwo        407.13 K     ±0.01%       407.12 K       407.30 K
PartOne        625.99 K     ±0.00%       625.99 K       625.99 K

Comparison: 
PartTwo        407.12 K
PartOne        625.99 K - 1.54x reduction count +218.86 K

##### With input test_input #####
Name              ips        average  deviation         median         99th %
PartTwo       28.82 K       34.69 μs    ±13.42%       33.47 μs       48.74 μs
PartOne       23.41 K       42.72 μs     ±8.05%       41.51 μs       51.46 μs

Comparison: 
PartTwo       28.82 K
PartOne       23.41 K - 1.23x slower +8.02 μs

Memory usage statistics:

Name       Memory usage
PartTwo        26.60 KB
PartOne        40.39 KB - 1.52x memory usage +13.79 KB

**All measurements for memory usage were the same**

Reduction count statistics:

Name    Reduction count
PartTwo          2.23 K
PartOne          4.22 K - 1.90x reduction count +2.00 K

**All measurements for reduction count were the same**
%Benchee.Suite{
  system: %{
    erlang: "26.1.2",
    os: :Linux,
    elixir: "1.15.7",
    available_memory: "62.71 GB",
    cpu_speed: "AMD Ryzen 9 5950X 16-Core Processor",
    num_cores: 32
  },
  configuration: %Benchee.Configuration{
    parallel: 1,
    time: 3000000000.0,
    warmup: 2000000000.0,
    memory_time: 3000000000.0,
    reduction_time: 3000000000.0,
    pre_check: false,
    formatters: [Benchee.Formatters.Console],
    percentiles: ~c"2c",
    print: %{configuration: true, benchmarking: true, fast_warning: true},
    inputs: [
      {"input",
       ".....664...998........343...............851............................2............414.....................3....................948.164....\n......*..................*617....885...*....................-......250.........536..........470...#..................../4......=.....*......\n...407...570..218................-.....654........776.....920.........*753...........566......*..347.....61.-979..786........935...42.......\n.......%....*...$..311.102..........................*.907.....723...............622-....*..354..............................................\n.....266..............*....987.554...........&....288...#......#.......................69......41..........486..-...........................\n.849................................&........781...........978......724*..196..../767................725..../...892.....*355.....815.390....\n....*......@.....*988......%........704...............*......&...........*...................826.....................243.......#....*.......\n...796......729.9.........490..721....................438.=....272..54&...926..481..............*..523......&.785...........766.......*493..\n........281.........706...........=.666.......505.........579.*................./...669.........73...*...639...*.......479.........514......\n...........*...386.......375..................................525.926..$120............&.580.........457........325.......*829..............\n.....758..662.......937....%...661.24......749*323...444.............*.............583....*.........................................223.....\n.......*........665....*...........*................@.................154......965..*....119.......620*............347.................*470.\n........391.........183.........75..783../....................209.312............*...362........./.....667..........*....77.................\n...379=..........................$......261..228........907......*.......+591...178.........227.704........@771..667..........268......543..\n.......................#.....................*..........*....................................-........*581...........101........*.....*.....\n................471...545..135........432..178....$225..143...973#..322............2.................................*...........239...985..\n......728*612...*.........*.....65....................................*...........*................&..............527....255+../............\n..255.........435.304....854...................-............=........261......&...749....+......196....694......................779..271.374\n......604.........*.....................708.....922.......76..82*554......991..19........456............*..582.........597@.................\n.................374..*........*707........................................*....................609...52....%.................483...........\n..../..................739......................$..........649...973.*511.861..20%.................=.....................148....*......343..\n...978.................................282&...401......961....-.*.........................................499%.........../.....347..........\n.................+..174..315.-819.................841.....*66......820.836......8....60....456........*........434..........................\n....62%.......908......./.................770....../..................*.....852......&.....*........317...%......@.......+.......691........\n........793......../......411......963.......*594..................@........@......*.......45.............729...........306.148....*..@.....\n626.......$......35..........*........*...........................77.134........584.....23....35................589........./...482..853....\n.......................366..668.........................238...........*..265.........*..........*...........&......*...471..................\n..741.............679.................@.807...76....185*...........211..%.........507....178..583....*.561...521..620...*....865.$247.494...\n.....*.....383.....%..183..876......179..$..................254.........................$..........697.*..............935...*...............\n...50.." <> ...},
      {"test_input",
       "467..114..\n...*......\n..35..633.\n......#...\n617*......\n.....+.58.\n..592.....\n......755.\n...$.*....\n.664.598..\n"}
    ],
    save: false,
    load: false,
    unit_scaling: :best,
    assigns: %{},
    before_each: nil,
    after_each: nil,
    before_scenario: nil,
    after_scenario: nil,
    measure_function_call_overhead: false,
    title: nil,
    profile_after: false
  },
  scenarios: [
    %Benchee.Scenario{
      name: "PartTwo",
      job_name: "PartTwo",
      function: &PartTwo.solve/1,
      input_name: "input",
      input: ".....664...998........343...............851............................2............414.....................3....................948.164....\n......*..................*617....885...*....................-......250.........536..........470...#..................../4......=.....*......\n...407...570..218................-.....654........776.....920.........*753...........566......*..347.....61.-979..786........935...42.......\n.......%....*...$..311.102..........................*.907.....723...............622-....*..354..............................................\n.....266..............*....987.554...........&....288...#......#.......................69......41..........486..-...........................\n.849................................&........781...........978......724*..196..../767................725..../...892.....*355.....815.390....\n....*......@.....*988......%........704...............*......&...........*...................826.....................243.......#....*.......\n...796......729.9.........490..721....................438.=....272..54&...926..481..............*..523......&.785...........766.......*493..\n........281.........706...........=.666.......505.........579.*................./...669.........73...*...639...*.......479.........514......\n...........*...386.......375..................................525.926..$120............&.580.........457........325.......*829..............\n.....758..662.......937....%...661.24......749*323...444.............*.............583....*.........................................223.....\n.......*........665....*...........*................@.................154......965..*....119.......620*............347.................*470.\n........391.........183.........75..783../....................209.312............*...362........./.....667..........*....77.................\n...379=..........................$......261..228........907......*.......+591...178.........227.704........@771..667..........268......543..\n.......................#.....................*..........*....................................-........*581...........101........*.....*.....\n................471...545..135........432..178....$225..143...973#..322............2.................................*...........239...985..\n......728*612...*.........*.....65....................................*...........*................&..............527....255+../............\n..255.........435.304....854...................-............=........261......&...749....+......196....694......................779..271.374\n......604.........*.....................708.....922.......76..82*554......991..19........456............*..582.........597@.................\n.................374..*........*707........................................*....................609...52....%.................483...........\n..../..................739......................$..........649...973.*511.861..20%.................=.....................148....*......343..\n...978.................................282&...401......961....-.*.........................................499%.........../.....347..........\n.................+..174..315.-819.................841.....*66......820.836......8....60....456........*........434..........................\n....62%.......908......./.................770....../..................*.....852......&.....*........317...%......@.......+.......691........\n........793......../......411......963.......*594..................@........@......*.......45.............729...........306.148....*..@.....\n626.......$......35..........*........*...........................77.134........584.....23....35................589........./...482..853....\n.......................366..668.........................238...........*..265.........*..........*...........&......*...471..................\n..741.............679.................@.807...76....185*...........211..%.........507....178..583....*.561...521..620...*....865.$247.494...\n.....*.....383.....%..183..876......179..$..................254.........................$..........697.*..............935...*...............\n...50.." <> ...,
      before_each: nil,
      after_each: nil,
      before_scenario: nil,
      after_scenario: nil,
      tag: nil,
      run_time_data: %Benchee.CollectionData{
        statistics: %Benchee.Statistics{
          average: 4187692.1324965134,
          ips: 238.79501366396892,
          std_dev: 266573.37743201025,
          std_dev_ratio: 0.06365639330632723,
          std_dev_ips: 15.20082930938339,
          median: 4023533.0,
          percentiles: %{50 => 4023533.0, 99 => 4967140.620000002},
          mode: [3996262, 4461631, 4005792, 3996012, 4003492, 3978922],
          minimum: 3949211,
          maximum: 6093355,
          relative_more: nil,
          relative_less: nil,
          absolute_difference: nil,
          sample_size: 717
        },
        samples: [4141365, 4495432, 4134235, 4114545, 4104204, 4330999, 3986222, 4413560, 3969582,
         3949211, 5314639, 4665166, 4045074, 3992042, 4336179, 4249857, 4150586, 4679656, 4086194,
         4084514, 4101804, 4345410, 3975201, 4599145, 4127525, 4107484, 4122605, 4803849, 4057053,
         3991672, 4353060, 4282678, 4146835, ...]
      },
      memory_usage_data: %Benchee.CollectionData{
        statistics: %Benchee.Statistics{
          average: 10439992.0,
          ips: nil,
          std_dev: 0.0,
          std_dev_ratio: 0.0,
          std_dev_ips: nil,
          median: 10439992.0,
          percentiles: %{50 => 10439992.0, 99 => 10439992.0},
          mode: 10439992,
          minimum: 10439992,
          maximum: 10439992,
          relative_more: nil,
          relative_less: nil,
          absolute_difference: nil,
          sample_size: 598
        },
        samples: [10439992, 10439992, 10439992, 10439992, 10439992, 10439992, 10439992, 10439992,
         10439992, 10439992, 10439992, 10439992, 10439992, 10439992, 10439992, 10439992, 10439992,
         10439992, 10439992, 10439992, 10439992, 10439992, 10439992, 10439992, 10439992, 10439992,
         10439992, 10439992, 10439992, 10439992, 10439992, 10439992, ...]
      },
      reductions_data: %Benchee.CollectionData{
        statistics: %Benchee.Statistics{
          average: 407131.5825105783,
          ips: nil,
          std_dev: 58.20231157109785,
          std_dev_ratio: 1.429570047408091e-4,
          std_dev_ips: nil,
          median: 407124.0,
          percentiles: %{50 => 407124.0, 99 => 407303.4},
          mode: 407091,
          minimum: 407013,
          maximum: 407395,
          relative_more: nil,
          relative_less: nil,
          absolute_difference: nil,
          sample_size: 709
        },
        samples: [407133, 407154, 407201, 407091, 407097, 407057, 407062, 407138, 407103, 407151,
         407228, 407054, 407110, 407117, 407125, 407087, 407072, 407074, 407106, 407080, 407097,
         407142, 407223, 407101, 407046, 407288, 407044, 407208, 407080, 407094, 407236, ...]
      }
    },
    %Benchee.Scenario{
      name: "PartOne",
      job_name: "PartOne",
      function: &PartOne.solve/1,
      input_name: "input",
      input: ".....664...998........343...............851............................2............414.....................3....................948.164....\n......*..................*617....885...*....................-......250.........536..........470...#..................../4......=.....*......\n...407...570..218................-.....654........776.....920.........*753...........566......*..347.....61.-979..786........935...42.......\n.......%....*...$..311.102..........................*.907.....723...............622-....*..354..............................................\n.....266..............*....987.554...........&....288...#......#.......................69......41..........486..-...........................\n.849................................&........781...........978......724*..196..../767................725..../...892.....*355.....815.390....\n....*......@.....*988......%........704...............*......&...........*...................826.....................243.......#....*.......\n...796......729.9.........490..721....................438.=....272..54&...926..481..............*..523......&.785...........766.......*493..\n........281.........706...........=.666.......505.........579.*................./...669.........73...*...639...*.......479.........514......\n...........*...386.......375..................................525.926..$120............&.580.........457........325.......*829..............\n.....758..662.......937....%...661.24......749*323...444.............*.............583....*.........................................223.....\n.......*........665....*...........*................@.................154......965..*....119.......620*............347.................*470.\n........391.........183.........75..783../....................209.312............*...362........./.....667..........*....77.................\n...379=..........................$......261..228........907......*.......+591...178.........227.704........@771..667..........268......543..\n.......................#.....................*..........*....................................-........*581...........101........*.....*.....\n................471...545..135........432..178....$225..143...973#..322............2.................................*...........239...985..\n......728*612...*.........*.....65....................................*...........*................&..............527....255+../............\n..255.........435.304....854...................-............=........261......&...749....+......196....694......................779..271.374\n......604.........*.....................708.....922.......76..82*554......991..19........456............*..582.........597@.................\n.................374..*........*707........................................*....................609...52....%.................483...........\n..../..................739......................$..........649...973.*511.861..20%.................=.....................148....*......343..\n...978.................................282&...401......961....-.*.........................................499%.........../.....347..........\n.................+..174..315.-819.................841.....*66......820.836......8....60....456........*........434..........................\n....62%.......908......./.................770....../..................*.....852......&.....*........317...%......@.......+.......691........\n........793......../......411......963.......*594..................@........@......*.......45.............729...........306.148....*..@.....\n626.......$......35..........*........*...........................77.134........584.....23....35................589........./...482..853....\n.......................366..668.........................238...........*..265.........*..........*...........&......*...471..................\n..741.............679.................@.807...76....185*...........211..%.........507....178..583....*.561...521..620...*....865.$247.494...\n.....*.....383.....%..183..876......179..$..................254.........................$..........697.*..............935...*...............\n...50.." <> ...,
      before_each: nil,
      after_each: nil,
      before_scenario: nil,
      after_scenario: nil,
      tag: nil,
      run_time_data: %Benchee.CollectionData{
        statistics: %Benchee.Statistics{
          average: 5134234.275213676,
          ips: 194.7710109037403,
          std_dev: 289460.5250648222,
          std_dev_ratio: 0.056378519083602883,
          std_dev_ips: 10.980901155169148,
          median: 5003175.0,
          percentiles: %{50 => 5003175.0, 99 => 6162481.559999998},
          mode: 4987475,
          minimum: 4740879,
          maximum: 6992837,
          relative_more: 1.226029543903667,
          relative_less: 0.8156410299999859,
          absolute_difference: 946542.1427171621,
          sample_size: 585
        },
        samples: [5524536, 5437785, 5453504, 5227781, 5214749, 5318172, 5306092, 5516676, 5450195,
         5412204, 5473176, 5457404, 5483215, 5415594, 5354823, 5285281, 5290942, 5077076, 5478256,
         5460515, 5470955, 5372493, 5349783, 5319082, 5261941, 5322592, 5543607, 5546997, 5449255,
         5458824, 5418425, 5413394, ...]
      },
      memory_usage_data: %Benchee.CollectionData{
        statistics: %Benchee.Statistics{
          average: 11404824.0,
          ips: nil,
          std_dev: 0.0,
          std_dev_ratio: 0.0,
          std_dev_ips: nil,
          median: 11404824.0,
          percentiles: %{50 => 11404824.0, 99 => 11404824.0},
          mode: 11404824,
          minimum: 11404824,
          maximum: 11404824,
          relative_more: 1.092416929055118,
          relative_less: 0.9154014125952317,
          absolute_difference: 964832.0,
          sample_size: 438
        },
        samples: [11404824, 11404824, 11404824, 11404824, 11404824, 11404824, 11404824, 11404824,
         11404824, 11404824, 11404824, 11404824, 11404824, 11404824, 11404824, 11404824, 11404824,
         11404824, 11404824, 11404824, 11404824, 11404824, 11404824, 11404824, 11404824, 11404824,
         11404824, 11404824, 11404824, 11404824, 11404824, ...]
      },
      reductions_data: %Benchee.CollectionData{
        statistics: %Benchee.Statistics{
          average: 625991.0,
          ips: nil,
          std_dev: 0.0,
          std_dev_ratio: 0.0,
          std_dev_ips: nil,
          median: 625991.0,
          percentiles: %{50 => 625991.0, 99 => 625991.0},
          mode: 625991,
          minimum: 625991,
          maximum: 625991,
          relative_more: 1.5375643327393675,
          relative_less: 0.6503792906137281,
          absolute_difference: 218859.41748942173,
          sample_size: 583
        },
        samples: [625991, 625991, 625991, 625991, 625991, 625991, 625991, 625991, 625991, 625991,
         625991, 625991, 625991, 625991, 625991, 625991, 625991, 625991, 625991, 625991, 625991,
         625991, 625991, 625991, 625991, 625991, 625991, 625991, 625991, 625991, ...]
      }
    },
    %Benchee.Scenario{
      name: "PartTwo",
      job_name: "PartTwo",
      function: &PartTwo.solve/1,
      input_name: "test_input",
      input: "467..114..\n...*......\n..35..633.\n......#...\n617*......\n.....+.58.\n..592.....\n......755.\n...$.*....\n.664.598..\n",
      before_each: nil,
      after_each: nil,
      before_scenario: nil,
      after_scenario: nil,
      tag: nil,
      run_time_data: %Benchee.CollectionData{
        statistics: %Benchee.Statistics{
          average: 34694.75356859635,
          ips: 28822.801638376273,
          std_dev: 4654.521971042223,
          std_dev_ratio: 0.13415636349281415,
          std_dev_ips: 3866.7622534792868,
          median: 33470.0,
          percentiles: %{50 => 33470.0, 99 => 48736.09999999995},
          mode: [33371, 33341],
          minimum: 32371,
          maximum: 774416,
          relative_more: nil,
          relative_less: nil,
          absolute_difference: nil,
          sample_size: 85748
        },
        samples: [62662, 45161, 39420, 38671, 37821, 54451, 75592, 47331, 39210, 37981, 39391,
         37231, 36251, 38850, 37351, 36991, 37651, 37560, 36761, 39421, 39611, 57131, 51391, 42531,
         39411, 37541, 36420, 38201, 36881, 39981, 38710, ...]
      },
      memory_usage_data: %Benchee.CollectionData{
        statistics: %Benchee.Statistics{
          average: 27240.0,
          ips: nil,
          std_dev: 0.0,
          std_dev_ratio: 0.0,
          std_dev_ips: nil,
          median: 27240.0,
          percentiles: %{50 => 27240.0, 99 => 27240.0},
          mode: 27240,
          minimum: 27240,
          maximum: 27240,
          relative_more: nil,
          relative_less: nil,
          absolute_difference: nil,
          sample_size: 30863
        },
        samples: [27240, 27240, 27240, 27240, 27240, 27240, 27240, 27240, 27240, 27240, 27240,
         27240, 27240, 27240, 27240, 27240, 27240, 27240, 27240, 27240, 27240, 27240, 27240, 27240,
         27240, 27240, 27240, 27240, 27240, 27240, ...]
      },
      reductions_data: %Benchee.CollectionData{
        statistics: %Benchee.Statistics{
          average: 2227.0,
          ips: nil,
          std_dev: 0.0,
          std_dev_ratio: 0.0,
          std_dev_ips: nil,
          median: 2227.0,
          percentiles: %{50 => 2227.0, 99 => 2227.0},
          mode: 2227,
          minimum: 2227,
          maximum: 2227,
          relative_more: nil,
          relative_less: nil,
          absolute_difference: nil,
          sample_size: 28169
        },
        samples: [2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227,
         2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227, 2227,
         2227, ...]
      }
    },
    %Benchee.Scenario{
      name: "PartOne",
      job_name: "PartOne",
      function: &PartOne.solve/1,
      input_name: "test_input",
      input: "467..114..\n...*......\n..35..633.\n......#...\n617*......\n.....+.58.\n..592.....\n......755.\n...$.*....\n.664.598..\n",
      before_each: nil,
      after_each: nil,
      before_scenario: nil,
      after_scenario: nil,
      tag: nil,
      run_time_data: %Benchee.CollectionData{
        statistics: %Benchee.Statistics{
          average: 42718.325742049215,
          ips: 23409.15713875142,
          std_dev: 3439.2985512709697,
          std_dev_ratio: 0.08051108023378224,
          std_dev_ips: 1884.6965286032319,
          median: 41511.0,
          percentiles: %{50 => 41511.0, 99 => 51461.259999999995},
          mode: 41331,
          minimum: 40730,
          maximum: 415198,
          relative_more: 1.2312618291866275,
          relative_less: 0.8121749381775286,
          absolute_difference: 8023.572173452863,
          sample_size: 69773
        },
        samples: [71471, 50941, 47721, 46651, 48391, 51281, 50031, 46290, 46201, 45711, 47231,
         49271, 49621, 47951, 48121, 48441, 47051, 47391, 47871, 51522, 51931, 47681, 93102, 91051,
         89871, 90712, 84792, 99662, 50581, 49011, ...]
      },
      memory_usage_data: %Benchee.CollectionData{
        statistics: %Benchee.Statistics{
          average: 41360.0,
          ips: nil,
          std_dev: 0.0,
          std_dev_ratio: 0.0,
          std_dev_ips: nil,
          median: 41360.0,
          percentiles: %{50 => 41360.0, 99 => 41360.0},
          mode: 41360,
          minimum: 41360,
          maximum: 41360,
          relative_more: 1.5183553597650514,
          relative_less: 0.6586073500967118,
          absolute_difference: 14120.0,
          sample_size: 24474
        },
        samples: [41360, 41360, 41360, 41360, 41360, 41360, 41360, 41360, 41360, 41360, 41360,
         41360, 41360, 41360, 41360, 41360, 41360, 41360, 41360, 41360, 41360, 41360, 41360, 41360,
         41360, 41360, 41360, 41360, 41360, ...]
      },
      reductions_data: %Benchee.CollectionData{
        statistics: %Benchee.Statistics{
          average: 4224.0,
          ips: nil,
          std_dev: 0.0,
          std_dev_ratio: 0.0,
          std_dev_ips: nil,
          median: 4224.0,
          percentiles: %{50 => 4224.0, 99 => 4224.0},
          mode: 4224,
          minimum: 4224,
          maximum: 4224,
          relative_more: 1.896722047597665,
          relative_less: 0.5272253787878788,
          absolute_difference: 1997.0,
          sample_size: 27133
        },
        samples: [4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224,
         4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224, 4224,
         ...]
      }
    }
  ]
}

Failures

Sometimes my ideas don’t work out.