[2020, Day 22, Part 2] Is there a way to speed up the state checking?

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/adventofcode

Our great sponsors
  • SonarLint - Deliver Cleaner and Safer Code - Right in Your IDE of Choice!
  • Scout APM - Less time debugging, more time building
  • SaaSHub - Software Alternatives and Reviews
  • AdventOfCode2020

    Solutions to all 25 AoC 2020 problems in Rust :christmas_tree: With relatively high global leaderboard placements!

    A solution that will work with very high probability (which I used here) is to store a hashset of hashes, HashSet. E.g you compute a hash for the two queues and see if that hash has already been seen. There is a very, very, small probability of a hash collision, but in practice this works.

  • advent-of-code-2020

    Advent of code 2020 using Golang (by CodingNagger)

    Personally, I had a map with string keys and boolean values unique to each game. Upon starting a new round, I would compute the state under string form, something like "1,2,3|8,9,7" where 1,2,3 are the cards for player 1 and 8,9,7 the cards from player 2. If the map contains that key I end the game with a player 1 win if not I add a new entry. There you get a complexity of O(1) to lookup values. My code is there: https://github.com/CodingNagger/advent-of-code-2020/blob/master/pkg/days/day22/computer.go

  • SonarLint

    Deliver Cleaner and Safer Code - Right in Your IDE of Choice!. SonarLint is a free and open source IDE extension that identifies and catches bugs and vulnerabilities as you code, directly in the IDE. Install from your favorite IDE marketplace today.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts