Skip to content

Instantly share code, notes, and snippets.

@hansputera
Created January 29, 2025 00:24
Show Gist options
  • Save hansputera/38771753cb092f31ab5d7b1da40128f2 to your computer and use it in GitHub Desktop.
Save hansputera/38771753cb092f31ab5d7b1da40128f2 to your computer and use it in GitHub Desktop.
O(n+1) code
def howmuchtarget(rangenum: int, target: int):
results = []
for i in range(1, rangenum+1):
for n in range(1, rangenum+1):
c = i+n
if c % target == 0:
results.append((i, n))
return results
results = howmuchtarget(10, 7)
print(results) # [(1, 6), (2, 5), (3, 4), (4, 3), (4, 10), (5, 2), (5, 9), (6, 1), (6, 8), (7, 7), (8, 6), (9, 5), (10, 4)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment