<jupyter_start><jupyter_text>**Deel 1**<jupyter_code>positie = [0,0] 
orientatie = 0 
graden = {
    'E' : [-360, 0, 360],
    'S' : [90, -270],
    'W' : [180, -180],
    'N' : [270, -90],
    }
def navigeer(p, o, g):
    for line in text:
        ch = line[0]
        u = int(line[1:])
        r = {
            'E' : [0, u],
            'S' : [1, -u],
            'W' : [0, -u],
            'N' : [1, u],
        } 
        if ch in list(r.keys()):
            p[r[ch][0]] += r[ch][1]
        if ch == 'L':
            o -= u
            if o < -360:
                o += 360
        if ch == 'R':
            o += u
            if o > 360:
                o -= 360
        if ch == 'F':
            di = next((k for k, v in g.items() if o in v), None)
            p[r[di][0]] += r[di][1]  
    return(p)
locatie1 = navigeer(positie, orientatie, graden)
print(abs(locatie1[0]) + abs(locatie1[1]))<jupyter_output><empty_output><jupyter_text>**Deel 2**<jupyter_code>positie = [0,0] # positie schip
waypoint = [10,1] # positie waypoint  
def navigeer_waypoint(p, wp):
    for line in text:
        ch = line[0]
        u = int(line[1:])
        r = {
            'E' : [0, u],
            'S' : [1, -u],
            'W' : [0, -u],
            'N' : [1, u],
        } 
        d = {
            90 : [[-wp[1], wp[0]], [wp[1], -wp[0]]],
            180 : [[-wp[0], -wp[1]], [-wp[0], -wp[1]]],
            270 : [[wp[1], -wp[0]], [-wp[1], wp[0]]]
        }
        if ch in list(r.keys()):
            wp[r[ch][0]] += r[ch][1]
        if ch == 'L':
            wp = d[u][0]
        if ch == 'R':
            wp = d[u][1]
        if ch == 'F':
            p[0] += wp[0]*u 
            p[1] += wp[1]*u
    return(p)
locatie2 = navigeer_waypoint(positie, waypoint)
print(abs(locatie2[0]) + abs(locatie2[1]))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21791370835608956, 'fraction_numerical': 0.05406881485527035, 'mean_word_length': 1.4394141145139814, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '621314', 'license': 'Apache-2.0', 'n_tokens_mistral': 800, 'n_tokens_neox': 758, 'n_words': 171, 'path': 'Dag12.ipynb', 'repo_name': 'isepri/Adventofcode2020', 'size': '1831'}