-
It was fun figuring out the logic for decoding the numbers. Sets were pretty handy
-
CodeRabbit
CodeRabbit: AI Code Reviews for Developers. Revolutionize your code reviews with AI. CodeRabbit offers PR summaries, code walkthroughs, 1-click suggestions, and AST-based analysis. Boost productivity and code quality across all major languages with each PR.
-
-
I made another solution (Common Lisp) which I like better than my original one, even though there's more code supporting it (https://github.com/blake-watkins/advent-of-code-2021/blob/main/day8.lisp). The essential functions are:
-
Nice, you had the same idea as my Haskell solution.
-
Basically just solved it like a puzzle
-
ditto, same approch i used also inpython
-
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
-
F#, Took a different approach after solving it in TypeScript. Only need correct mapping for b, d, and e segment. Happy about the clean and simple F# code as compare to TypeScript.
-
Python3, 6124/137.
-
Python 3, using https://github.com/Z3Prover/z3 to find a satisfying assignment of segments for each line of input.... which is terribly slow (it's still running), and stressing my CPU fans, but I believe it will work!
-
-
-
Full solution at https://github.com/kunalb/AoC2021/blob/main/js/day08.js
-
adventofcode
Advent of Code solutions of 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 and 2024 in Scala (by sim642)
My Scala solution.
-
Rust -- part 1 was fairly easy, but I had absolutely no clue how to do part 2 for a long time. I ended up just brute forcing it, trying every single possible wire re-arrangement (thanks itertools::permutations). I used a bitmask to represent which lights were on (no idea if its necessary), but it was a fun exercise trying to get the bit fiddling right -- I was pleasantly surprised when it just worked (ig that's the benefit of writing small, fairly self-contained routines). My initial answer for part 2 was also reversed (3535 instead of 5353), which is why there's a rev in there near the end. Overall, very fun challenge -- I enjoyed not knowing how to approach it initially, and I'm sure lots of people will have far more clever solutions.
-
Lots of fun with sets
-
advent-of-code-go
All 10 years of adventofcode.com solutions in Go/Golang (and a little Python); 2015-2024
-
Python 505/180 featured on github
-
Elixir
-
-
-
Link to solution
-
-
Haskell, both parts: https://github.com/Javran/advent-of-code/blob/master/src/Javran/AdventOfCode/Y2021/Day8.hs
-
Python, had a ton of fun figuring this out. You all have elegant solutions, I have my cute little seven switch and a bunch of brute forcing. Code here!
-
Pascal 3590/5744
-
-
-
-
Python 3
-
-
Go, 1538 / 4240
-
I worked out a collection of equations that gave me each segment through set algebra. Here's the relevant piece in Python. Complete solution here
-
-
Golang + Prolog
-
Rust solution using bitmasks
-
My day 8 solution is a bit long to paste in here easily: https://github.com/kupuguy/aoc2021/blob/main/src/day8.py
-
part1 part2
-
-
-
7994 - [Part 1]
-
My Java implementation for both parts.
-
-
Part 1 wasn't too bad- I decided against parsing the strings and just counted based on string length.
-
Available on GitHub.
-
Common Lisp. Lost four hours to trying to force a backtracking approach lmao :/
-
Python
-
-
-
Solution in Kotlin: https://github.com/Shockah/Advent-of-Code/blob/master/src/pl/shockah/aoc/y2021/Day8.kt
-
An approach in Python!
-
Raku, 9341 / 11194. Linked code derives segment properties from a list of digits; the original code for submission hard-coded segment-count-to-presence and segment-count-to-absence values, which was shorter but less elegant. Part 1 is a 1-liner after parsing: [+] ($_.grep(so *.chars == any(2,3,4,7)).elems for $.parsed.made)
-
Advent-of-Code-2021
Made it through all 25 days of Advent of Code for the second time! (by Leftfish)
Here's my approach (I have no CS background) in Python. In short:
-
See my solution on GitHub.
-
This was a pain in the butt and I solved it with ugly spaghetti code. Because my patience was really starting to run out. Source code
-
-
Raku, see GitHub.
-
I'm so proud I solved part 2 in python just by using digits 7, 4 and 8. You don't need to know the exact correspondence of all the segments. Here's my solution
-
Clojure, for sure my worst one yet. BUT, I did get to use `clojure.set/invert-map` twice, so I count that as a partial win.
-
-
-
-
Inspired by this solution I cleaned my code a little: Code with comments on github
-
Python 3, O(n log n) for part 2 if I am not mistaken
-
-
-
This is my first solution for part 2, it runs instantly but it's ugly af - GitHub solution.
-
-
Python 3 Decode the mapping of each segment in a 7-seg display, then decode the input with that built up dictionary. Could probably improve that mapping in some way, as it's really ugly. However once i've gotten that logic down Part A and B become very easy. Solution A & B
-
Part 1
-
Generic pure-logic Kotlin solution, works with any non-conflicting configuration of digits :)
-
-
Javascript : solution here
-
-
-
Day 8
-
Kotlin
-
Today's and all previous days solutions here
-
-
Part1: https://github.com/SuddenGunter/adventofcode/blob/main/2021/day8/lib/task1.ex
-
advent-of-code-2021
Discontinued Code I used for solving https://adventofcode.com/2021 (by pavel1269)
-
Part 1 - one liner becaue why not
-
-
-
Anyone interested in the implementation or in further documentation can go to my GitHub.
-
aoc-2021
Discontinued Advent of Code 2021 [Moved to: https://github.com/TenViki/advent-of-code] (by TenViki)
Not the best but it works https://github.com/TenViki/aoc-2021/tree/main/08
-
My solution in python.
-
-
Interesting though that we ended up with a very similar approach from different angles - it seems like you thought about the problem and came up with how to identify the digits based on segments, whereas I chose to look at the data detached from any meaning and found that intersection counts yielded a unique sorting key - but that's in fact the very same thing.
-
-
Clojure (GitHub). For part 2, I did process of elimination to decode the remaining digits based on the already solved digits. For example, the segments for 2 can be determined by subtracting the segments for 7 from the 5-segment digits (2, 3, 5); 2 will be the only digit with three segments remaining.
-
Scala. Similar to others, just counted the output lengths for part 1 and used the overlap with 1/4 method for part 2.
-
I'm sure it could be tidied up: github
-
-
JS solution
-
as always: https://github.com/gerolfscherr/aoc2021/blob/main/src/AOC8.java part 1 was trivial, part two required surprisingly much code.
-
Rust [code] [explanation]
-
the sauce
-
github
-
I made the computer myself: https://github.com/jes/scamp-cpu/
-
https://github.com/naddi96/Advent-of-Code-2021/blob/main/Day 8 Seven Segment Search/f.py
-
-
-
-
-
I'm sure I can clean up my part 2, but it works, and it works swiftly, so we'll see how much I bother to think about it.
-
Perl solution... compact without comments.. See https://github.com/drbaggy/adventofcode/blob/main/2021/day-08/pt2.pl for commented version....
-
I created a mapping matrix and found a way to normalize the matrix by swapping rows and columns until it reached a standard form. Thus I could correlate code words to numbers. GitHub with commented code.
-
Did something similar in Python, but a little wordier.
-
My uhhh very verbal Liberty BASIC solution... I really did miss pre-implemented string- or datastruture manipulation functions available in python more than on the other days. Ended up with 199 lines haha (including some leftover prints and comments)
-
-
I have what might be the ugliest solution in all of C#, but it works!!!!! solution
-
-
JavaScript - Part 2
-
-
Part 1: https://github.com/stormsweeper/AdventOfCode/blob/master/2021/day08/php/segment_displays.php (~50ms exec time)
-
So yep, my solution is way harder to read than yours, twice as long, and ~1000 times slower :'D
-
I think today was very difficult because of the way the problem was layed out. Most of what you need to do for part2 was explained in part1 for no reason and the example werent exhaustive. I tried doing it with sets, then I also tried bruteforcing it and in the end I ended up doing a more manual approach which is very ugly but I am too tired to refactor rigth now. Part1 and part2 in Javascript.
-
Golang
-
C - https://github.com/purport/advent_of_code/blob/main/2021/day08.c
-
part 2 took me a bit to work out mentally how you could programmatically determine the mappings. I ended up settling on using some set logic. I typed up some notes if anyone cares to read.
-
Day 8 - PHP solution
-
Maple
-
My solution in Clojure. It was pretty loooooong and still leaves couple points of possible improvement.
-
-
Nice challenge and reminded of the days I was taught Prolog in University. But I'm afraid I did not really solve it the prolog way. Instead a very dirty solution in Scala, looking at sizes and being subset of earlier patterns. Found some nicer examples in other repos.
-
Rust
-
My Kotlin, Python, and Rust are following the same approach, although I didn't convert my Python solution to bit sets because it didn't seem to have a performance benefit there.
-
-
C# solution with a manual deduction process (one of many possible no doubt) that I figured out in the hours after midnight, then I slept on it and it took all morning to actually code the thing, but I like the result. Again a sprinkling of LINQ makes it bearable to write and read
-
Java
-
-
-
Rust
-
Another F# solution, for anyone who's interested: https://github.com/DurdSoft/AdventOfCode2021/blob/main/AdventOfCode2021/Day8.fs
-
Python
-
That sounds pretty much like my C# solution, except I used a bitmask instead of sorting.
-
-
-
My solution in Rust. It’s certainly not perfect, but it took me long enough to post it here.
-
-
Rust
-
Solution (ammonite). Though this one was interesting; brute force worked on first try but scratched an itch which led to full on rash of optimizations that can be done.
-
-
-
Python 3.9 part 1 and part 2 using Z3, which runs in about 18-20s.Describing constraints for this still makes me scratch my head.
-
Go / Golang with contains and sorting to match. Could use some cleanup and a good set logic... But run out of time. :D
-
Anyhow, my code: https://github.com/emteeoh/adventofcode2021/blob/main/8/8.py
-
Part 1 is pretty straightforward: https://github.com/Legolaszstudio/aoc2021/blob/main/Day8/08.cpp
-
C# After wrapping my head around part two for some time I had to take paper and figure out the mappings. Probably could be a bit cleaner, but overall I'm happy with the code and the fact I figured it out on my own. GitHub
-
-
-
My Kotlin solution
-
Okay I'm fighting github actions at the moment but I can direct link the pdf of the writeup: https://github.com/SV-97/SV-97.github.io/blob/master/assets/pdfs/2021-12-08-aoc21-8/aoc21-8.pdf
-
Python (Part 2: 54ms)
-
Here's my solution in F# in Juptyer Notebook. For Part 2, used a process of elimination for mapping the other patterns. The Seq.except method became very useful.
-
And part2 is here. Executes in about 40ms on my machine.
-
https://github.com/alokmenghrajani/adventofcode2021/blob/main/day08/day08_gophersat.go if you want to see how to solve today's with a SAT solver. IMHO, it's cleaner with z3 but the two versions are quite similar.
-
-
Rust solution, which was pretty fun to code, especially part 2. :)
-
Solution: https://github.com/c-kk/aoc/blob/master/2021-go/day08/solve.go
-
GitHub: https://github.com/Gallahad072/Advent-of-Code/blob/master/2021/8.py
-
I challenge you to write a worse solution than mine
-
Github
-
aoc2021
Advent of Code 2021 - z/OS Flask REST Solutions (runnning python and REXX lol) (by wizardofzos)
-
-
My solutions in Python 3: https://github.com/prendradjaja/advent-of-code-2021/blob/main/08--seven-segment-search/b.py
-
Did part 2 in Z3. It's a pretty inefficient solution, but it does work.
-
-
-
Rust solution, commented both solutions to clearly explain the used logic.
-
github solution
-
Github
-
Day 8 part 2 in python using set operations. https://github.com/en0/aoc2021/blob/main/08/p2.py
-
-
Haskell - parsing code left out because it is in another file. Full code here: https://github.com/FractalBoy/advent-of-code-2021/blob/main/src/Day8.hs
-
Rust Each segment has a unique combination of the number of times it appears, and the set of segment counts in the digits it appears in. Using this information I make a decoder without having to hard code an algorithm. https://github.com/Crazytieguy/advent-2021/blob/master/src/bin/day8/main.rs
-
Github Link
-
It's so... inelegant. I quickly solved the sample entry on paper and then implemented it. github link
-
My code is NOT optimized for brevity but for a balance of execution speed and readability. As this is not a brute force solution, speed does not really matter - otherwise the manual statements mentioned in the beginning are most likely faster than my fingerprint comparison. It runs on my MacBook in 1.5 ms if I suppress the repeated text output that is in the Github version (3 ms with all the text output).
-
F#
-
Rust ~285us.
-
-
-
GitHub/SevenSegment.java
-
Code is on GitHub.
-
-
-
-
Python 3.8 solution damn it took me 3 days to complete the part 2 for stupid attention error. Figuring out that counting letters in the sequence diagram was a huuuuge leap forward. Also sorting the letters.
-
-
-
So ugly, but got it done.
-
-
Julia
-
SaaSHub
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives