You will write three functions. Two count by a recurrence, and one counts by listing every case, so the checker can compare them.
The idea. The Tower of Hanoi needs moves with . The staircase count is with and . Strings of and with no two s together can be counted by trying every string.
Your tasks.
hanoi(n). Use the recurrence, calling hanoi(n - 1).stairs(n). Work forward in a loop with two variables.no_two_ones(n). Loop over product("01", repeat=n) and count the strings that do not contain "11".Run your code once to unlock the worked solution.
Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…