bourb0n

Untitled

Dec 1st, 2020
571
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def part_2(target, numbers):
  2.   for idx, _ in enumerate(numbers): # Find the 3 numbers that compliment to the target
  3.     next_idx = idx + 1
  4.     last_idx = len(numbers) - 1
  5.  
  6.     while last_idx >= next_idx:
  7.       if numbers[idx] + numbers[next_idx] + numbers[last_idx] == target:
  8.         print("Answer found")
  9.  
  10.       if numbers[idx] + numbers[next_idx] + numbers[last_idx] > target:
  11.         last_idx-=1
  12.       else:
  13.         next_idx+=1
  14.  
RAW Paste Data