Skip to content
This repository was archived by the owner on Nov 17, 2024. It is now read-only.

Commit e9d2ca3

Browse files
committed
benchmarks
1 parent fee89a2 commit e9d2ca3

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ haddocks][haddock] --- more info below!
4646
| Day 6 | | [x][d06g] | [x][d06h] | [x][d06b] |
4747
| Day 7 | | [x][d07g] | [x][d07h] | [x][d07b] |
4848
| Day 8 | | [x][d08g] | [x][d08h] | [x][d08b] |
49-
| Day 9 | | | | |
49+
| Day 9 | | [x][d09g] | [x][d09h] | [x][d09b] |
5050
| Day 10 | | | | |
5151
| Day 11 | | | | |
5252
| Day 12 | | | | |
@@ -321,3 +321,6 @@ All networking features are powered by *[advent-of-code-api][]*.
321321
[d08g]: https://github.com/mstksg/advent-of-code-2021/blob/master/src/AOC/Challenge/Day08.hs
322322
[d08h]: https://mstksg.github.io/advent-of-code-2021/src/AOC.Challenge.Day08.html
323323
[d08b]: https://github.com/mstksg/advent-of-code-2021/blob/master/reflections.md#day-8-benchmarks
324+
[d09g]: https://github.com/mstksg/advent-of-code-2021/blob/master/src/AOC/Challenge/Day09.hs
325+
[d09h]: https://mstksg.github.io/advent-of-code-2021/src/AOC.Challenge.Day09.html
326+
[d09b]: https://github.com/mstksg/advent-of-code-2021/blob/master/reflections.md#day-9-benchmarks

reflections.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Table of Contents
2929
* [Day 6](#day-6) *(no reflection yet)*
3030
* [Day 7](#day-7) *(no reflection yet)*
3131
* [Day 8](#day-8) *(no reflection yet)*
32+
* [Day 9](#day-9) *(no reflection yet)*
3233

3334
Day 1
3435
------
@@ -559,3 +560,45 @@ std dev 5.367 μs (4.515 μs .. 6.275 μs)
559560
* parsing and formatting times excluded
560561
```
561562

563+
564+
565+
Day 9
566+
------
567+
568+
<!--
569+
This section is generated and compiled by the build script at ./Build.hs from
570+
the file `./reflections/day09.md`. If you want to edit this, edit
571+
that file instead!
572+
-->
573+
574+
*[Prompt][d09p]* / *[Code][d09g]* / *[Rendered][d09h]* / *[Standalone Reflection Page][d09r]*
575+
576+
[d09p]: https://adventofcode.com/2021/day/9
577+
[d09g]: https://github.com/mstksg/advent-of-code-2021/blob/master/src/AOC/Challenge/Day09.hs
578+
[d09h]: https://mstksg.github.io/advent-of-code-2021/src/AOC.Challenge.Day09.html
579+
[d09r]: https://github.com/mstksg/advent-of-code-2021/blob/master/reflections-out/day09.md
580+
581+
*Reflection not yet written -- please check back later!*
582+
583+
### Day 9 Benchmarks
584+
585+
```
586+
>> Day 09a
587+
benchmarking...
588+
time 1.593 ms (1.573 ms .. 1.614 ms)
589+
0.999 R² (0.999 R² .. 1.000 R²)
590+
mean 1.570 ms (1.561 ms .. 1.578 ms)
591+
std dev 27.83 μs (21.69 μs .. 34.24 μs)
592+
593+
* parsing and formatting times excluded
594+
595+
>> Day 09b
596+
benchmarking...
597+
time 7.241 ms (7.209 ms .. 7.271 ms)
598+
1.000 R² (0.999 R² .. 1.000 R²)
599+
mean 7.314 ms (7.292 ms .. 7.354 ms)
600+
std dev 82.86 μs (58.27 μs .. 124.0 μs)
601+
602+
* parsing and formatting times excluded
603+
```
604+

src/AOC/Challenge/Day09.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ day09a :: Map Point Int :~> Int
4040
day09a = MkSol
4141
{ sParse = Just . parseAsciiMap (mfilter (< 9) . digitToIntSafe)
4242
, sShow = show
43-
, sSolve = Just . sum . map ((+ 1) . snd) . findLows . M.filter (< 9)
43+
, sSolve = Just . sum . map ((+ 1) . snd) . findLows
4444
}
4545

4646
day09b :: Map Point Int :~> Int
@@ -50,7 +50,7 @@ day09b = MkSol
5050
, sSolve = \xs -> Just
5151
let -- map of points to their associated low points after flowing
5252
-- all the way downhill
53-
res = flip M.mapWithKey (flowMap xs) \p -> \case
53+
res = flip M.mapWithKey (flowMap xs) \p -> \case
5454
Nothing -> p
5555
Just q -> res M.! q
5656
in product . take 3 . sortBy (flip compare) . toList $ freqs res

0 commit comments

Comments
 (0)