r/badcode • u/theabbiee Biggus Dickus • Dec 08 '21
python My submission for Advent Of Code, In my defense, the problem was actually hard
26
Upvotes
r/badcode • u/theabbiee Biggus Dickus • Dec 08 '21
2
u/hp77reddits Dec 09 '21
slightly off topic but how do you capture screenshot like this of your code? I have always wondered.
7
u/Sanduhr32 Dec 08 '21
You can simplify a lot of this code actually. I also solved today. I applied some functional programming for getting rid of some loops, but majority of my code also is for the 2nd part. I created some helper methods like returning the intersecting char amount of 2 strings (without sets) & finding the random arranged chars for the 7 segments in an ordered array (index equal to the number represented by the segments for the number at that index), since the chars representing a number also are randomly ordered.
Can link code if you want. It was a nice challenge. I hope you have fun and will continue participating
3
u/___R3D___ Dec 09 '21
I'm pretty sure more than half of people that did Day 8 could post their solution on here lmao
3
u/kristallnachte Dec 11 '21
I didn't find this one that hard.
I did similar method to you. I don't really understand you "top char" stuff....you can just count how many match, you don't actually have to know which ones map or not.
2
u/seeroflights Dec 09 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
1
u/[deleted] Dec 08 '21
the code would be fine if there were more methods to separate...
1
u/BadHairDayToday Dec 27 '21 edited Dec 27 '21
I wanted to show off my superior solution but it turnes out I didn't even solve day 8 part 2 yet. Bad code still beats non-functioning code. Congrats!
In fact, now that I look at it a bit better the code isn't even that bad. You could load up the file a bit nicer though, and shorter names would help legibility.
So yeah it's a really challenging one. I can do it on paper.