r/learnpython • u/darthminimall • Nov 30 '20
Advent of Code
Advent of Code starts tomorrow. If you don't know, it's 25 programming puzzles released daily from the 1st-25th of December. It's a good way to practice Python if that's something you're interested in (or any other language, for that matter).
29
u/RobinsonDickinson Dec 01 '20
Are these easy problems? algorithms ?
36
u/darthminimall Dec 01 '20
The difficulty increases over time. In my experience, all of the problems are solvable with, at most, a bit of research.
25
u/__developer__ Dec 01 '20
I did it last year and the difficulty generally increased over time, but a few of the problems took me quite a bit longer than others. About half of the problems last year, the "Intcode" problems, were related to creating virtual computers that could interpret and execute simple commands that were sent to them. Its fun and a good way to practice a language and learn new algorithms.
10
u/xelf Elf Dec 01 '20 edited Dec 01 '20
Today's problems took about a minute to answer, and about 5 minutes to download the text: the server was so overloaded at first. But there will be some days where a problem might take some amount of googling before you can start coding. For example if you need a particular math formula but don't actually know it exists already, or that it's what you're looking for.
5
u/Sw429 Dec 01 '20
Yeah, you're bound to hit some 503s if you try to download it immediately when it opens like I did. This is a pretty popular challenge, especially now that it's in its sixth year.
4
u/xelf Elf Dec 01 '20
Part of that is brought about by rewarding people that are in the first 100 to complete. Hopefully it will slow down a bit as the problems take longer to solve. It certainly seemed fairly stable when it did come back up.
14
11
u/Lamboarri Dec 01 '20
RemindMe! 1 day “Advent”
9
u/xelf Elf Dec 01 '20
Starts in about 2.5 hours (midnight ET)
4
u/Lamboarri Dec 01 '20
I'll be going to bed soon so wanted it to remind me tomorrow sometime so I could revisit this thread for the link. Thanks, though. Didn't realize this was posted so long ago.
1
u/remindditbot Dec 01 '20 edited Dec 01 '20
Lamboarri, kminder in 1 day on 2020-12-02 09:00:00Z
Thanks, though.
6 OTHERS CLICKED THIS LINK to also be reminded. Thread has 7 reminders.
OP can Set timezone, Delete comment, and more options here
Protip! How can your butt look good without any meat on it?
8
u/__developer__ Dec 01 '20
There is also the subreddit /r/adventofcode where people discuss the puzzles for this year and previous years.
6
1
3
u/lohtech Dec 01 '20
I am planning to follow this year's event each day. No doubt there will be days where the solution is too difficult. The aim is to go for somewhat optimal algorithms / solutions as opposed to just brute forcing it with time and compute.
Feel free to refer to my progress / solutions here if you want a sanity check, provide feedback or take reference. Hope this is not against the spirit of the event (since it's not really a competitive event), but more to encourage mutual learning!
3
u/SatuSPR Dec 01 '20
Just did day 1, was really fun. Thanks for posting, otherwise I wouldn't have seen this.
2
u/Groentekroket Dec 05 '20
Yeah indeed! I have done all the challenges so far and I really enjoyed it while learning new things. Thanks u/darthminimall for posting this!
2
u/johnsandall Dec 01 '20
I'm publishing my solutions to this year's Advent of Code accompanied by full notebook explanations as a free teaching resource.
Bonus: PEP8/black/pylint/mypy compliant code + working environments!
Try yourself first: https://adventofcode.com/2020/day/1
Then look 👀 https://github.com/john-sandall/advent-of-code/
1
u/xelf Elf Dec 02 '20 edited Dec 02 '20
This will be handy to have as a complete compilation. You might want to check other solutions to the problems as they're posted in adventofcode.com though, to see if you missed anything or to offer alternate solutions.
return [a * b for a in expenses for b in expenses[expenses.index(a) :] if a + b == 2020][0]The problem with this approach is that it's O( N3 ) because of the for loops and index().
You can do it O( N2 ) using combinations:
print( [prod(c) for c in combinations(expenses,2) if sum(c) == 2020] )Or even O(n) if you use a set or dictionary:
setexp = { 2020-e : e for e in expenses } print( [setexp[e]*e for e in expenses if e in setexp] )Although that's not the best O(n) solution because it would think 1010 is a valid answer on it's own. /u/baghiq posted a better solution earlier today using a set.
Anyway, I like the idea good luck to you and keep it up!
2
u/Cleover453 Dec 01 '20
is it for beginners and amateurs👀
8
u/ixipaulixi Dec 01 '20
Last year's started out easy and then got really tough.
2
u/Cleover453 Dec 01 '20
I will try
4
u/ixipaulixi Dec 01 '20
Definitely do so; I didn't know Python last year, so I was doing it in Bash. I got to like the 10th or 11th lesson and just caved in...I was spending too much of my personal time trying to make it work.
I've since started learning Python, and am looking forward to giving it another shot this hear. Hopefully I'll get higher up on my work's leaderboard this year.
2
u/Cleover453 Dec 01 '20
I am a software developer student (hoping to get AS degree by 2022). I am trying to get as most skill as I can. I hope that will help me to get to amateur lvl
2
u/ixipaulixi Dec 01 '20
I'm not a developer, so I couldn't say whether or not this bump you from beginner to amateur, but you'll definitely learn something if you participate.
1
Dec 01 '20
[removed] — view removed comment
3
u/ixipaulixi Dec 01 '20
They only accept the answer and the only feedback you'll get is whether it's right or wrong.
2
u/ffrkAnonymous Dec 01 '20
I say yes. I tried last year and it starts easy and builds on each day. I only got about 10 days in but it was still fun. And of course, you learn by seeing everyone else's solutions.
1
1
1
1
u/bigamaxx Dec 01 '20
Check the html source code of the advent of code site its a nice detail you can see here
1
1
u/surprajs Dec 01 '20
Is this site working for you right now? I have some "We'll be right back" communicate.
1
u/vxc601 Dec 01 '20
If I start on the weekend, will all puzzles be available, or only the ones for the current day?
1
1
1
1
1
1
u/RobertGryffindor Dec 02 '20
As a beginner, it was nice to feel a sense of accomplishment with this. I know it was easy, but I was able to do it without hitting a wall or having to google anything.
Here's the code I used
•
u/xelf Elf Dec 01 '20
It starts in about 2.5 hours . "Tomorrow" isn't quite accurate depending on what time zone you're in. =) It starts Nov 30 at 9pm PT (midnight ET)
https://adventofcode.com/2020