-🎄- 2021 Day 12 Solutions -🎄-

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/adventofcode

Our great sponsors
  • SonarQube - Static code analysis for 29 languages.
  • Scout APM - Less time debugging, more time building
  • SaaSHub - Software Alternatives and Reviews
  • deno_aoc

    🎄 Advent of code solutions written in TypeScript for Deno.

    Yeah it's possible with a stack based approach: https://github.com/N8Brooks/deno_aoc/blob/main/year_2021/day_12.ts

  • adventofcode

    Advent of Code challenge solutions (by flwyd)

    Raku, much cleaner (part 1 and part 2 are tiny, and the base class DFS method is a lot cleaner) and also 20x faster with memoization. Took several tries to realize what key could be used for memoization; I ended up using the whole "budget" multisetwhich handles all the variants of small caves that can/can't be used after this one.

  • SonarQube

    Static code analysis for 29 languages.. Your projects are multi-language. So is SonarQube analysis. Find Bugs, Vulnerabilities, Security Hotspots, and Code Smells so you can release quality code every time. Get started analyzing your projects today for free.

  • adventofcode

    Solutions for problems from AdventOfCode.com (by bhosale-ajay)

    TypeScript used strategy pattern and a single function to find paths for part 1 and 2.

  • aoc

    Advent of Code - mscha's Perl 6 solutions (by mscha)

    Another Raku version, see GitHub, using DFS instead of recursion (inspired by many people on this thread).

  • Anyway, here was my solution where I mapped in order to resolve that problem, and then had to write a recursive “untangle the mess function” haha: https://github.com/ttilberg/advent-of-code-2021-rb/blob/main/2021/12/2.rb

  • aoc

    Advent of Code (by c-kk)

    Now it runs in 0.3 milliseconds! See: https://github.com/c-kk/aoc/blob/master/2021-go/day12-dfs/solve.go

  • aoc2021

    Advent Of Code 2021 solutions (by constb)

    Github: Part 1 Part 2

  • Scout APM

    Less time debugging, more time building. Scout APM allows you to find and fix performance issues with no hassle. Now with error monitoring and external services monitoring, Scout is a developer's best friend when it comes to application development.

  • advent-of-code-go

    (All 7 years of) adventofcode.com solutions in Go

  • AdventOfCode2021

  • AdventOfCode_2021

    Repository for Advent of Code 2021 solutions (by galenelias)

  • AdventOfCode

    Hacky solutions for [Advent of Code](https://adventofcode.com), working on past problems (by AllanTaylor314)

    Python3 (218/98)

  • advent-of-code

    My Advent of code files (by timrprobocom)

  • aoc

    Advent of Code (by quickthom)

    Python 3 (1575/2551)

  • adventOfCode2021

    Full Code for both parts

  • aoc-2020

    Awful code that implements the challenges from https://adventofcode.com/2020/ (by Heleor)

  • My solution in Common Lisp, 2335/2041.

  • AdventOfCodePython

    My attempts to solve the Advent of Code puzzles in Python. I've just started to study Python in a bit more detail, so I am playing around with it and try to learn some of its advanced functionality.

    Python: https://github.com/mkern75/AdventOfCodePython/blob/main/year2021/Day12.py

  • aoc

    🎄 advent of code 350⭐ (by MasterMedo)

    I think there's no faster algorithm, but I think you can improve the execution time by reducing the number of comparisons you do. Check out my solution.

  • AdventOfCode

  • advent-of-code-2021

  • adventOfCode


  • advent-of-code-2021

    AOC in go (by alextanhongpin)

  • aoc2021

    Advent of Code 2021 Solutions (by nlowe)

    Go, 3030/3121

  • adventofcode-solutions-js


  • advent-of-code

    My solutions to Advent of Code (by daniel-dara)

    Part 1 - 35

  • adventofcode2021

    Solutions to Advent of Code 2021 (by a-mroz)


  • comp


  • AdventOfCode

    Sharing Advent of Code Exercises (by shouchen)

  • AdventOfCode2021

    My solutions to advent of code 2021. Will keep updating as the event progresses. (by abhimanyu891998)


  • perlweeklychallenge-club

    Knowledge base for The Weekly Challenge club members using Perl, Raku, Ada, APL, Awk, Bash, BASIC, Bc, Befunge-93, Bourne Shell, BQN, Brainfuck, C3, C, CESIL, C++, C#, Clojure, COBOL, Coconut, Crystal, D, Dart, Elm, Erlang, Excel VBA, Fish, Forth, Fortran, Gembase, GNAT, Go, Haskell, Haxe, HTML, Idris, IO, J, Janet, Java, JavaScript, Julia, Kotlin, Lisp, Lua, M4, Miranda, MMIX, Mumps, Myrddin, Nim, Nix, Node.js, Nuweb, OCaml, Odin, Ook, Pascal, PHP, Python, Postscript, Prolog, R, Ring, Ruby, Rus

    Perl. As luck would have it there was a The Weekly Challenge not too long ago in which I used a similar approach of using partial paths as a hash key.

  • advent

    advent of code (by jasontconnell)

  • aoc2021

    Advent of code 2021 (by oleg-prikhodko)

    Recursive javascript solution using Set and custom counter: https://github.com/oleg-prikhodko/aoc2021/blob/master/12.js

  • advent-of-code

    Common Lisp. Got bit really hard twice today, on part a by not knowing that equalp compares strings case-insensitively (wtf!?) and on part b by speedreading and thinking that all small caves could be revisited on a single path

  • Advent2021

    Fairly straightforward recursive solution: https://github.com/IdrisTheDragon/Advent2021/blob/main/day_12/day_12.py

  • aoc2021

    Solutions to AOC2021 in Python. (by jdgunter)

    I have a similar solution, except I did the recursive DFS instead of an iterative one: https://github.com/jdgunter/aoc2021/blob/master/12/12.py

  • aoc2021

  • advent-of-code

    Advent of Code solutions in JS (by leyanlo)

    Iterative solution. Took me a few hours to clean this up into something presentable, but pretty happy with how it turned out. GitHub

  • adventofcode

    Advent of Code solutions of 2015, 2016, 2017, 2018, 2019, 2020 and 2021 in Scala (by sim642)

    My Scala solution.

  • aoc2021

    C++ https://github.com/ileonte/aoc2021/blob/main/day12/main.cpp

  • I left the types in this time so just the imports are missing.

  • adventOfCode2020

    Advent of code (by MissMormie)

  • AoC2021.jl

    Solution to Advent of Code 2021 in Julia (by abraemer)


  • AdventOfCode2021

    Advent of code 2021 (by marcodelmastro)

  • aoc2021

    Advent of code 2021 in Kotlin! (by crnkofe)

  • aoc2021

    Advent of Code 2021 (by sotolf2)

  • aoc2021

    Advent of Code 2021 - my answers

    Haskell 2873/1767

  • fgl

    A Functional Graph Library for Haskell

    Using fgl but only as a data structure this time, with edge labels denoting whether the target is a big room. Not using any of its algorithms as it doesn't have anything built-in for "traversal with re-visiting".

  • submarine

    AdventOfCode 2021

  • adventofgo

    advent of code in go


  • advent-of-code-2021

    advent of code 2021 solutions (by simorautiainen)

    Python solution. If you look at the input you might notice that there is not a single path from uppercase cave to uppercase cave, so with recursion there is no way code can get stuck. It also means that you don't need to keep track of the finished paths because there is no way to generate duplicates.

  • advent-of-code-solutions

    My JS solutions for https://adventofcode.com/ (by AugustsK)

  • advent-of-code

    Mine takes 2ms: https://github.com/SvetlinZarev/advent-of-code/tree/main/2021/aoc-day-12

  • adventofcode

    :christmas_tree: Advent of Code (2015-2021) in C#

  • advent-2021

    Went for optimization on this one. All strings are converted into ints (first becomes 0, second becomes 1, etc.), allowing me to use a vector instead of a hashmap for faster lookup times.

  • advent-of-code-2021

    Code I used for solving https://adventofcode.com/2021 (by pavel1269)

  • adventofcode

    ES6 solutions to Advent of Code puzzles. (by surgi1)

  • advent-of-code

    Advent of Code in python3 (by lehippie)

    Python3 : https://github.com/lehippie/advent-of-code/blob/master/2021/12.py

  • adventofcode

    Advent of code solutions (by mathsaey)

  • adventofcode-2021-solutions

    Solutions for Advent of Code 2021 edition

  • AoC2021

    Advent of Code 2021 (by gereons)

  • advent-of-code

    Solutions for Advent of Code, in TypeScript. (by Awjin)


  • AoC

    Advent of Code submissions (by tomribbens)

    My Python solution is available on my Github

  • adventofcode

    Advent of Code solutions (by alchemyst)

    Python on github

  • aoc2021

    Rust. I made it terribly ugly and unreadable while attempting to speed it up. That worked I think, part 2 runs in 0.015s on my laptop. The main trick was converting all caves from strings to power of 2 integers. That way, instead of storing a list of visited caves, you can use a single integer and do bitwise comparisons to check if you've visited a cave before.

  • advent-2021

    🎄 Advent of Code 2021: Solutions in Scala


  • advent_of_code

    Solutions to adventofcode.com (by ankitsumitg)

    Reusable method for both part 1 and 2: GIT Link

  • advent-of-code

    My solutions to Advent of Code (by deiwin)

    In case it's helpful, I found the solution to be quite comfortable to write in Haskell today. No special libraries used: https://github.com/deiwin/advent-of-code/blob/main/2021/Day12.hs

  • I didn't read part two right for literally two hours... but eventually I did! Solution in python!

  • AdventOfCode

    Advent of Code Solutions (by auxym)

  • Advent-of-Code

    Advent of Code (by michaeljgallagher)

    A nice twist on a classic problem! And part two was a nice little modification from part one. Neat problem today

  • aoc2021

    Advent of Code, 2021 (by gkwaerp)


  • AdventOfCode2021

  • adventofcode

    Some flavors of implementations for the Advent of Code challenges (by gansanay)

    Python 3, to be cleaned a bit

  • AdventOfCode

    Versions with `Write-Verbose` lines can be found on my AoC github here: part1 &part2

  • AOC

  • advent-of-code-2021

    It's back. It's worse. (by mrwilson)

    Went for a recursive BFS method (Source and tests), only a minor change from part 1 to part 2

  • advent-of-code

    Advent of code solutions (by rbusquet)

  • aoc2021

    Source (~16 LoC but v. slow :))

  • AOC2021

    Advent of code solutions 2021 (by calebwilson706)

  • aoc-2021-fsharp

    My F# solutions for Advent of Code 2021 https://adventofcode.com/2021

  • aoc2021

    Advent of Code 2021 on my homemade 16-bit CPU SCAMP (by jes)

  • coding_challenges

    Various Coding challenges with my solutions (by BigPeet)

  • aoc

    My solutions to adventofcode.com (by ciscou)

    My solution in 50 lines of ruby: https://github.com/ciscou/aoc/blob/master/2021/12.rb

  • aoc2021

    Advent of Code 2021, this time in Go (by danvk)

  • adventofcode

    Incomplete list of some of my AoC solutions (by Dav1dde)

    Rust: Day 12

  • advent_of_code_2021

    My solutions to the challenges from Advent of Code 2021 (by pierrechevalier83)

    [Rust solution](https://github.com/pierrechevalier83/advent_of_code_2021/blob/main/src/day12.rs)

  • Advent-of-Code-2021


  • adventofcode

    Advent of code (by Peter554)

    Full solution

  • advent-of-code-2021

    🎄 My Advent of Code solutions in Rust. http://adventofcode.com/2021

    Part 1 0.861ms (861μs)

  • advent-of-code

    My Advent of Code answers (by tcsullivan)

    Clojure (GitHub). My first solve of part 2 took ~15 mins, given 1GB of stack and 4GB of heap. Finally found the bottlenecks (concat) and got it down to 8-ish seconds:

  • AoC2021

    Advent of Code 2021 in F# (by kimvais)

    So pretty compared to my spaghetti

  • advent-of-code-2021

    My solutions to advent of code 2021 in deno/TS (by J-Swift)

  • Advent-of-Code-2021

    Advent of Code 2021 solutions in Matlab (by j-a-martins)


  • aoc

    Advent of Code Solutions (by joeyemerson)

  • Part 1 Part 2

  • advent-of-code

  • advent-2021

    C# Today. Solution here.

  • aoc2021

    Js/Ts Part1&2

  • AdventOfCode

    C# solutions for Advent of Code (by AlFasGD)

  • advent-of-code

    Advent of code solutions (by tallbikeguy)

  • adventofcode

    Answers to Advent of Code (by viceroypenguin)

  • aoc2021

    Advent of Code 2021, in Rust (by Killavus)

  • rockstar

    The Rockstar programming language specification

    Using a language known as Rockstar.

  • advent-2021

    Rust https://github.com/Crazytieguy/advent-2021/blob/master/src/bin/day12/main.rs At first I used a HashSet to keep track of which caves were visited, and it worked fine. As a fun challenge I wanted to avoid cloning on each recursion, so now each cave has an index and I keep which ones were visited in an array of bool.

  • aoc-2021

    Advent of Code 2021 with C#/LINQ (by jasonincanada)

    C# solution with basic graph search. I track the step counts to each cave and decide which next caves to take based on them, and prune it after returning from a recursive call to SearchFrom

  • aoc2021

    Advent of Code 2021 (by TheJare)

  • Main logic util.py for both parts (part 1 and part 2)

  • advent-of-code

    My solutions for the Advent of Code (by JesperDramsch)

    Python 3. Figured I'd learn some more networkx. Was useful for the "smol" attribute in the end and easily getting the neighbors. Full code is on Github.

  • advent-of-code-2021

    Misha's Advent of Code 2021 "hacking" (by mramendi)

  • aoc-typescript

  • advent-of-code

    Solutions for Advent of Code 2017 in javascript (ES6) (by Akallabet)

    Solution in Javascript, this one was so painful, I did use google quite a lot and try for so many hours and at the end the solution became incredibly simple

  • AdventofCode

  • advent-of-code-2021

  • AdventOfCode2021

    Also, decided to have a look at what the graph looked like with networkx

  • adventofcode

    https://adventofcode.com/2021/ (by Torakushi)

  • advent-of-code-2021

    github part 2 commit at part 1

  • adventofcode2021

    Solution on GitHub

  • icpcPrep

    Storage of competitive programming solutions

    Part 1 link Part 2 link (~5ms optimized)

  • aoc-2021-in-kotlin

  • AOCday12

    solution for AOC day 12

  • AdventOfCode2021.jl

    Advent of Code 2021 in Julia

  • AdventOfCode2021

    Advent of code solutiosn (by McSick)

    Rust: https://github.com/McSick/AdventOfCode2021/blob/main/12/tree-pathfind/src/main.rs Been optimizing and didn't even consider the release option. Debug mode ~3-3.5s. With release mode, part 2 runs in 0.35s including loading the input. Nice! Also did something unique than others and rewrote mine to use an adjacency matrix.

  • roast

    🦋 Raku test suite

    Recursive solution in Raku.

  • advent-of-code-2021

    All solutions for the 2021 Advent of Code event. (by Bruception)

  • Advent-of-Code-2021

    Advent of Code Solutions 2021 in Python (by DenverCoder1)

  • CodingExercises

    A variety of coding exercises for practice and to learn new languages

    My Rust solution

  • AdventOfCode2021

  • AdventOfCode2021

    My solutions to https://adventofcode.com/2021 (by willkill07)

  • The complex rules made this a bit fiddly to write. Writeup on my blog and code on Gitlab.

  • adventofcode

    Hmm, interesting! I'm definitely not getting the input on compile time either. I'm using a function in my util mod to either get it from the web (for the first time and store it) or read from a file (I did the flamegraph not on the first run). I see you are using std::fs::read_to_string to read your file. I'm using another method to read the files in a similar way but also use a BufReader in the middle of it. I'm not sure if it can make that of a difference but that seems like the only difference considering the rest of the parsing looks similar with iter/map stuff.

  • AdventOfCode2021FSharp

    Solutions for Advent of Code 2021 in F#

    F# with Jupyter Notebook. Slow but works. I'll probably come back to this day and optimize the solution.

  • advent-of-code-kotlin-2021

    Advent of Code 2021 Challenge (by PhenixFine)

    Kotlin - I didn't finish it until three in the morning and just now got around to cleaning up the code. I really struggled with part 2 ( path finding was one of my least favorite subject in computer science ). Though it probably wouldn't have taken so long if I had just scrapped part 2 when it became a mess, instead of wasting time trying to fix it.

  • advent-of-code-2021

    My solutions to https://adventofcode.com/2021 (by plan-x64)

  • advent-of-code

    Attempt 1 (GitHub)

  • adventofcode_2021

    My solutions for AoC21 in R and Julia

    That was the hardest so far for me. Pretty hacky and takes ~8s to finish. R / Rstats: Code

  • Advent_of_Code

    My Advent of Code solutions.

    My solution in Python. A simple search without recursion.

  • AoC2021

    Advent of Code 2021 (by travis-miller)

    Used DFS part 1 part 2

  • AdventOfCode2021

    Advent of Code 2021 challenge: 13 different languages, one chosen at random every day! (by Qualia91)

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts