You will compute derangement numbers and Catalan numbers from their recurrences, and count the orders with exactly items in place.
The idea. with and . The Catalan numbers follow with . Exactly items in place: .
Your tasks.
derangements(n). Build the list d = [1, 0] and extend it with the recurrence.catalan(n). Build the list c = [1] and extend it with the sum.exactly_fixed(n, k). Use comb(n, k) and derangements(n - k).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…