-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEpsilon.py
More file actions
41 lines (36 loc) · 1.05 KB
/
Epsilon.py
File metadata and controls
41 lines (36 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
file = open("input.txt").read().strip()
lines = file.split("\n")
def decimate(string):
i = 1
count = 0
for char in reversed(string):
if char == "1":
count += i
i *= 2
return count
index = 0
def compare(first):
for i in range(0, 12):
if not first[i] == epsilon[i]:
return (i, first)
def remove(item):
return item[1:len(item)]
def first(item):
return item[index]
survivors = lines
while len(survivors) > 1:
firsts = list(map(first, survivors))
survivors = list(filter(lambda x: (x[index] == "0") == (firsts.count("0") > firsts.count('1')), survivors))
print(survivors)
index += 1
index = 0
gamma = survivors[0]
survivors = lines
while len(survivors) > 1:
firsts = list(map(first, survivors))
survivors = list(filter(lambda x: (x[index] == "0") != (firsts.count("0") > firsts.count('1')), survivors))
print(survivors)
index += 1
epsilon = survivors[0]
print(survivors)
print(decimate(epsilon) * decimate(gamma))