Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def part_2(target, numbers):
- for idx, _ in enumerate(numbers): # Find the 3 numbers that compliment to the target
- next_idx = idx + 1
- last_idx = len(numbers) - 1
- while last_idx >= next_idx:
- if numbers[idx] + numbers[next_idx] + numbers[last_idx] == target:
- print("Answer found")
- if numbers[idx] + numbers[next_idx] + numbers[last_idx] > target:
- last_idx-=1
- else:
- next_idx+=1
RAW Paste Data