diff options
| author | Andreas Grois <andi@grois.info> | 2023-12-07 20:26:51 +0100 |
|---|---|---|
| committer | Andreas Grois <andi@grois.info> | 2023-12-07 20:26:51 +0100 |
| commit | 8d6efb1c1fdddc1fbad167510ce25e56be684130 (patch) | |
| tree | f35cf0d4943ccb397f3d0a91ad8a1cb1116eccdd /Day3.lean | |
| parent | 9fb83b22220c825943549bc97bdab457bfad7f5b (diff) | |
Allow error messages in parsing (for debugging)
And fix an off-by-one in day 5
Diffstat (limited to 'Day3.lean')
| -rw-r--r-- | Day3.lean | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -78,10 +78,10 @@ private def extractPartNumbers (input : List (Coordinate × Char)) : List PartNu acc :: helper as none helper input none -def parse (schematic : String) : Option Schematic := do +def parse (schematic : String) : Except String Schematic := do -- I think this one is easier if we don't split the input in lines. Because: let charsWithCoordinates ← match schematic.toList with - | [] => none + | [] => throw "Could not pare input: Empty" | c :: cs => pure $ cs.scan (λ s c ↦ (uncurry Coordinate.nextByChar s, c)) (Coordinate.default, c) -- Whitespaces are **intentionally** left in. This makes extracting the numbers easier. pure $ { |
