Or named "command window".
I mean "q and colon" ( q: ).
Not "colon and q" means quit vim ( :q ).
| defmodule Day23 do | |
| def p2 do | |
| i = "389547612" | |
| cups = String.split(i, "", trim: true) |> Enum.map(&String.to_integer/1) | |
| start = hd(cups) | |
| max = 1_000_000 | |
| steps = 10_000_000 | |
| mem = :atomics.new(max, []) | |
| Enum.each(Enum.zip(cups, tl(cups) ++ [10]), fn {i, next} -> :atomics.put(mem, i, next) end) | |
| Enum.each(10..max, &:atomics.put(mem, &1, &1 + 1)) |