Share frame generation to avoid accidental quadratic complexity

Previously each test was computing all frames from scratch.
This commit is contained in:
George Thomas 2025-12-30 12:03:21 +00:00
parent 50e3119aef
commit 2cd2341673

View File

@ -26,11 +26,11 @@ puzzle =
t <- TL.readFile if isRealData then "../inputs/real/4" else "../inputs/examples/4"
input' <- input
t @=? drawGrid (mkGrid input' <&> \case InEmpty -> OutEmpty; InRoll -> OutRoll)
, testGroup
"frames"
let frames = Seq.fromList . takeUntil noneAccessible . fmap snd . generateFrames . mkGrid <$> input
nFrames = if isRealData then 58 else 9
in ( [0 .. nFrames] <&> \n ->
, withResource
(Seq.fromList . takeUntil noneAccessible . fmap snd . generateFrames . mkGrid <$> input)
mempty
\frames -> testGroup "frames" let nFrames = if isRealData then 58 else 9 in
( [0 .. nFrames] <&> \n ->
goldenVsStringDiff (show n) diffCommand (path <> "frames/" <> show n) $
TL.encodeUtf8 . maybe "frame list too short!" drawGrid . Seq.lookup n <$> frames
)