From a98eb2707e395f87b87e7370df1503158d0e1a1a Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Sun, 28 Jul 2024 10:20:18 +0100 Subject: [PATCH] Optimised day 23 --- README.html | 21 ++-- README.md | 8 +- advent-of-code23.cabal | 10 +- advent23/Main.hs | 179 ++++++++--------------------------- advent23/MainNoDepthLimit.hs | 160 +++++++++++++++++++++++++++++++ advent23/MainTree.hs | 141 +++++++++++++++++++++++++++ 6 files changed, 368 insertions(+), 151 deletions(-) create mode 100644 advent23/MainNoDepthLimit.hs create mode 100644 advent23/MainTree.hs diff --git a/README.html b/README.html index 13d51f8..4ad5959 100644 --- a/README.html +++ b/README.html @@ -11,14 +11,19 @@ div.columns{display: flex; gap: min(4vw, 1.5em);} div.column{flex: auto; overflow-x: auto;} div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} - ul.task-list{list-style: none;} + /* The extra [class] is a hack that increases specificity enough to + override a similar rule in reveal.js */ + ul.task-list[class]{list-style: none;} ul.task-list li input[type="checkbox"] { + font-size: inherit; width: 0.8em; margin: 0 0.8em 0.2em -1.6em; vertical-align: middle; } + .display.math{display: block; text-align: center; margin: 0.5rem auto;} + /* CSS for syntax highlighting */ pre > code.sourceCode { white-space: pre; position: relative; } - pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } + pre > code.sourceCode > span { line-height: 1.25; } pre > code.sourceCode > span:empty { height: 1.2em; } .sourceCode { overflow: visible; } code.sourceCode > span { color: inherit; text-decoration: inherit; } @@ -29,7 +34,7 @@ } @media print { pre > code.sourceCode { white-space: pre-wrap; } - pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } + pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; } } pre.numberSource code { counter-reset: source-line 0; } @@ -80,12 +85,8 @@ code span.va { color: #19177c; } /* Variable */ code span.vs { color: #4070a0; } /* VerbatimString */ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ - .display.math{display: block; text-align: center; margin: 0.5rem auto;} -
@@ -156,14 +157,14 @@ in the cabal file:

ghc-options: -O2 -Wall -threaded - -eventlog -rtsopts "-with-rtsopts=-N -p -s -hT" -

Only include the -eventlog directive if you want to use -Threadscope to investigate parallel behaviour.

then running

cabal run advent01prof --enable-profiling

Generate the profile graph with

hp2ps -M advent01.hp
+

To generate an eventlog (used for tracking multi-core performance), +pass in the -l RTS flag:

+
cabal run advent01 --enable-profiling -- +RTS -N -p -s -hT -l

Packages

Packages I used a lot: