Created
December 9, 2020 06:41
-
-
Save kung-foo/e752d3a14724d615c2679c7a02592975 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python3 | |
import os | |
import sys | |
import random | |
from itertools import combinations | |
src = open("input.txt", "r").readlines() | |
src2 = """35 | |
20 | |
15 | |
25 | |
47 | |
40 | |
62 | |
55 | |
65 | |
95 | |
102 | |
117 | |
150 | |
182 | |
127 | |
219 | |
299 | |
277 | |
309 | |
576""".splitlines() | |
src = [int(r.strip()) for r in src] | |
pos = 0 | |
size = 25 | |
target = None | |
while pos + size < len(src): | |
block = src[pos:pos+size] | |
target = src[pos+size] | |
# print(target, block) | |
# if target == 11586: | |
# print(target, block) | |
match = False | |
for pair in combinations(block, 2): | |
if pair[0] + pair[1] == target: | |
match = True | |
continue | |
if not match: | |
print(target, pos) | |
break | |
pos += 1 | |
for offset in range(0, pos): | |
for length in range(1, 50): | |
block = src[offset:offset+length] | |
if sum(block) == target: | |
block = sorted(block) | |
print(offset, length, block, block[0], block[-1], block[0] + block[-1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment