-
• #77
I'll pretend to understand what that's doing.
It looks pretty though.
-
• #78
Meanwhile, I'm still on day 2, getting bogged down in pandas, trying to understand why I can't use an operator on an array (to be honest, I don;t even know if I'm using the right language to describe what I'm trying to do).
For some reason, I'm trying to avoid iterating through line by line, and hoping / expecting there's a way to do it with a vector operation (again - not sure if I'm using the right words to describe what I'm trying to do).
Still - I have now learned about lambdas
-
• #79
I've just caught up to day three...
I have to say, day three / part two took a long time to finish; I wasn't expecting or looking for integer overflow on the final multiplication and you don't get an exception by default for it in c#, which I don't think I knew.
In case anyone's doing c#, I don't think it's terribly different to a couple of earlier answers:
public int Answer(int r = 3, int d = 1) { var inputData = GetInputData().ToArray(); var returnValue = 0; var lengthOfRow = inputData[0].Length; var currenthPoz = 0; for (var currentvPoz = d; currentvPoz < inputData.Length; currentvPoz += d) { currenthPoz = (currenthPoz + r) % lengthOfRow; if (inputData[currentvPoz].ElementAt(currenthPoz) == '#') returnValue++; } return returnValue; }
-
• #80
Thank you for this! Really useful. I'm planning to carry Haskell on past the advent of code, I feel like it is not a quick language to get competent in!
Out of interest, in what capacity do you teach into Haskell?
-
• #81
Day 4 done with regex mainly.
https://gist.github.com/dmckennell/f8b44c1d6c15dbdff05480d2360b8c9e
...generates:
Part 1 took 0.085530307 seconds Part 2 took 0.050166096 seconds Part 1: 213 Part 2: 147
-
• #82
Day 4: There's no way I can do all that string parsing and validation with just a spreadsheet.
(the validation is incredibly weak for edge cases, the formulae close to unreadable, but it gave me a gold star first time)
-
• #83
More regex! Give me more, I need it.
-
• #84
Another case where 99% of the solution took as long as the last 1%, maybe I should have done all my checks with regexes. My code worked on the provided test passports but missed 1 invalid passport in my full set because I wasn't discarding unitless heights.
-
• #85
Doing it for the first time this year, fun so far. Definite productivity dip, but I figure it's good to do something a bit different.
Here's my day 4 part 2 in JS, that # in the eye colour hex caught me out for a bit.
https://gist.github.com/abrwn/eaf8acb7272c3ae1661d1faa35c0ca1a -
• #86
Day 4 was decent - I've been using FluentValidators a lot recently, so quite easy to use them here. Once you've got a passport object set up, you can write rules it's got to fulfil to be valid such as:
public class PassportDataValidator : AbstractValidator<PassportData> { public PassportDataValidator() { RuleFor(passport => passport.byr).InclusiveBetween(1920, 2002); RuleFor(passport => passport.iyr).InclusiveBetween(2010, 2020); } }
-
• #87
Stopped twatting about and finished day 2.
I really wanted this to work without iteration, but I was getting nowhere.
#!/usr/bin/python import timeit from pandas import read_table df = read_table('input_day2.txt', sep='-| |: ', header=None, engine='python') # Part 1 starttime = timeit.default_timer() my_check = 0 for index, row in df.iterrows(): my_check = my_check + (row[3].count(row[2]) >= row[0] and row[3].count(row[2]) <= row[1]) print("Part 1 - Number of valid passwords:", my_check) print("Time taken: ", timeit.default_timer() - starttime) # Part 2 starttime = timeit.default_timer() my_check = 0 for index, row in df.iterrows(): my_check = my_check + ((row[3][row[0]-1] == row[2]) is not (row[3][row[1]-1] == row[2])) print("Part 2 - Number of valid passwords:", my_check) print("Time taken: ", timeit.default_timer() - starttime)
:: tiswas@laptop2:/media/storage/Documents/Technical/Git/AoC2020 :: $ ./day2_password_check.py Part 1 - Number of valid passwords: 500 Time taken: 0.13249829085543752 Part 2 - Number of valid passwords: 313 Time taken: 0.1401983331888914
-
• #88
My java is on gitlab as georgebrisco. Day 4 seemed dull so hoping it gets built on.
Today though was a day that test driven development was built for
-
• #89
TIL about
endswith()
! -
• #90
Bah, had hoped for something meaty today but I guess Eric has learned from scaring people off with a really tough problem within the first week. (Hoping for tomorrow though.)
-
• #91
I've seen lots of solutions elsewhere (we have a Slack channel at work for it) that would accept lots of other invalid strings. endswith() or the equivalent was a common culprit, for example many would think the following were not invalid:-
hgt:172bcm
hgt:60zin
But Eric chose not put anything like that in.
-
• #92
Was also expecting something a little harder. Did waste a fair amount of time reading day 4 input. More coffee required.
https://gitlab.com/akflds/adventofcode/-/blob/master/2020/5.py
-
• #93
My slicing wouldn't have caught that either. Will redo with regex at some point.
-
• #94
I was surprised by how easy today was, started to think I might have chances of making it to the end. But it's likely to ramp up soon? We'll see how long I manage to hang on.
Today's solution is my neatest so far I think (even did a sanity check on the input with the regex stuff learned yesterday). Except for the function to go from binary string to int, couldn't get Python to parse with int(string, 2) and I found this function on StackOverflow whilst looking for a solution.
-
• #95
Mine is here https://gitlab.com/Georgebrisco/adventofcode2020
Yesterday's was a bit of a mish mash. Today's was quick. I could obviously optimize a bit but I expected a different part B.
Enjoying it, but dreading it getting difficult in the work week.
I don't primarily code for a living, so it is nice to be doing it every day. I am now a bit disappointed to have finished for the day.
We also have a slack channel about it. I find the chat here and there about it better than the doing
-
• #96
Here was my Day 5 in perl:-
https://gist.github.com/alexgreenbank/8f9f60abcd4fa6a140cb076264112f7e
-
• #97
Not sure if I can be bothered to fire up the laptop at the weekend...
-
• #98
That is very neat, clear code. I don't think I ever said that about perl before
-
• #99
Last year seemed harder, I never really got into the intcode stuff.
-
• #100
First year i've done it. Enjoying it a fair bit.
Yesterday's really showed the value in unit tests. Obviously had none, and caused me headache catching a couple of little errors in my regex.
Today was nice didn't take too long.
I was very lazy this morning, will need to rework if this ends up being the computer. Already realised splitting input on "\n\n" would have been better option.
Python: https://gitlab.com/akflds/adventofcode/-/blob/master/2020/4.py