1, 2, …, faces was rolled several times in a row, and the results are stored in rolls in the order of the throws.
A series is any sequence of face values. A series *occurs* in rolls if it can be obtained from rolls by crossing out some throws (the rest keep their order).
Find the length of the shortest series that does not occur in rolls.rolls=[2, 1, 1, 2, 2], faces=2 → 3
Every face came up, and all pairs [1, 1], [1, 2], [2, 1], [2, 2] occur too. The series [1, 2, 1] does not: every 2 that follows a 1 comes at the very end, with no 1 after it.
rolls=[3, 1, 3, 3], faces=3 → 1
A 2 never came up, so even [2] cannot be found.
rolls=[1, 1, 1], faces=1 → 4
The die has a single face: one, two and three 1s can be found, but not four.
rolls=[2, 1, 1, 2, 2], faces=2
3
Run checks the first 3 tests in your browser. Submit checks all 100 tests on the server, hidden ones included.