Wednesday, June 30, 2010

The Answer, in Python

import string

def next_letter(index):
  letters = string.punctuation + string.ascii_lowercase + string.digits
  return letters[index]

def main():
  response = ""
  index = 0
  orders = "36,13,-9,-6,8,8,-4,-1,9,-18,-3,17,-10,11,-15,\
-23,21,12,-2,-30,18,22,-18,14,-4,-2,-8"
  orderArray = orders.split(',')
  for order in orderArray:
    index = index + int(order)
    response += next_letter(index)
  print (response)

if __name__ == "__main__":
  main()

7 comments:

thisismike said...

Online Evaluator:

codepad.org

Anonymous said...

I feeling not smart enough to do this. Just wait till Kaleb gets home!

unicorn girl said...

You've got to be kidding. Oh, this is Old Bob, not Unicorn Girl.

thisismike said...

Well, Unicorn Bob, I'm not sure what you think I'm kidding about ... of ... on... the. Too many prepositions.

We're very serious. Besides, you'll never know if you don't try.

luke&whit said...

I love it! I love it! I love it!

ol' Bob said...

Impressive. I don't get it, but it's impressive.

What was the question?

Luke said...

This Python stuff is the world's best kept secret.