In [47]:
#Part 1.1
import numpy as np
def get_position(direction,movement,x,y):
    
    dict_orientation = {'NL':'W','NR':'E','EL':'N','ER':'S','WL':'S','WR':'N','SL':'E','SR':'W'}
    next_orientation = dict_orientation[direction+movement[0]]
    movements = movement[1:len(movement)]
    if (next_orientation == "W" or next_orientation =="E"):
        if(next_orientation =="E"):
            x_new = x + int(movements)
        else:
            x_new = x - int(movements)
        y_new = y
    if (next_orientation == "S" or next_orientation =="N"):
        if(next_orientation =="N"):
            y_new = y + int(movements)
        else:
            y_new = y - int(movements)
        x_new = x
    return x_new,y_new,next_orientation

f = open("/Users/fran/adventofcode/2016/fran/file_input.txt")
for l in f: 
    l = l.rstrip()
    list_data = l.split(',')

x = 0
y = 0
orientation = 'N'
for val in list_data:
    val = val.replace(' ',"")
   
    x,y,orientation = get_position(orientation,val,x,y)
    
    
print (np.abs(x)+np.abs(y))


226

In [46]:
#Case 2 - pythonchallenge
def get_ascii(a):
    if(not(ord(a) >= 97 and ord(a) < 123)):
        return chr(ord(a))
    if(ord(a)+2 > 122):
        
        return chr(ord(a)+2-122+96)
    return chr(ord(a)+2)
strings = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj." 
strings= "string.maketrans()"
string_n = ""

for letter in strings:
    if(letter == " "):
        string_n = string_n + " "
    else:
        string_n = string_n + get_ascii(letter)
print (string_n)


uvtkpi.ocmgvtcpu()

In [45]:



---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-45-fbc475a15836> in <module>()
----> 1 from string import lowercase as cypher_in
      2 from string import maketrans
      3 # jvvr://yyy.ravjqpejcnngpig.eqo/re/fgh/ocr.jvon
      4 c1 = "http://www.pythonchallenge.com/pc/def/map.html"
      5 

ImportError: cannot import name 'lowercase'

In [ ]: