Zero-pair access codes
Combinatorial Counting
How many six-digit sequences over digits 0,1,2,3,4 have a nonzero first digit, exactly two occurrences of 0, and no equal adjacent digits? Leading zeroes are not allowed.
Solve using mathematics, algorithms, or your own code offline. Submit only the final integer here—no program, expression, graph, or written proof.
Check your answer without signing in. Sign in to save your progress.
How to approach this problem
Use a state for the last digit, position and number of zeros used. Add only digits different from the last digit, and initialize with nonzero digits.
Worked example with different values
For alphabet {0,1,2}, the valid two-digit codes with exactly one zero are 10 and 20. The sequences 01 and 02 fail the leading-digit restriction.
Apply the same reasoning to the challenge. This example is a separate practice problem.
Learn the technique: Dynamic programming and grid paths