[Baypiggies] Python in the Movies | Decoding an ISBN?

Glen Jarvis glen at glenjarvis.com
Sat Oct 3 19:03:11 CEST 2015


I have been watching "Ex Machina" (http://www.imdb.com/title/tt0470752/).
[It's worth watching, by the way).

When I see a television program and/or movie that has "code," I always
pause and look. It's amazing how often a thin veneer of "code" is put up on
the screen as the actor hammer at the keyboard and the "code" just flows
down the page.

I admit, usually I do this exercise only for my family to groan because I
usually piss and moan how badly it is done. For example, Criminal Minds
once had an IP address similar to: 76.21.58.572. They even had the actors
read it in the dialogue.. Arghhh

"Ex Machina," at roughly index 1:09:37 has two "windows." One looks like C.
And, the second, the foreground window Python. It's not PEP8 compliant, has
bad spacing and doesn't win the efficiency award, but it's genuine code and
syntactically (but not semantically) correct :)  woot!

Here is the code below. What grabbed my interest is the "puzzle" included:
(An obfuscated way to write "ISBN = "):

sys.stdout.write("".join(chr(i) for i in (73,83,66,78,32,61,32)))

I expect the rest is an ISBN number. I'm curious what book was intended --
even if their "code" is broken.

I believe their "sieve of Eratosthenes" is incorrect. Reference video:
https://www.youtube.com/watch?v=V08g_lkKj6Q


Can anyone work out which ISBN number they were trying to reference?  1206
isn't prime. And, if I just assume they completely meant to take code[i] -
key[i] ignoring prime's completely, I get this `12053003823` -- which isn't
an ISBN reference.


Hmm... I'm still mildly curious...


# 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+1

    return x


def prime(n,x):

# Find the nth prime


    i = 1

    j = 1

    while j <= n:

        if x[i] == 1:

            j = j+1

        i = i+1

    return i-1



x = sieve(1000)


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20151003/e635170b/attachment.html>


More information about the Baypiggies mailing list