Skip to content

Instantly share code, notes, and snippets.

@SonOfLilit
Last active August 29, 2015 14:17
Show Gist options
  • Save SonOfLilit/5b814db2a4a72b109e5c to your computer and use it in GitHub Desktop.
Save SonOfLilit/5b814db2a4a72b109e5c to your computer and use it in GitHub Desktop.
All Gists
SonOfLilit
Edit
Delete
Star0
SonOfLilit / choose
Last active 30 minutes ago
Code
Revisions 3
Embed URL
HTTPS clone URL
You can clone with HTTPS or SSH.
Download Gist
choose Raw
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
def words(x):
result = []
i = 0
while x:
if x & 1:
result.append(i)
x >>= 1
i += 1
return result
def popcnt(x):
count = 0
while x:
count += x & 1
x >>= 1
return count
six_of_sixteen = [words(x) for x in range(1<<16) if popcnt(x) == 6]
assert len(six_of_sixteen) == 8008
for code in six_of_sixteen:
errors = set(range(1, 16))
for i, a in enumerate(code):
for b in code[i+1:]:
if a ^ b in errors:
errors.remove(a ^ b)
if not errors:
print "good"
break
Write Preview Parsed as Markdown Edit in fullscreen
Comment
Status API Blog About © 2015 GitHub, Inc. Terms Privacy Security Contact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment