static void Part1(Cups cups) { for (int i = 0; i < 100; ++i) { cups.Move(); } // zero based indexing Cup one = cups.Find(0); Console.WriteLine("Part 1: {0}", string.Join("", one.Labels().Select(label => label + 1).Skip(1))); }
public void Move() { Cup pickup = _current.Pickup(); HashSet <int> pickupLabels = new(pickup.Labels()); int destLabel = (_current.Label + _cups.Count - 1) % _cups.Count; while (pickupLabels.Contains(destLabel)) { destLabel = (destLabel + _cups.Count - 1) % _cups.Count; } _cups[destLabel].Place(pickup); _current = _current.Next; }