Question: Write a function happy_sequences(first, rest) that gets two arguments. The fist argument is the number s_0 (i.e. the start of the sequences). The second arument
Write a function happy_sequences(first, rest) that gets two arguments. The fist argument is the number s_0 (i.e. the start of the sequences). The second arument is a list of integers. The function should return the list of all happy sequences that start with the integer first and contain all elements from the set rest (in any order). Each possible sequence should appear in the list exactly once.
Example:
>>> happy_sequences(3, [5, 10, 55, 2, 2, 66])
[[3, 66, 55, 5, 10, 2, 2], [3, 66, 2, 2, 10, 5, 55], [3, 66, 2, 2, 10, 55, 5]]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
