Create a list that contains the numbers and where each pair of consecutive numbers has a different sum. Any list satisfying the conditions is acceptable.
You may assume that is in the range .
In a file sumdiff.py
, implement a function create
that returns the required list.
def create(n): # TODO if __name__ == "__main__": print(create(6)) # [3, 1, 6, 2, 4, 5] print(create(10)) # [7, 10, 3, 1, 5, 4, 8, 6, 9, 2] print(create(15)) # [9, 4, 6, 14, 15, 13, 12, 11, 5, 2, 3, 8, 1, 7, 10]
Explanation: In the code template example , the sums of pairs are , , , and . Since all the sums are different, the solution is valid. For example the solution would not be valid, because and .