Yesterday, a lot of you finished quickly and were looking for more to keep you occupied on a Saturday. All of the golfed one-liners were really fu...
For further actions, you may consider blocking this person and/or reporting abuse
OK, today seemed pretty straightforward, although it took me to reach task 2 to have the insight that it was union and then intersect... oh well it is a Sunday :-)
Anyway Haskell was a nice fit and simply used set operations on lists to keep with my somewhat weak goal of using lists.
I've created a step-by-step tutorial (TypeScript) again:
[Advent of Code 2020] Day 6 Step-by-Step Tutorial (TypeScript)
Kai ・ Dec 6 ・ 6 min read
and I did something with bits, just for fun:
Clever solution. I had an instinct that I could use binary to solve Day5, although couldn't quite flesh out a working solution (ended up solving it in a different way). It didn't even dawn on me that you could use binary for this challenge, although it seems obvious now. 👍
Python one-liners, thanks to set theory and list comprehension, and map
Part 1:
Part 2:
I try to explain this more fully at dev.to/meseta/advent-of-code-2020-...
Python impl today. Prob not great python but works.
Tomorrow will try something like prolog?!
Failing that, maybe Haskell.
Ruby, part 2:
Rust!
Ugh, made it too late for this day (but I had it done in time for the problem, honest!).
Used HashSet to my benefit here, as I could apply set theory to the problem and get it done easily.
As always, in Github.
COBOL
2 Solutions again.
Go:
And tweet-sized PHP:
I decided to do this year in Haskell. Perhaps if it gets too crazy, I'll revert to what I know better, but until now it's been fun.
I might start a library with the
groups
andaddAll
functions, seems I'm going to use them for every puzzle...I thought the most obvious way to do this would be to intersect a bunch of HashSets, but seemed to be more short & sweet to just check that every character in the first line was contained in every other line 🤷
Part 1
Part 2
PlaneGroup
Only took a few minutes today; here is what I got in Ruby:
I spent a long time trying to get a regex to work for part 2, but I have given up for the time being. Got a short couple of answers for this:
Haskell:
Python. A bit less elegant than some of the other python versions already posted but the same idea using set theory
Javascript answer, Part 1 and 2 in one script, change the
part2
boolean to false if you want a part 1 answer.Looking at other people's responses, mine feels very inefficient :(
JavaScript - I did it in COBOL first, but still wanted to practice reduce a bit.
Yesterday I had no time to post my solution in Elixir, but there is!
I've solved this using Clojure for the sake of. It seems to be the shortest one so far.
A little late to the party, but I got it done before bed time 😁
Day6.h:
Day6.c:
Re yesterday: actually my solution was in D, but I don't see it listed in the table.
OK cool, I wasn't 100% sure. I'll update that.
Yeah, I should've mentioned that in the original. Those C-like languages look pretty much all the same if you don't know some particular details.
Haha! Yeah, I was thinking, "I'm pretty sure that's not Go, but maybe it's C#? Or C++?" I just thought of inspecting the HTML classes yesterday after running into a similar issue. 😂
Ruby, part 1:
Here is my walkthrough for day 6 in JavaScript:
Source code: github.com/tpatel/advent-of-code-2...