Skip to content

Instantly share code, notes, and snippets.

@rtzll
Created June 19, 2016 06:58
Show Gist options
  • Save rtzll/b35692a947faa08694fcb4bfe630adaf to your computer and use it in GitHub Desktop.
Save rtzll/b35692a947faa08694fcb4bfe630adaf to your computer and use it in GitHub Desktop.
Ex Machina Easter egg - Book recommendation
# BlueBook code decryption
import sys
def sieve(n):
# Compute primes using sieve of Eratosthenes
x = [1]*n
x[1] = 0
for i in range(2, n/2):
j = 2*i
while j < n:
x[j] = 0
j = j+i
return x
def prime(n, x):
# Find nth prime
i = 1
j = 1
while j <= n:
if x[i] == 1:
j = j+1
i = i+1
return i-1
# Compute BlueBook unlock code
x = sieve(10000)
code = [1206,301,384,5]
key = [1,1,2,2]
sys.stdout.write("".join(chr(i) for i in [73,83,66,78,32,61,32]))
for i in range(0, 4):
sys.stdout.write(str(prime(code[i],x)-key[i]))
print
@rtzll
Copy link
Author

rtzll commented Jun 19, 2016

The result is ISBN = 9780199226559

Here the amazon link: https://www.amazon.com/Embodiment-inner-life-Cognition-Consciousness/dp/0199226555/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment