Skip to content

Instantly share code, notes, and snippets.

@loudambiance
Created December 16, 2021 05:11
Show Gist options
  • Save loudambiance/ceb185fae2abb1e7b2f4270ffed88ead to your computer and use it in GitHub Desktop.
Save loudambiance/ceb185fae2abb1e7b2f4270ffed88ead to your computer and use it in GitHub Desktop.
with open('task3a.txt') as f:
lines = []
for ele in f:
lines.append(list(ele.strip('\n\r ')))
gamma = ''.join([ max(x, key=x.count) for x in zip(*lines) ])
epsilon = ''.join('1' if x == '0' else '0' for x in gamma)
power = int(gamma, 2) * int(epsilon,2)
print(power)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment