How many ways can you construct a list from the numbers so that all sums of adjacent pairs are distinct and so that the first number is ?
You may assume that and that . The algorithm should be efficient in all these cases.
In a file oddlist.py
, implement a function count
that returns the desired count.
def count(n, x): # TODO if __name__ == "__main__": print(count(1, 1)) # 1 print(count(4, 2)) # 4 print(count(8, 5)) # 830
Explanation: When and , the answer is , because the lists are , , and .