Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def weakSidon(sequence_length):
- """Finds a weak Sidon sequence (a sequence (a_i) of integers where a_i + a_j for i < j are all unique) of the necessary length."""
- sequence = [1]
- sums = []
- while len(sequence) < sequence_length:
- test_integer = sequence[-1] + 1
- test_sums = list(map(lambda x: test_integer + x, sequence))
- while any(x in list(test_sums) for x in sums):
- test_integer = test_integer + 1
- test_sums = list(map(lambda x: test_integer + x, sequence))
- sequence.append(test_integer)
- sums = sums + test_sums
- return sequence
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement