diff options
| author | Andreas Grois <andi@grois.info> | 2024-09-23 10:46:14 +0200 |
|---|---|---|
| committer | Andreas Grois <andi@grois.info> | 2024-09-23 10:46:14 +0200 |
| commit | fda8a5b06d63aaa6b7db2ca7b2a7c0bd321bd16e (patch) | |
| tree | 4bea8d04be3f9a7c53039d8a69e2b566ea75d156 | |
| parent | 41231274d7e5466c89e24414bf567accf5bb2760 (diff) | |
Begin Day12
| -rw-r--r-- | Day12.lean | 36 | ||||
| -rw-r--r-- | lakefile.lean | 1 |
2 files changed, 37 insertions, 0 deletions
diff --git a/Day12.lean b/Day12.lean new file mode 100644 index 0000000..a929c2f --- /dev/null +++ b/Day12.lean @@ -0,0 +1,36 @@ +import «Common» + +namespace Day12 + +------------------------------------------------------------------------------------ + +inductive SpringMask +| operational +| damaged +| unknown + +structure SpringArrangement where + Mask : List SpringMask + DamagedGroups : List Nat + +inductive ParsingError +| unknownSymbolInLeftBlock : Char → ParsingError +| unknownSymbolInRightBlock : Char → ParsingError +| missingBlockSeparator : ParsingError +| noInput : ParsingError +| missingLeftBlock : ParsingError +| missingRightBlock : ParsingError + +instance : ToString ParsingError where + toString := λ + | .unknownSymbolInLeftBlock c => s!"Unkown character in left part of input: '{c}'. Expected '#', '.' or '?'." + | .unknownSymbolInRightBlock c => s!"Unknown character in right part of input. '{c}'. Expected either a numeric digit, or ','." + | .missingBlockSeparator => "An input line is missing a block separator (whitespace)." + | .noInput => "The input file is empty." + | .missingLeftBlock => "The left block, which should contain a map of operational ('.') or damaged ('#') springs, or the question mark ('?') is empty." + | .missingRightBlock => "The right block, which should contain a comma-separted list of numbers, is empty." + + + +def parse (input : String) : Except ParsingError SpringArrangement := + sorry diff --git a/lakefile.lean b/lakefile.lean index 5698911..d902aa3 100644 --- a/lakefile.lean +++ b/lakefile.lean @@ -14,6 +14,7 @@ lean_lib «Day8» where lean_lib «Day9» where lean_lib «Day10» where lean_lib «Day11» where +lean_lib «Day12» where lean_lib «Common» where |
