Our great sponsors
- ONLYOFFICE ONLYOFFICE Docs โ document collaboration in your environment
- CodiumAI - TestGPT | Generating meaningful tests for busy devs
- InfluxDB - Access the most powerful time series database as a service
- Sonar - Write Clean Python Code. Always.
-
TypeScript
-
In part1, though, vector was repeatably faster than circular_buffer. About 40us for vector and 70us or so for circular buffer. I expected circular buffer would out perform vector for this task.
-
ONLYOFFICE
ONLYOFFICE Docs โ document collaboration in your environment. Powerful document editing and collaboration in your app or environment. Ultimate security, API and 30+ ready connectors, SaaS or on-premises
-
Haskell
-
Only to find that I had wasted about 2 hours.. and had to re-implement everything, so the second time I did it quick and dirty instead. I kept the cards as strings with the deck being a single string... way, way simpler, even with the recursion, etc.
-
I added an AtomicInteger counter to each of our caching branches here in yours, and here in mine.
-
As I'm trying to optimize my solution (~3s) so I tried to check what makes your solution so fast, but it doesn't seem to work with my input. Example and part 1 works as expected, but part 2 with my input returns 8104 instead of 32665
-
Borrowed both ideas in my version :) On my input your version runs at 3ms, mine in 1.5ms, so it might be faster on some inputs (link). I initially started with something similar to yours but then figured why not use 512-bit ints, so that the notion of 'head' and 'tail' disappears as your head then stays at position 0 (so, e.g., to remove a card, you just right-shift the whole bigint). Also used a tiny bit of simd along the way.
-
CodiumAI
TestGPT | Generating meaningful tests for busy devs. Get non-trivial tests (and trivial, too!) suggested right inside your IDE, so you can code smart, create more value, and stay confident when you push.
-
github
-
CrabSharp (aka C#) Solution
-
part 1
-
Part 1 Part 2
-
Python 3, 905 on the part 2 leaderboard, which is a good position for me.
-
Python 3 (1345/540)
-
Part 1\ Part 2\ Since the script for part 2 is written in a recursive way, there is an extra step to get the final answer. The final answer can be easily obtained based on the non-empty deck.\ \ I was confused by the infinite loop prevention rule, but other than that, pretty simple puzzle.
-
code
-
part1
-
My input: https://github.com/xPaw/adventofcode-solutions/blob/d5b979f4a4fe45b5c14c290c69cb7c7d323310ec/2020/data/day22.txt
-
Python. Part 2 threw me for a loop (similar to many others here, it seems) but it's nice to be reminded to read the instructions carefully and not just rely on results from the sample inputs. Not terribly performant, but it runs quickly enough and the code is hopefully not too hard to read, so I'm quite happy with it.
-
part 1 part 2
-
Go/Golang
-
Python3 solution
-
RUST
-
Swift
-
Here are all my Python solutions so far in a Jupyter notebook, including today's one.
-
AdventOfCode
My Advent of Code solutions. I also upload videos of my solves: https://www.youtube.com/channel/UCuWLIm0l4sDpEe28t41WITA (by jonathanpaulson)
Python, placed 454/29. Code: https://github.com/jonathanpaulson/AdventOfCode/blob/master/2020/22.py. Video of me solving: https://youtu.be/iD4R7wSNrdw
-
Python, 138/16. code (permalink) & screen recording
-
C++ 324/394
-
advent-of-code-go
All 8 years of adventofcode.com solutions in Go/Golang; 2015 2016 2017 2018 2019 2020 2021 2022
Go Solution 537/997
-
C#
-
Python3 my solution. Takes a few seconds for part2.
-
Python3 simple solution.
-
AoC 2020 Day 22 - Kotlin. 2094/2452
-
Finished part 1 in 8 minutes, then proceeded to take over an hour to finish part two. Re-wrote the while loop maybe 5 times and got 5 different answers from my input, yet it would always pass the test cases
-
Golang
-
JavaScript 2291/1888
-
Python (1906/2343): https://github.com/UnicycleBloke/aoc2020/blob/main/day22/day22.py
-
https://gitlab.com/t-rkr/advent-of-code-2020/blob/master/day22/day22.pl
-
Java, 417/312. https://github.com/SizableShrimp/AdventOfCode2020/blob/master/src/main/java/me/sizableshrimp/adventofcode2020/days/Day22.java
-
adventOfCode
Solutions to the 'Advent of Code' (http://adventofcode.com) programming challenges in Elm (by jwoLondon)
Literate Elm
-
Haskell by a non-Haskell programmer ;)
-
aoc
๐ My solutions and walkthroughs for Advent of Code (https://adventofcode.com) and more related stuff.
Python 3 solution - Walkthrough
-
Java Fun day, I like space cards. I had minor Vietnam flashbacks to the spacecards of last year, but luckily it was nothing like that. Some takeaways:
-
Nodejs solution
-
JavaScript Solution day 22
-
Python 3 Solution
-
-
[Haskell] (Taken from my daily haskell reflections)
-
Python 3
-
Elixir
-
Clojure: https://github.com/mgrzeszczak/aoc-2020-clojure/blob/master/src/aoc_2020_clojure/day22.clj
-
Python 3 part1, part2
-
Part 1 & 2
-
python3: https://github.com/taddeus/advent-of-code/blob/master/2020/22_spacecards.py
-
Doesn't really matter. My original solution was just like yours, but because other people have decided to use *both* deques I've changed mine... and ... it did not work. It turned out to be a bug in hashbrown lol: https://github.com/rust-lang/hashbrown/issues/218
-
Python solution with deque
-
Scala
-
These are my solutions in Python and Rust, which run in 2.5s and 0.6s respectively. I am looking for some ways to improve the performance
-
Part 2 in Scala
-
Any comments are more than welcome! https://github.com/tpaschalis/aoc-2020/blob/main/day22/day22.exs
-
Code (see function - game_l2)
-
JavaScript/TypeScript Repo
-
Long day at work, the long time needed to solve all.
-
Advent-of-Code-2020
Advent of Code 2020 written in C++ using VS code with WSL integration. (by daniel-meilak)
GitHub solution to Part 2
-
Groovy
-
Julia
-
Advent-of-Code-2020
Solutions for the 2020 Advent of Code puzzles (using javascript and NodeJS) (by chaeron)
All of my 2020 puzzle solutions, including giving crabs a beating are here: https://github.com/chaeron/Advent-of-Code-2020
-
Python3 solution on GitHub. Just simulated it. I missed the part that says that when you start a sub-game, that you should only use the first p1card and p2card amount of cards from each deck in that sub-game. Without that, it would take a very long time for the game to end (as I found out after several hours of hoping lol).
-
advent-of-code
๐ This is my set of awesome solutions for the Advent of Code puzzles (by garciparedes)
Part 1: https://github.com/garciparedes/advent-of-code/blob/master/2020/22_crab_combat_part_1.rs
-
Ada
-
Here's my Python solution: https://github.com/Leftfish/Advent-of-Code-2020/blob/main/22/d22.py
-
advent-of-code-2020-jq
Solving Advent of Code with jq [Moved to: https://github.com/odnoletkov/advent-of-code-jq]
Part 2
-
Java - main & Part 2 game logic
-
Nothing clever about it :) I just tried to use this method of hashing (since it was about 3 times faster than what I was already doing), and noticed that it resulted in the wrong answer for part 2 for my input - so it definitely does matter for some cases!
-
Full source code here.
-
Rust solution:
-
Yeah, in most languages set is just a wrapper around hash. Pretty sure that's the case with Ruby - https://github.com/ruby/ruby/blob/master/lib/set.rb
-
Kept it fairly simple in Python. Runs in half a second for both parts together.
-
A Rust solution which would be really easy to adopt to multiple players. It takes 70 ms for both parts.
-
Advent_of_Code
These are my solutions to the Advent of Code puzzles. These are some of my first Python scripts, so please manage your expectations. :^) (by Nomen-Heroum)
Mine went down from 20062 to 16881 recursive calls, here's my code (also Python 3). Just add a global CALLS before line 7 and global CALLS; CALLS += 1 before line 17 in the if block to count the function calls.
-
Code Repository: https://github.com/haskelling/aoc2020
-
Rust, with a pretty straightforward approach.
-
InfluxDB
Access the most powerful time series database as a service. Ingest, store, & analyze all types of time series data in a fully-managed, purpose-built database. Keep data forever with low-cost storage and superior data compression.