Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
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.
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
Related posts
- I cannot be the one that thinks this: notice the gaps between each problem, does this mean we'll descend the islands later on?
- [2023 day 3 and 4] Day 4 is quite a bit higher than day 3. Do you think we will be jumping around like 2020, or will there just be a gap?
- Broken days order in 2020 calendar?
- Aoe2 datasets
- What is a good way to learn .net?