/r/Python's 2021 Advent of Code

It's (almost) December, which means it's time for Advent of Code!

Advent of Code is a yearly advent calendar where there's a new programming puzzle each day. They vary in difficulty and don't require a computer science background to solve. You can solve the problems using any programming language you like, so while we love python here, you can take this as an opportunity to explore other languages. If you have trouble with one of the puzzles, don't worry, another day's puzzle might be easier for you!

This year we're joining our sister community, /r/LearnPython, for a shared leaderboard. The /r/Python and /r/LearnPython leaderboard code is: 1179846-33292986

If you want to talk about your solutions, please state which day the solution is for, and then put the solution under the spoiler tag. Please be sure to format your code for reddit or host it on a code hosting site such as GitHub or GitLab. Additional discussion of the daily puzzles can be found on the Advent of Code Subreddit: /r/adventofcode

We hope you take this time as a chance to have some fun solving these puzzles! Good luck!

32 comments · 98% upvoted · other discussions

comments

Armaliite

Really enjoying the challenges so far! Trying to do it without using external libraries. So far numpy would have been very useful. They do seem to be progressively more challenging so I hope I can manage to finish all.

C6H5CH3

I have only been allowing myself numpy. And specifically methods which I am confident I could recreate in vanilla python just slower.

Good on you for recreating all that functionality :)

Really have enjoyed so far.
Oh and icecream for debugging.

Vipulkunwar

Do you've any suggestions I'm joining the first time?

Armaliite

Maybe you could have a look at this article: https://realpython.com/python-advent-of-code/

Try to solve the example first before you move on to all the data.

Vipulkunwar

Thank you for your suggestions. I'll do it.

[deleted]

What an extremely fun idea. Jesus would have been in favor of this, being a scholar who strove to get to the heart of things! :)

[deleted]

What do we do if we just want to look at or try prior years puzzles without authenticating or submitting anything?

Avanta8

Just change the date in the url

eisbear86

just as /u/Avanta8 said change the date in the url, but to see the actual puzzle inputs you need to authenticate in some way.

[deleted]

Lame.

EDIT: I mean I get it for the current year's puzzles, but why not relax that for years gone by?

[deleted]

I'd disagree were it not for the fact that they only allow OAuth. I just want my accounts separate! >:(

Strigone

You can login using reddit, and you can create a reddit account without an email address

pinging also u/SeerLite

576p

Why relax? Some people might still want to play it. And since github is full of people solving those, it's super easy to look up the solutions somewhere else...

thereal0ri_

So far if I could rate the projects.

(1/10) So far everything is fucking ass. Not enjoyable nor am I learning anything. It's not fun at all.

Words to anyone wanting to participate, if you're a beginner, don't bother. I've spent more time looking for how to do something right because I don't know how to do what's being asked of me than actually writing code and troubleshooting. You'd think it'd be fun, basic, chill, enjoyable, or good. But it's not any of that. It makes me NOT want to code rather than WANT to code.

Also, there are 2 parts per day. So get ready for that mess too. Instead of 1 project a day, nah, gotta do 2 things.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

My progress;

  • Day2 [4 stars]: (pretty much gave up/quit)
xelf

To be honest, day's 1 and 2 were the easy ones. Day 3, while interesting, was way more time consuming than the other 2 put together.

If you're really struggling pop on the discord and ask for advice.

Do not think of AOC as a contest, leave that to the speedcoders who have been practicing all year, instead think of it as a learning experience. Ask lots of questions!

And if you're still really struggling, /u/jonathan_paulson posts videos of how to solve all the puzzles minutes after the problems go live.

here's day 1: https://youtu.be/pkLfyRwDMMw
here's day 2: https://youtu.be/e3_iiz_6bFw

trust_me_on_that_one

Words to anyone wanting to participate, if you're a beginner

I did look at it and yes, there's no way I could even solve the first one, but you know what? I just closed the window and went to do something else.

There wasn't a time where did I feel the need to get this worked up over a game lol

As far as I'm concencerned, the creators of Advent of Code owe me nothing.

jamescodesthings

Sounds tough, where did you struggle?

I’m using it as a gateway into python from other languages but I can appreciate others might not find it as useful.

who_body

perhaps check out this walkthrough of day 1…author iterates through progressively more advanced solutions. maybe this will be helpful for a beginner

https://www.reddit.com/r/Python/comments/r6y73y/indepth_analysis_of_python_solutions_to_advent_of

mr_clemFandango

sounds like you were expecting to be hand held through each task - the idea is that you learn independently to solve the challenges - they aren't supposed to be easy!

thereal0ri_

I wasn't expecting to be handled and I understand. I was expecting something maybe a little bit more fun and chill for the holidays.

Also nothing so far has taught me anything nor have I learned. It's instead just made me feel like I don't know a single thing and useless.

Like..I can make full on bots with anti stupid logic, I can make lots of things already with my 2+ years of using python...but these "challenges" make me feel like I don't know a single thing and stupid..

mr_clemFandango

it's more a test of problem solving than coding skills.

the code ability you need can be fairly low (lists and loops basically) - it's the logic that is difficult

thereal0ri_

Right, I understand that. The concept is basic, but what you have to do in order to get the answer isn't basic. Infact it's like advanced gymnastics under the blanket of a preschool playground.

Everytime I am able to understand what is needed/the concept. I'll need to turn it into a list and loop through the stuff. But what I need to do in order to answer the question is anything but basic. Like, after I gave up on day 2 and resorted to looking up others code repositories, never in a million years would I have figured out how to get the answer to the questions without it. So something involving "basic" concepts, doesn't involve doing basic and simple things to get an answer.

sobek696

You don't have to do the 2 parts. The second part is deliberately more challenging, potentially encouraging a more generic solution on a harder case, for people who want the fun.

The main 'idea' behind each question is often hinted at with bold (in day 1 -- "the number of times a depth measurement increases")

Often, a helpful first step is to quickly look at what example data they give, then look for some bold text near that, then maybe read the question more thoroughly.

who_body

for day 3…what if the the counts of 0 are equal to the counts of 1?

anyone?

xelf

It's in the text what to do. Reread the problem. =)

wsrq

Perhaps he was referring to the part 1 where it isn't specified.

xelf

You could be right, but it doesn't occur in part 1 though.

Vipulkunwar

I heard this first time. But it seems too great and enthusiastic. Do anybody crack all of them? I'm happy to know.