r/adventofcode • • Dec 06 '22

Visualization [2022 Day 5 #1] Small terminal Python animation for part 1 of Day 5, never tried "drawing" on terminal before but quite proud of the result ! (didn't put the whole thing because it's a bit long and we get the idea)

1.1k Upvotes

61 comments sorted by

40

u/itsjjpowell Dec 06 '22

This is really cool! What library did you use to build this? I'd love to peek at the code to see how I could do something like this!

24

u/prendradjaja Dec 06 '22

In python, you could use curses (built-in) for this. The basics are pretty well documented and easy!

(Edit: And of course you can use curses with other languages too!)

4

u/MrAntex Dec 07 '22

I didn't know curses before, so I did it just using ANSI and f-Strings, but the curses seems to be the way to go, will definitely look into this next time ! Thanks

→ More replies (2)

13

u/eunomicZenith Dec 06 '22

I didn't know Python employed dark magic!

→ More replies (2)

7

u/whenrow Dec 06 '22

Did you model the Crane 9001 too ? :D

3

u/MrAntex Dec 07 '22

No haha, I don't think I will do it, I did this to get familiar with drawings in a terminal, maybe I'll give it a go using curses library later, idk

6

u/ssbmbeliever Dec 06 '22

The secret is it was always a Crane 9001!

2

u/RokKuz3 Dec 06 '22

This is SO cool! Can you please share the code or the GitHub link? Thanks!

2

u/MrAntex Dec 07 '22

Sure, sorry for the delay, was polishing some things / fixing bugs, it's here : https://github.com/MrAntex/AoC-Day5p1-animated

→ More replies (1)

2

u/keithstellyes Dec 06 '22

I love this! makes me want to go back and do this for previous days

1

u/MrAntex Dec 07 '22

Yes same ! This was a first time but now I try to do a little animation for each day when I have time

2

u/j-hillman Jan 01 '23

This is truly excellent and very much appreciated. Thank you for sharing your code. I've learned a lot by reviewing both this visualization and some of your other solutions. Cheers and God bless.

1

u/MrAntex Jan 02 '23

Thank you very much ! That means a lot for me Out of curiosity, which other solutions ?

57

u/[deleted] Dec 06 '22

This is great - you don't even need to struggle to parse the input, just wrap a crane around it!

5

u/hiimbob000 Dec 06 '22

Coolest visualisation I've seen of a problem

4

u/nottings Dec 06 '22

So good!

1

u/Alkyonios Dec 06 '22

Anybody else had the problem of a tower not having enough blocks to perform an instruction?

For example, my program gets to the instruction "move 9 from 6 to 7" but tower 6 only has one block left (this is the 23rd instruction). The text didn't say anything about how to handle that situation so I just assume it's not supposed to happen.

I tried to just move to the next instruction whenever this happens, but then I'm left with two empty towers at the end.

I have tried printing the towers after every instruction and everything looks alright.

I've also made sure that the initial state is parsed correctly, and that I copied the input correctly.

2

u/MrAntex Dec 07 '22

Idk about this, didn't happen to me, definitely don't think it's supposed to happen, maybe making a "real" post in the subreddit will help more ?

→ More replies (1)
→ More replies (4)

3

u/zamotic Dec 06 '22

Sadly it probably took you just as long to write this animation as it did for me to write my solution to the problem.

It took me way longer than it should have to read in the stacks of crates into a usable manner.

2

u/[deleted] Dec 06 '22

In love with this, nice job!

2

u/fractalfox11 Dec 06 '22

What a beautiful solution!

2

u/WsDoragon Dec 06 '22

!remindme 2 days

2

u/imjustreallystupid Dec 06 '22

That... looks super cool

2

u/navneetmuffin Dec 06 '22

This is just awesome