r/adventofcode • u/ImpossibleSav • Dec 07 '23
Visualization [2023 Days 1-6] [Python] Visualizing the length of the Basilisk, my Python one-liner that solves all the puzzles so far!
105
Upvotes
r/adventofcode • u/ImpossibleSav • Dec 07 '23
15
u/ImpossibleSav Dec 07 '23 edited Dec 07 '23
GitHub has stopped syntax highlighting part of the Basilisk, so I figured it was time to share! Just like last year, I'm trying to solve all of this year's problems in a single line of Python code. Here is the link to the Basilisk, which is my pet name for the absolutely beautiful line of code that combines of all the days' solutions together into one.
My one-line solutions are not efficient, so the code is a bit slow and will continually get slower as the month progresses. But I do have each individual solution in different .py files in the repo if you would like to take a closer look. I'm also trying to post each day in the solution megathreads.
This visualization shows the number of characters in my one-line solutions for each part of each day. I actually wrote up a small script to automatically count the characters, calculate their percent of the whole, pick a proportional colour on a rainbow gradient, and save the rainbow line in an SVG file so I can easily use that as the snake's fill colour. This way, I can update the visualization each day as soon as I finish coding the solution. (Don't worry, I won't spam the subreddit with them — it's just for my own antics!) The automation script is here, if anyone is interested.
I made it through about a dozen days last year, so we'll see how far I get this year. I'm learning a lot of new strategies though, so I'm optimistic! :)
5
u/mount-cook Dec 07 '23
that's next level. I have a thing for python one-liners as well haha.Do I understand correctly that all your solutions are one single expression, so there's no semicolons in it?
2
u/keithstellyes Dec 07 '23
Incredible. Do you think it would be possible to have all years and all days? A true monster? I wonder what point the Python environment chokes
2
u/trevdak2 Dec 07 '23
Oh man, I'm tempted to do this with my golfed javascript solutions. There's been disappointingly little golf this year compared to last year. I'd love to see how few bites I would need for all solutions at once
17
u/CocksuckerDynamo Dec 07 '23
Thanks I hate it
3
u/dl__ Dec 07 '23
You are clearly a witch. What black sorcery is this?!
1
u/RussellDash332 Dec 17 '23
I've been doing all one-liner up to Day 17 (today) :D
1
u/mistrzegiptu Dec 07 '23
After seeing this I hate python even more. Interesting idea tho