From: Neil Smith Date: Sat, 4 Jan 2020 12:58:48 +0000 (+0000) Subject: Removed needless scanning of each column X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=0ec58176ef0b59be76d4c2798d4d3fabdb121a24;p=advent-of-code-19.git Removed needless scanning of each column --- diff --git a/advent19/src/advent19.hs b/advent19/src/advent19.hs index 7543513..0cf73ee 100644 --- a/advent19/src/advent19.hs +++ b/advent19/src/advent19.hs @@ -76,8 +76,8 @@ traceUpper machine prev x = u' traceLower :: Machine -> (Integer, Integer) -> Integer -> (Integer, Integer) traceLower machine (_, prev) x = (x, l') where (bic, foundU) = beamInColumn machine x - startU = max prev foundU - l = head $ dropWhile (\y -> tractorBeamAt machine x y) [startU..] + startL = if prev == 0 then foundU else prev + l = head $ dropWhile (\y -> tractorBeamAt machine x y) [startL..] l' = if prev == 0 && bic == False then 0 else l - 1