Last active
March 26, 2025 10:12
-
-
Save fhuszar/9027c1ba8d3d88eeebe17fd86f13fd63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
answer = True | |
maxint = 1000 | |
numrandom = 10000 | |
books = list(set([random.randint(1, maxint) for _ in range(numrandom)])) | |
if answer: | |
#a random set of integers will be a positive example with a very high probability. | |
selected_books = books | |
else: | |
selected_books = [] | |
sums = set() | |
for i, book in enumerate(books): | |
violation = False | |
for book2 in selected_books: | |
if book+book2 in sums: | |
violation = True | |
if violation: | |
continue | |
else: | |
for book2 in selected_books: | |
sums.add(book + book2) | |
selected_books.append(book) | |
print(' '.join([str(i) for i in selected_books])) | |
sums = set() | |
found = False | |
for i in range(len(selected_books)): | |
for j in range(i+1, len(selected_books)): | |
if (selected_books[i] + selected_books[j]) in sums: | |
found=True | |
else: | |
sums.add(selected_books[i] + selected_books[j]) | |
if found: | |
print('YES') | |
else: | |
print('NO') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment