27 lines
660 B
Python
27 lines
660 B
Python
# HumanEval/43
|
|
# Loki Mode Multi-Agent Solution
|
|
# Attempts: 1
|
|
# Passed: True
|
|
|
|
def pairs_sum_to_zero(l):
|
|
"""
|
|
pairs_sum_to_zero takes a list of integers as an input.
|
|
it returns True if there are two distinct elements in the list that
|
|
sum to zero, and False otherwise.
|
|
>>> pairs_sum_to_zero([1, 3, 5, 0])
|
|
False
|
|
>>> pairs_sum_to_zero([1, 3, -2, 1])
|
|
False
|
|
>>> pairs_sum_to_zero([1, 2, 3, 7])
|
|
False
|
|
>>> pairs_sum_to_zero([2, 4, -5, 3, 5, 7])
|
|
True
|
|
>>> pairs_sum_to_zero([1])
|
|
False
|
|
"""
|
|
seen = set()
|
|
for num in l:
|
|
if -num in seen:
|
|
return True
|
|
seen.add(num)
|
|
return False |