From ba3676762a64d418a4d731f799e7f2655cf09bcc Mon Sep 17 00:00:00 2001 From: Seth Etter Date: Sun, 3 Dec 2023 09:38:45 -0600 Subject: [PATCH] 2023, day03: first attempt, too low --- 2023/day03/deno.json | 9 +++ 2023/day03/deno.lock | 37 ++++++++++++ 2023/day03/input | 140 +++++++++++++++++++++++++++++++++++++++++++ 2023/day03/part1.ts | 75 +++++++++++++++++++++++ 2023/day03/part2.ts | 13 ++++ 2023/day03/puzzle.md | 40 +++++++++++++ 2023/day03/test.ts | 24 ++++++++ 7 files changed, 338 insertions(+) create mode 100644 2023/day03/deno.json create mode 100644 2023/day03/deno.lock create mode 100644 2023/day03/input create mode 100644 2023/day03/part1.ts create mode 100644 2023/day03/part2.ts create mode 100644 2023/day03/puzzle.md create mode 100644 2023/day03/test.ts diff --git a/2023/day03/deno.json b/2023/day03/deno.json new file mode 100644 index 0000000..0928a95 --- /dev/null +++ b/2023/day03/deno.json @@ -0,0 +1,9 @@ +{ + "tasks": { + "cache": "deno cache part1.ts part2.ts", + "pull": "aoc --day 3 download --overwrite", + "test": "deno test --watch", + "p1": "deno run -A part1.ts", + "p2": "deno run -A part2.ts" + } +} diff --git a/2023/day03/deno.lock b/2023/day03/deno.lock new file mode 100644 index 0000000..2c1d001 --- /dev/null +++ b/2023/day03/deno.lock @@ -0,0 +1,37 @@ +{ + "version": "3", + "remote": { + "https://deno.land/std@0.208.0/assert/_constants.ts": "8a9da298c26750b28b326b297316cdde860bc237533b07e1337c021379e6b2a9", + "https://deno.land/std@0.208.0/assert/_diff.ts": "58e1461cc61d8eb1eacbf2a010932bf6a05b79344b02ca38095f9b805795dc48", + "https://deno.land/std@0.208.0/assert/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7", + "https://deno.land/std@0.208.0/assert/assert.ts": "9a97dad6d98c238938e7540736b826440ad8c1c1e54430ca4c4e623e585607ee", + "https://deno.land/std@0.208.0/assert/assert_almost_equals.ts": "e15ca1f34d0d5e0afae63b3f5d975cbd18335a132e42b0c747d282f62ad2cd6c", + "https://deno.land/std@0.208.0/assert/assert_array_includes.ts": "6856d7f2c3544bc6e62fb4646dfefa3d1df5ff14744d1bca19f0cbaf3b0d66c9", + "https://deno.land/std@0.208.0/assert/assert_equals.ts": "d8ec8a22447fbaf2fc9d7c3ed2e66790fdb74beae3e482855d75782218d68227", + "https://deno.land/std@0.208.0/assert/assert_exists.ts": "407cb6b9fb23a835cd8d5ad804e2e2edbbbf3870e322d53f79e1c7a512e2efd7", + "https://deno.land/std@0.208.0/assert/assert_false.ts": "0ccbcaae910f52c857192ff16ea08bda40fdc79de80846c206bfc061e8c851c6", + "https://deno.land/std@0.208.0/assert/assert_greater.ts": "ae2158a2d19313bf675bf7251d31c6dc52973edb12ac64ac8fc7064152af3e63", + "https://deno.land/std@0.208.0/assert/assert_greater_or_equal.ts": "1439da5ebbe20855446cac50097ac78b9742abe8e9a43e7de1ce1426d556e89c", + "https://deno.land/std@0.208.0/assert/assert_instance_of.ts": "3aedb3d8186e120812d2b3a5dea66a6e42bf8c57a8bd927645770bd21eea554c", + "https://deno.land/std@0.208.0/assert/assert_is_error.ts": "c21113094a51a296ffaf036767d616a78a2ae5f9f7bbd464cd0197476498b94b", + "https://deno.land/std@0.208.0/assert/assert_less.ts": "aec695db57db42ec3e2b62e97e1e93db0063f5a6ec133326cc290ff4b71b47e4", + "https://deno.land/std@0.208.0/assert/assert_less_or_equal.ts": "5fa8b6a3ffa20fd0a05032fe7257bf985d207b85685fdbcd23651b70f928c848", + "https://deno.land/std@0.208.0/assert/assert_match.ts": "c4083f80600bc190309903c95e397a7c9257ff8b5ae5c7ef91e834704e672e9b", + "https://deno.land/std@0.208.0/assert/assert_not_equals.ts": "9f1acab95bd1f5fc9a1b17b8027d894509a745d91bac1718fdab51dc76831754", + "https://deno.land/std@0.208.0/assert/assert_not_instance_of.ts": "0c14d3dfd9ab7a5276ed8ed0b18c703d79a3d106102077ec437bfe7ed912bd22", + "https://deno.land/std@0.208.0/assert/assert_not_match.ts": "3796a5b0c57a1ce6c1c57883dd4286be13a26f715ea662318ab43a8491a13ab0", + "https://deno.land/std@0.208.0/assert/assert_not_strict_equals.ts": "4cdef83df17488df555c8aac1f7f5ec2b84ad161b6d0645ccdbcc17654e80c99", + "https://deno.land/std@0.208.0/assert/assert_object_match.ts": "d8fc2867cfd92eeacf9cea621e10336b666de1874a6767b5ec48988838370b54", + "https://deno.land/std@0.208.0/assert/assert_rejects.ts": "45c59724de2701e3b1f67c391d6c71c392363635aad3f68a1b3408f9efca0057", + "https://deno.land/std@0.208.0/assert/assert_strict_equals.ts": "b1f538a7ea5f8348aeca261d4f9ca603127c665e0f2bbfeb91fa272787c87265", + "https://deno.land/std@0.208.0/assert/assert_string_includes.ts": "b821d39ebf5cb0200a348863c86d8c4c4b398e02012ce74ad15666fc4b631b0c", + "https://deno.land/std@0.208.0/assert/assert_throws.ts": "63784e951475cb7bdfd59878cd25a0931e18f6dc32a6077c454b2cd94f4f4bcd", + "https://deno.land/std@0.208.0/assert/assertion_error.ts": "4d0bde9b374dfbcbe8ac23f54f567b77024fb67dbb1906a852d67fe050d42f56", + "https://deno.land/std@0.208.0/assert/equal.ts": "9f1a46d5993966d2596c44e5858eec821859b45f783a5ee2f7a695dfc12d8ece", + "https://deno.land/std@0.208.0/assert/fail.ts": "c36353d7ae6e1f7933d45f8ea51e358c8c4b67d7e7502028598fe1fea062e278", + "https://deno.land/std@0.208.0/assert/mod.ts": "37c49a26aae2b254bbe25723434dc28cd7532e444cf0b481a97c045d110ec085", + "https://deno.land/std@0.208.0/assert/unimplemented.ts": "d56fbeecb1f108331a380f72e3e010a1f161baa6956fd0f7cf3e095ae1a4c75a", + "https://deno.land/std@0.208.0/assert/unreachable.ts": "4600dc0baf7d9c15a7f7d234f00c23bca8f3eba8b140286aaca7aa998cf9a536", + "https://deno.land/std@0.208.0/fmt/colors.ts": "34b3f77432925eb72cf0bfb351616949746768620b8e5ead66da532f93d10ba2" + } +} diff --git a/2023/day03/input b/2023/day03/input new file mode 100644 index 0000000..3030b76 --- /dev/null +++ b/2023/day03/input @@ -0,0 +1,140 @@ +........897.......839...........651.399.............236...............................343...986...........308............................... +........*................*404......*............134.....953..508=.....................*....*..........325*..........744......392............ +...350..847..403...-..541.....622.................*....................356.......%..95...793....................830...........*.....163..... +.....&.......@...105.............$..745............42...785.............*..443.412............922..............*...........663........*..... +.253....../..........696.............*..................*..............817.$.....................*...........62........................373.. +...........244...419....*189....=........*...871.74...797...353.737................227..626.....429.726%...9......*956...803/.......*....... +.793...........=.....-...........119..683.18.*...............@......+.....182..372....$.&...................*..756...............945.610.... +....*.........496.....395.....................929.746................76..*.....*..............673-...*.....47........591..271............... +.....964..................241...........*............+.....+....590.......129.6....$.....@...........680....................*............... +..........523*448...........&....136.759.356............789.......*.................367.330..397.............483....354......354...869...... +...488................920........*...........................652...802....$.......*............*..............-.....................*....... +..../.........986....*......*....550.995......376...............+......641.....567.315.........887..66...863....552.936..........277........ +.................*.800...354.464.......*.533......................20.......704..........918........*.....*...........*....214........&434... +........%.....589...................596..*.......373...-..........*....785.@......941......*....521.......908...897..610.................... +........384..........827*101....698......978....*......947.614.571....*..........@.....+...1.......................=......#73...734......... +122%..........*...................*..........993............./.....260.........+.....466...............%........................*........... +...........938.992........246......305...449......335...739................588..681.........920.....164.........................431......... +..558....$........................................@.....*.....................=............-............847.....879..51................624.. +.....*.104....*818.......505.785.10...................161....210....................723..........55......*..424..&.....*.........723..*..... +...44......542.....975..................437...............51....*686.....*....../..*.........990*......708.....@....715...&....#.......997.. +...............801..@.............-....*.....702....&....*............238.236.706.183..+................................842.545............. +...........202*...................906..204...*...990......212....380%..................208...................66............................. +......./........../....878............................266.......................278...............920...................144.........423..... +....494..*.....976........@.....&.......*287...553-..*.............731...................649..247*........703......@....%....817....*....... +.........856.......592...........708.404............707.......274...*........-............#.....................%.567.........*......431.761 +.............663.........974...............%...446.............*............751....793..........811....225.&...48.....860..887.............. +................&...........*.......673..536......-.........447.....@...............@...$..................816..........*................... +....822................@....251....$............................413..306.164.............540.....313..476..........@...586./65....840....... +.....*......@.950.....266............$.........1...+...............*..........373..................*.............885.................*...... +......157.529....*.........341.....480.............60......765....122...633....+............$182....963.....................587..976.824.... +................172............685.....480....#........831*................*......747......................262..................-........... +....*......+438.....@......332./.......=...739..815...............356.....119.273.&.....317*674.......=...*....561..........192..........89. +....867..-........179..............319........../....74@..952*374...*.........*....................125....578...*...........*......652...... +..........549.............873.........*...=........*...............695.*.....126.........821.....................697.$......806.52....*54... +....792...........-...646*....770.....163.637....941........884.........744..............................#............800................... +.......*.......181............@.............../........92..#...................518...654.......421*995.310....450...............771......... +...+................./48...........968.........269................904.......=...../.....................................266.....*........... +.211....636.................630.17*.....%581........./843.....%..*.......878...............829.....119.33........211.........247............ +.......*......................-...................%..........559..873.............*138.439*....687*..........130....*681.................... +....522.................792........896.........471...480*321...................125..............................*...................291..... +........616.......818.....$..858.............................659*826.....109.....................................10.564=.331...156...+...... +........*.......@...*..29....*...@......546.............907.............*.....965.......217.808.....802..212...............*................ +....607.976..641..852.@...330...158....../.......630........247.......503........$.335+....*.........*..*....618...423&.335...803........... +......=..............................502........#........-..*.....923......664....................421...395.-..................#............ +........*.................625....646..@...99............901.59......*.....*..........517.$747.*....................315..............79...922 +.....289.789..............%......*.........*......................762....388..189.....*........277.........*222...*.................$....... +.................................738....406.....462...........................*.....915..............505/.......61.....+.......202*......646 +..749..............163............................*.....963..........907.......979....................................223..716.....265...... +.......&....741............362.......117.......837..96../.................#..............786.256.....942..=970...983........*............... +......133......*486.725.......*....../...............%................930.310...................*733.-.............$.....198.........189.... +....................*........256........68.......267...873........418*.....................573.................................219..*....... +......+.....439..525..187........495..............*...=.......923..........327..988..300........447*59..702../..840......40.....*........... +......731....*........*..........*..............547.......453.....6.$.........*.......*................-....447....@.......*.737............ +.907#.......375........195.....707..17.................9..........%..119...147..594.22.......81.........................485......446........ +.....................................*....#............*.....62...................*...........*....569...935.868....-...............*528.... +...#..........209........229.......787.470..............403........892.........816.....923..811...$.........*......104.907.849....*......... +..154.346.....*...361.........................10/...237................-................*.............600..............*.......998.606...... +.........%...216..*.......*.........*368.869.........#................6..98...........53.............*.....850@...102...751................. +....550............727...383.....818.....*...913.............879...........*.....420.....150.........708.................................... +705*.......@688.......................289.....*.........................431........*...+....*50.....................698...668*144........... +..................501..70.520....$32......562..458....170......279$............504......883............/...44........*...................... +..450..107@........*..................586*...........*.........................*....510............788.274............589...-26......&...... +...................342.........&.551+.................302...............286.....931....&....-649..$.............575................185...199 +............602..............470.........243*......@............818.690*.......................................*....863..793*............... +......934.....*......200.936.....46..........137.72.........377*......................443*372........498....320..#...........553......598... +........-...451./952..*...*....*.......................804..............305......700............675...&.........611......................... +......................393.......708....957........*697......808.....138*.........%......186....*....%...162*...........624........244.%..... +.....220*.........872......*...........*.........7.........................................=..6....391......562...880.....*......#....120... +...+.....608.........*...74.568........193.........379.........$682......933.927&.....&............................./..984.................. +93..553........*768.739...........421.........880.....*....737.............*.........69..................................................... +.........334...............................40*........910.................................+465..682.............141*.......248..80.......... +.........=..................323...172.............506..............503........568....785+.......%.......940*734.......#573....*...*.....130. +...163@........%17..42..108*.......*...$......700..*..81...../...............+....%.............................#285.........499.523....*... +.............-........*..........305.706.....*....942.....843........*.............378.861.......573.859.173............522............544.. +..........974.......517.756..762.............480.....................289................*...........*......*.228%..........*......628....... +....567........&274......+..../..........................................926.............391............214.............270...230..-........ +...........=...............52...../......155*150.......180&..*......482..&...884................-125...........................@............ +..........332..................318............................123......%......*...............=........................310.................. +....................856.154........@............161....192..................=..387.............384..*827................*..&400......588.... +.......283.............*....@.......12.....309...*...$...........643.......885..........862................210.......449.................... +.......*......937.........98.....&........*....560....884.......$.................866#.../.............622..*..901.............462.......... +.....279............273......896..17.661..880...............138...632......66...%.............93......*....349...*........./......=......... +..............430....*....+.....*.....*............350...............*..........226.......621*......312........=..266....574..111........... +..339........../.....770.451....122........990.....................811...780........*448.................325.249...............+...$...441.. +......................................$......%...........793..............@..787.766....................................64..+......252.*.... +.........556........../.....256/...267...336.....897..........524*417.........................950...930$.452........164......713.......592.. +....759....*...........672.................-.868....*....613......................401.....742..*..............560........=.........939...... +.....$...780.......195......578...............*...%...+....*.....=.....&.............*......#...645...636.797..........652...........*...... +......................*......................77...97.988.821...882...977.......127.609.914...............*.................................. +..........+...195&.....930.....872.......................................79..............&.....14...................-.......150..274........ +..........473................9*.............951&................./...827*.............46......-...13....751.........640.......*.....*504.... +898................-.............56*....378..............291..310..........58............937.....$.......*.../.............840..714......... +............-321.128.157............549..-....130....478*.........*.....................................123...164..............*....631..... +..516..989@..........*.........*670............................204..577.......&817....@514........790...............816.........148.*....... +.....*................233...........*838.....*951.....-954..........$.......&.................110.........99...........*..@187.......671.467 +224...205.....552................823......343................490*...........377..................*.......$...........779.......408.......... +............./..../.....................................166*..........120...........452.........148...=.......................*............. +.562..............768.........#.267.29...806*......476......214.........*....*......*...............867.211....248.$870....@...829...*...... +...*..826@...................1.....*.........251....+.....#...........211.893.403....702.......44.......*........+..........75......977..... +..368.........861$......867....=.......................834.....................................=.........507................................ +.......721*............*.......912.#497....................87-.....231...894.......968..........................659$.......@..........564... +...........690.......432....@..................332................*.........*756..*................302..214*.........803..855............... +..................26.......943...........633...*.....299.150....639.................796.....440.............428......+...........538.647.... +........31........*............................260.....-................=..261.............*............................644.303..%.....-.... +227..........#.161....*....&.....305...............345........328....639...*........$.......802....612.185................%../.............. +.......683.953.....224....58.....*.................*....799...............944.964....245.............*.%................@......28.19.242.97. +....93*........../.............908.........$249..480.......*......978..............................58........=209......373.802*.........*... +467...........201..........932.....997......................548................/.....-904.....796.....3+............................915..... +...................#......@.......*......748*965.................922......451..169..............$.945....372#..979........%..436...*........ +........&.....880&..789........14.805..............571....222/.....*.70......*........./958..........%.........&.../....61.....*...73....... +.......280.................................=.861......-.........144...........950................%.......907......910.......396............. +.....+.........592*149.820*511...........298....&.......*264..........-..527..............-.....679.......*...............@......50*270..... +...901......=....................@483.............$..936......625%...619....%..........748...............785...860......26..181.........747. +.........85..640...#........=.=.......49.......216.............................268*.............................#...........#.....53....*... +...........+.......744...933...766....*.................%...............*714.......909................................999...........*...311. +.............783....................947.................352...765..............897.....+430..869.................121.%............236....... +...45....*......*..752......617..................332...........*...236...........*..........*....@.528..........&......530.................. +..../.134.713.871..*.............*...........#.....%.930...........*....323....377........678.544..*........542.........$.......470.629*786. +..................259...&.....959.225......177.......*.....912*..........$.........................306..996.*....*.........*681...*......... +..........250*768......598.........................850.........598..............3*.........904*648........=.372...197...410......152...=.... +............................................507@.......960..............362.164...131...................................................115. +.....746.......117..678=........952...303*.......+......................./..*...........$636../...597......37................351...=........ +.......*.281...@...................*......337.258..814...687.....#922.=....772..611.153.......573....*.......*..............*.......518..... +....144.....*.......396...........240................+......*.........45.......+.......*...........479.&293..126.....784-...783............. +...........843...@....*..918*.............................986.....542...................117.....................................578.707..... +..984.............251........258....597$.650.........................*..................................928.409.684...547.......*....%...... +....&..489....931...........................$....356........................489..............302...............*............./...259.../996. +......./........*.................................*......385........63*911...*.........%........*578...633.175.........@804..421............ +..98...........188..........226....+...............909....*...................535.....798................$....*.796......................... +....*.....%...................+....531...563...........426......617*202.........................929-.......439....%..332.....+.23&.347...... +...364..149..............425............*.....662.481.......................788..$844..................506..........@.....693......&........ +..........................*....408...772....+.......-.......232*......*......*.............#.+294.....*.....706................435.......... +......566*972........631=.425.*...........14............984.....667..7.236....195..9.....222........757......*.....865..604&..*....344.&.... +.................439..........710..............477*714..............................*544........368............395*...........435...*..204.. +..........229......+..596.179........../................165.542*47........147..............653..*...................466...........119....... +.....690...@............@.......467..626........&......*.................*....=42.....724....+.816....262*.....237.@....549.383............. +......*.........750..............*..............202....967.914......279..................*........./......147.@...............*........480.. +...444.......84...#....+..........527......*351..............*......*................225..888.......806.............7......#...518.....*.... +.............*........628...............749......*976.200.....852..354...23....=........*...............................138............833.. +..........964.................................211...............................578.....986.............879......59......................... diff --git a/2023/day03/part1.ts b/2023/day03/part1.ts new file mode 100644 index 0000000..68f9ac2 --- /dev/null +++ b/2023/day03/part1.ts @@ -0,0 +1,75 @@ +if (import.meta.main) { + const input = ( + await Deno.readFile("input").then((bytes) => + new TextDecoder().decode(bytes), + ) + ).trim(); + console.log(answer(input)); +} + +type Coord = [number, number]; + +type PartNum = { + num: number; + coords: Coord[]; +}; + +export function answer(input: string): number { + const grid = input.split("\n").map((l) => l.split("")); + const [partNums, symbols] = getPartNumsAndSymbols(grid); + + return partNums.reduce( + (sum, { coords, num }) => + isSymbolAdjacent(coords, symbols) ? sum + num : sum, + 0, + ); +} + +export function isSymbolAdjacent(coords: Coord[], symbols: Coord[]): boolean { + return coords.some(([x, y]) => + adjacentCoords([x, y]).some(([ax, ay]) => + symbols.some(([sx, sy]) => ax === sx && ay === sy), + ), + ); +} + +function adjacentCoords([x, y]: Coord): Coord[] { + return [ + [x - 1, y - 1], + [x + 1, y + 1], + [x - 1, y + 1], + [x + 1, y - 1], + [x, y + 1], + [x, y - 1], + [x + 1, y], + [x - 1, y], + ]; +} + +function getPartNumsAndSymbols(grid: string[][]): [PartNum[], Coord[]] { + const isSymbol = (c: string) => !c.match(/([0-9]|\.)/); + const isNum = (c: string) => !!c.match(/[0-9]/); + + const partNums: PartNum[] = []; + const symbolCoords: Coord[] = []; + + for (let y = 0; y < grid.length; y++) { + for (let x = 0; x < grid[y].length; x++) { + const c = grid[y][x]; + if (isSymbol(c)) symbolCoords.push([x, y]); + else if (isNum(c)) { + const coords: Coord[] = []; + let numStr = ""; + let current = c; + while (current && isNum(current)) { + coords.push([x, y]); + numStr += current; + current = grid[y][++x]; + } + partNums.push({ num: parseInt(numStr), coords }); + } + } + } + + return [partNums, symbolCoords]; +} diff --git a/2023/day03/part2.ts b/2023/day03/part2.ts new file mode 100644 index 0000000..5658bc9 --- /dev/null +++ b/2023/day03/part2.ts @@ -0,0 +1,13 @@ +if (import.meta.main) { + const input = ( + await Deno.readFile("input").then((bytes) => + new TextDecoder().decode(bytes), + ) + ).trim(); + console.log(answer(input)); +} + +export function answer(input: string): number { + console.log(input); + return 42; +} diff --git a/2023/day03/puzzle.md b/2023/day03/puzzle.md new file mode 100644 index 0000000..cf71786 --- /dev/null +++ b/2023/day03/puzzle.md @@ -0,0 +1,40 @@ +\--- Day 3: Gear Ratios --- +---------- + +You and the Elf eventually reach a [gondola lift](https://en.wikipedia.org/wiki/Gondola_lift) station; he says the gondola lift will take you up to the *water source*, but this is as far as he can bring you. You go inside. + +It doesn't take long to find the gondolas, but there seems to be a problem: they're not moving. + +"Aaah!" + +You turn around to see a slightly-greasy Elf with a wrench and a look of surprise. "Sorry, I wasn't expecting anyone! The gondola lift isn't working right now; it'll still be a while before I can fix it." You offer to help. + +The engineer explains that an engine part seems to be missing from the engine, but nobody can figure out which one. If you can *add up all the part numbers* in the engine schematic, it should be easy to work out which part is missing. + +The engine schematic (your puzzle input) consists of a visual representation of the engine. There are lots of numbers and symbols you don't really understand, but apparently *any number adjacent to a symbol*, even diagonally, is a "part number" and should be included in your sum. (Periods (`.`) do not count as a symbol.) + +Here is an example engine schematic: + +``` +467..114.. +...*...... +..35..633. +......#... +617*...... +.....+.58. +..592..... +......755. +...$.*.... +.664.598.. + +``` + +In this schematic, two numbers are *not* part numbers because they are not adjacent to a symbol: `114` (top right) and `58` (middle right). Every other number is adjacent to a symbol and so *is* a part number; their sum is `*4361*`. + +Of course, the actual engine schematic is much larger. *What is the sum of all of the part numbers in the engine schematic?* + +To begin, [get your puzzle input](3/input). + +Answer: + +You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22Gear+Ratios%22+%2D+Day+3+%2D+Advent+of+Code+2023&url=https%3A%2F%2Fadventofcode%2Ecom%2F2023%2Fday%2F3&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle. \ No newline at end of file diff --git a/2023/day03/test.ts b/2023/day03/test.ts new file mode 100644 index 0000000..8bf6431 --- /dev/null +++ b/2023/day03/test.ts @@ -0,0 +1,24 @@ +import { assertEquals } from "https://deno.land/std@0.208.0/assert/mod.ts"; +import * as p1 from "./part1.ts"; +import * as p2 from "./part2.ts"; + +Deno.test("part1", () => { + const examples = [ + "467..114..", + "...*......", + "..35..633.", + "......#...", + "617*......", + ".....+.58.", + "..592.....", + "......755.", + "...$.*....", + ".664.598..", + ].join("\n"); + assertEquals(p1.answer(examples), 4361); +}); + +Deno.test("part2", () => { + const examples = ["abc", "def"].join("\n"); + assertEquals(p2.answer(examples), 42); +}); -- 2.51.2