Are there enough people planning to participate this year that it would be good to set up a temporary subgroup again with daily topics, like we did last year? I'll watch to see how many people...
I'll watch to see how many people respond to this thread, or reply to this comment and let me know if you're planning to participate (even if you're not starting quite yet). If it looks like we have a decent size group, I'll set that up again.
I'm willing to give it a go this year. I've never tried before, but my Python is at a reasonable enough level to give it a whirl, I think Edit: I take it back. I am struggling to concentrate even...
I'm willing to give it a go this year. I've never tried before, but my Python is at a reasonable enough level to give it a whirl, I think
Edit: I take it back. I am struggling to concentrate even on day 1's challenge TT_TT
I'm joining in; going to be coding mostly in C#, unfortunately. I may go back and redo some questions in other languages if I think it's a good exercise.
I'm joining in; going to be coding mostly in C#, unfortunately. I may go back and redo some questions in other languages if I think it's a good exercise.
Alright, I created the sub-group (and moved this topic into there): ~comp.advent_of_code If you posted solutions inside this topic, please copy/move them into the threads for Day 1 and Day 2....
Alright, I created the sub-group (and moved this topic into there): ~comp.advent_of_code
If you posted solutions inside this topic, please copy/move them into the threads for Day 1 and Day 2.
I started off trying to solve things in Rust, but... It's so much work to do even simple things, I feel. I've got a background in Perl, and it took me maybe three minutes to solve the first task...
I started off trying to solve things in Rust, but... It's so much work to do even simple things, I feel.
I've got a background in Perl, and it took me maybe three minutes to solve the first task of day one.
Doing the same thing in Rust requires a whole lot of boilerplate.
I still got it done, but it seemed much harder than it should be.
Or maybe I'm just not used to learning things anymore. Which is a bit of a scary thought.
oh man, I need to learn a language quick. I did the first three(!!) in Sheets... but I doubt I'll be able to hack through most of them this way. edit: If anyone wants to see my sheet so far, you...
oh man, I need to learn a language quick. I did the first first two three(!!) in Sheets... but I doubt I'll be able to hack through most of them this way.
If it's anything like last year, where you had to implement a bytecode interpreter and build upon it in subsequent days, then yeah, Sheets may be a bit unsuitable.
good Lord. There's a guy in the sub that has been doing everything with Excel -- so there is still hope. But yes, I am also doubting I can complete it with sheets alone. I've dipped into a little...
good Lord. There's a guy in the sub that has been doing everything with Excel -- so there is still hope. But yes, I am also doubting I can complete it with sheets alone. I've dipped into a little python, but not a lot.
=ARRAYFORMULA( COUNTIF( REGEXEXTRACT( A1:A, REPT( ".", MOD( TRANSPOSE( SEQUENCE(1,COUNTA(A1:A),4,3)-3)-1, LEN($A1:A)))& "(.)"), "#")) wow, I'm stunned. If anything, this is even more impressive...
=ARRAYFORMULA( COUNTIF( REGEXEXTRACT( A1:A, REPT( ".", MOD( TRANSPOSE( SEQUENCE(1,COUNTA(A1:A),4,3)-3)-1, LEN($A1:A)))& "(.)"), "#"))
wow, I'm stunned. If anything, this is even more impressive than using a "real" language.
Highly recommend Python. It has a relatively simple syntax that's pretty close to plain english and it's incredibly powerful. I started learning with a raspberry pi and I'd highly recommend it to...
Highly recommend Python. It has a relatively simple syntax that's pretty close to plain english and it's incredibly powerful.
I started learning with a raspberry pi and I'd highly recommend it to anyone who can swing the $20-35 pricetag.
Raspberry PIs are really cool and a great learning tool, but there isn't really anything special about using them for python. You can install python on your windows machine in 5 minutes!
Raspberry PIs are really cool and a great learning tool, but there isn't really anything special about using them for python. You can install python on your windows machine in 5 minutes!
This is really cool! I like the way you've built some sort of run harness for all your days! I end up creating a separate crate for each day so I have to start from scratch. Making a runner like...
This is really cool! I like the way you've built some sort of run harness for all your days! I end up creating a separate crate for each day so I have to start from scratch. Making a runner like this might make doing the rest of the days less tedious.
Sure! I have two separate solutions for day 1. I made a simple iterative solution that isn't very interesting, but I also made a generalized recursive solution that will find any sum and any...
Sure! I have two separate solutions for day 1. I made a simple iterative solution that isn't very interesting, but I also made a generalized recursive solution that will find any sum and any number of terms. It's suuuper slow though, like half a second to do 3 terms. I haven't spent any time looking into why that is, I'm sure there's some allocations or moves that I'm doing that I shouldn't be.
I only really attempted AoC once before, doing each day's challenge in a different programming language. I didn't get very far. This year I'm focusing on completion and to a lesser degree speed....
I only really attempted AoC once before, doing each day's challenge in a different programming language. I didn't get very far. This year I'm focusing on completion and to a lesser degree speed. So Python it is.
I've been reading SICP so I want to do it in scheme, but I also like (attempting) to race and scheme is too slow for me, so I'm hacking it out in python then making a nice scheme solution. Day one...
I've been reading SICP so I want to do it in scheme, but I also like (attempting) to race and scheme is too slow for me, so I'm hacking it out in python then making a nice scheme solution.
I did 2017 and 2018 in JS, will be doing 2020 in the same. Here's my run harness and solutions. I'm happy with the workflow: run tests in watch mode (so they immediately execute when I save a file...
I did 2017 and 2018 in JS, will be doing 2020 in the same. Here's my run harness and solutions. I'm happy with the workflow: run tests in watch mode (so they immediately execute when I save a file in vim) while writing the answer, followed by yarn run solve 2020 02 1, which downloads the input from AoC, executes your solution, and puts the answer in your clipboard.
I'm using Python using Anaconda and Jupyter Notebook. I love Advent of Code because it's a great chance to stretch my coding muscles. Day 1 A For this one I just brute forced it. This rechecks...
I'm using Python using Anaconda and Jupyter Notebook. I love Advent of Code because it's a great chance to stretch my coding muscles.
Day 1 A
For this one I just brute forced it. This rechecks several time, both 'A' + 'B' = 2020 and 'B' + 'A' = 2020 show up as valid results. If you wanted to be more efficient, you could make sure that each combination only gets checked once.
test_data = '''1721
979
366
299
675
1456'''
numbers = test_data.split('\n')
for i in range(0, len(numbers)):
numbers[i] = int(numbers[i])
for num1 in numbers:
for num2 in numbers:
if num1 != num2 and num1 + num2 == 2020:
print(f"Match Found: {num1} + {num2} = 2020")
print(f"{num1} * {num2} = {num1 * num2}")
Day 1 B
This is basically the same as part A, but with an added layer. So instead of checking 'A' + 'B', you're checking 'A' + 'B' + 'C'. This is far, far less efficient because of that added step, but with a data set this small it didn't really matter.
test_data = '''1721
979
366
299
675
1456'''
numbers = test_data.split('\n')
for i in range(0, len(numbers)):
numbers[i] = int(numbers[i])
for num1 in numbers:
for num2 in numbers:
for num3 in numbers:
if num1 != num2 and num1 != num3 and num2 != num3 and num1 + num2 + num3 == 2020:
print(f"Match Found: {num1} + {num2} + {num3} = 2020")
print(f"{num1} * {num2} * {num3} = {num1 * num2 * num3}")
Day 2 A
For this one I wrote a regular expression and broke up each line into it's component pieces. From there it was a matter of using each of the pieces to check if the password fit.
Regular expressions are somewhat cryptic, and if you haven't learned how to deal with them, I highly recommend https://regexone.com/
It does take a bit of work to learn how to use them, but they are excellent at solving certain types of problems
import re
test_data = '''1-3 a: abcde
1-3 b: cdefg
2-9 c: ccccccccc'''
passwords = test_data.split('\n')
pattern = re.compile(r'(\d+)-(\d+)\s(\w):\s(\w+)')
valid_passwords = 0
for password in passwords:
match = pattern.match(password)
min_val = int(match.group(1))
max_val = int(match.group(2))
important_char = match.group(3)
passphrase = match.group(4)
count = passphrase.count(important_char)
if count >= min_val and count <= max_val:
valid_passwords = valid_passwords + 1
#print(f"{password} meets the criteria")
else:
pass
#print(f"{password} does not meet the criteria")
print(f'A total of {valid_passwords} passwords were valid')
Day 2 B
For this one my regex solution was robust enough that I didn't have to rework it. Though I did rename some of the variables for added readability. I did need to redo the password validation check though.
This is basically an XOR logic gate, where it will be true if exactly one of the parameters is TRUE and FALSE if neither or both of the parameters are TRUE. I put a quick one together by starting with 0. Each of the criteria that was TRUE would add +1. If the value at the end was exactly 1, I knew my result was valid. If it was anything other than 1, I knew the result was invalid.
In the code below I separated out 0 and 2 as results for my own debugging purposes, but really the only check you need to make is if it equals 1.
Don't worry about the competition part, just compete against yourself.
Don't be afraid to ask for help. But if you ask for help, try to understand what people are telling you, rather than just copying it
These will get substantially harder as time goes one. The later ones especially will be a challenge even for experienced programmers. Don't beat yourself up if you can't figure them out
Sometimes the hardest part is just getting started. Even getting to the point where you can even start working on the problem takes some effort. Before you even start trying to solve it you need 1)Somewhere to run the code. 2)The problem data in a place you can work with it. I recommend downloading Anaconda and using Jupyter Notebook. Then you can just copy-paste the data into a variable (but you'll need to reformat it or use triple quotes like in my examples
In these early days I usually like to make things more difficult for myself. I'm doing these in Rust. My solution to Day 1 is generalized to any sum and number of terms: Day 1 use std::io; use...
In these early days I usually like to make things more difficult for myself. I'm doing these in Rust.
My solution to Day 1 is generalized to any sum and number of terms:
Looking at the global leaderboards: how do people solve a challenge faster than it takes me to read the task? Are the problems similar to last years? I could, for example see myself running tons...
Looking at the global leaderboards: how do people solve a challenge faster than it takes me to read the task?
Are the problems similar to last years? I could, for example see myself running tons of programs on an input and seeing whether one of them yields a result. Or do people actually just speed read and code a quick hack in literally under 2 minutes ?
The latter, I think. Some people are into "competitive programming" - solving Advent of Code-style problems quickly - and that kind of practice, alongside knowing a language very well, leads to...
The latter, I think. Some people are into "competitive programming" - solving Advent of Code-style problems quickly - and that kind of practice, alongside knowing a language very well, leads to the crazy / scary sub-two minute times on the leaderboard.
Are there enough people planning to participate this year that it would be good to set up a temporary subgroup again with daily topics, like we did last year?
I'll watch to see how many people respond to this thread, or reply to this comment and let me know if you're planning to participate (even if you're not starting quite yet). If it looks like we have a decent size group, I'll set that up again.
Here to chime in that I'll be participating as well
I plan to participate! Hopefully I can make it all the way through this year.
I shall try this year... But I'll probably only get the first couple done... I'm pretty bad! lol
I did 20/25 in 2018, skipped 2019, but am planning on giving it another go this year.
I am planning to participate!
I will be participating, and I would love to have the posts like we did last year!
Might not have time for the later ones, but I'll definitely be participating for the first few!
I'm willing to give it a go this year. I've never tried before, but my Python is at a reasonable enough level to give it a whirl, I think
Edit: I take it back. I am struggling to concentrate even on day 1's challenge TT_TT
I'm going to participate, at least until I lose steam
I'm joining in; going to be coding mostly in C#, unfortunately. I may go back and redo some questions in other languages if I think it's a good exercise.
I'm in! Finished the first two in JS, will keep going as time allows.
Alright, I created the sub-group (and moved this topic into there): ~comp.advent_of_code
If you posted solutions inside this topic, please copy/move them into the threads for Day 1 and Day 2.
Mentions for people with solutions in here: @Bauke @clone1 @petrichor @andre @PapaNachos @blitz
Time to play with a bit of Rust again! Maybe this year I won't peter off at day 10 :)
I started off trying to solve things in Rust, but... It's so much work to do even simple things, I feel.
I've got a background in Perl, and it took me maybe three minutes to solve the first task of day one.
Doing the same thing in Rust requires a whole lot of boilerplate.
I still got it done, but it seemed much harder than it should be.
Or maybe I'm just not used to learning things anymore. Which is a bit of a scary thought.
oh man, I need to learn a language quick. I did the
firstfirsttwothree(!!) in Sheets... but I doubt I'll be able to hack through most of them this way.edit: If anyone wants to see my sheet so far, you can see it here.
If it's anything like last year, where you had to implement a bytecode interpreter and build upon it in subsequent days, then yeah, Sheets may be a bit unsuitable.
good Lord. There's a guy in the sub that has been doing everything with Excel -- so there is still hope. But yes, I am also doubting I can complete it with sheets alone. I've dipped into a little python, but not a lot.
=ARRAYFORMULA( COUNTIF( REGEXEXTRACT( A1:A, REPT( ".", MOD( TRANSPOSE( SEQUENCE(1,COUNTA(A1:A),4,3)-3)-1, LEN($A1:A)))& "(.)"), "#"))
wow, I'm stunned. If anything, this is even more impressive than using a "real" language.
Thanks! It's a goofy way to approach it, but it appears to be leaner than the stuff the other spreadsheet folks are doing. :)
Highly recommend Python. It has a relatively simple syntax that's pretty close to plain english and it's incredibly powerful.
I started learning with a raspberry pi and I'd highly recommend it to anyone who can swing the $20-35 pricetag.
Raspberry PIs are really cool and a great learning tool, but there isn't really anything special about using them for python. You can install python on your windows machine in 5 minutes!
I started with GPIO stuff, was still in school and having that concrete connection to reality seemed to make it more "real" to me.
This is really cool! I like the way you've built some sort of run harness for all your days! I end up creating a separate crate for each day so I have to start from scratch. Making a runner like this might make doing the rest of the days less tedious.
Sure! I have two separate solutions for day 1. I made a simple iterative solution that isn't very interesting, but I also made a generalized recursive solution that will find any sum and any number of terms. It's suuuper slow though, like half a second to do 3 terms. I haven't spent any time looking into why that is, I'm sure there's some allocations or moves that I'm doing that I shouldn't be.
Day1
Followup: I finished and posted my day 2 here
I only really attempted AoC once before, doing each day's challenge in a different programming language. I didn't get very far. This year I'm focusing on completion and to a lesser degree speed. So Python it is.
I've been reading SICP so I want to do it in scheme, but I also like (attempting) to race and scheme is too slow for me, so I'm hacking it out in python then making a nice scheme solution.
Day one
Day two
I did 2017 and 2018 in JS, will be doing 2020 in the same. Here's my run harness and solutions. I'm happy with the workflow: run tests in watch mode (so they immediately execute when I save a file in vim) while writing the answer, followed by
yarn run solve 2020 02 1
, which downloads the input from AoC, executes your solution, and puts the answer in your clipboard.Day 01
Day 02
I'm using Python using Anaconda and Jupyter Notebook. I love Advent of Code because it's a great chance to stretch my coding muscles.
Day 1 A
For this one I just brute forced it. This rechecks several time, both 'A' + 'B' = 2020 and 'B' + 'A' = 2020 show up as valid results. If you wanted to be more efficient, you could make sure that each combination only gets checked once.Day 1 B
This is basically the same as part A, but with an added layer. So instead of checking 'A' + 'B', you're checking 'A' + 'B' + 'C'. This is far, far less efficient because of that added step, but with a data set this small it didn't really matter.Day 2 A
For this one I wrote a regular expression and broke up each line into it's component pieces. From there it was a matter of using each of the pieces to check if the password fit.Regular expressions are somewhat cryptic, and if you haven't learned how to deal with them, I highly recommend https://regexone.com/
It does take a bit of work to learn how to use them, but they are excellent at solving certain types of problems
Day 2 B
For this one my regex solution was robust enough that I didn't have to rework it. Though I did rename some of the variables for added readability. I did need to redo the password validation check though.This is basically an XOR logic gate, where it will be true if exactly one of the parameters is TRUE and FALSE if neither or both of the parameters are TRUE. I put a quick one together by starting with 0. Each of the criteria that was TRUE would add +1. If the value at the end was exactly 1, I knew my result was valid. If it was anything other than 1, I knew the result was invalid.
In the code below I separated out 0 and 2 as results for my own debugging purposes, but really the only check you need to make is if it equals 1.
Tips for Beginners
Don't worry about the competition part, just compete against yourself.
Don't be afraid to ask for help. But if you ask for help, try to understand what people are telling you, rather than just copying it
These will get substantially harder as time goes one. The later ones especially will be a challenge even for experienced programmers. Don't beat yourself up if you can't figure them out
Sometimes the hardest part is just getting started. Even getting to the point where you can even start working on the problem takes some effort. Before you even start trying to solve it you need 1)Somewhere to run the code. 2)The problem data in a place you can work with it. I recommend downloading Anaconda and using Jupyter Notebook. Then you can just copy-paste the data into a variable (but you'll need to reformat it or use triple quotes like in my examples
In these early days I usually like to make things more difficult for myself. I'm doing these in Rust.
My solution to Day 1 is generalized to any sum and number of terms:
Day 1
I noticed Day 2 is easily parallelizable so I took a multithreaded approach to the problem:
Day 2
Looking at the global leaderboards: how do people solve a challenge faster than it takes me to read the task?
Are the problems similar to last years? I could, for example see myself running tons of programs on an input and seeing whether one of them yields a result. Or do people actually just speed read and code a quick hack in literally under 2 minutes ?
If you want to see one of the consistent leaderboard finishers solve the puzzles live, check out Jonathan Paulson's YouTube channel.
The latter, I think. Some people are into "competitive programming" - solving Advent of Code-style problems quickly - and that kind of practice, alongside knowing a language very well, leads to the crazy / scary sub-two minute times on the leaderboard.