In this Kata, you will be given directions and your task will be to find your way back. 
```Perl
solve(["Begin on Road A","Right on Road B","Right on Road C","Left on Road D"]) = ['Begin on Road D', 'Right on Road C', 'Left on Road B', 'Left on Road A']
solve(['Begin on Lua Pkwy', 'Right on Sixth Alley', 'Right on 1st Cr']) =  ['Begin on 1st Cr', 'Left on Sixth Alley', 'Left on Lua Pkwy']
```

More examples in test cases. 

Good luck!

Please also try [Simple remove duplicates](https://www.codewars.com/kata/5ba38ba180824a86850000f7)

Difficulty: introductory

Starter code:

def solve(arr):
	

Solutions:
DIRS = {'Left': 'Right', 'Right': 'Left'}

def solve(arr):
    lst,prevDir = [], 'Begin'
    for cmd in arr[::-1]:
        d, r    = cmd.split(' on ')
        follow  = DIRS.get(prevDir, prevDir)
        prevDir = d
        lst.append(f'{follow} on {r}')
    return lst

def solve(arr):
    go_moves, go_places = list(zip(*(s.split(" ", 1) for s in arr)))
    back_moves = ["Begin"] + ["Right" if s == "Left" else "Left" for s in go_moves[:0:-1]]
    return [" ".join(z) for z in zip(back_moves, go_places[::-1])]


def solve(arr):
    lst,prevDir = [],None
    for cmd in arr[::-1]:
        d,r = cmd.split(' on ')
        if not lst: lst.append(f'Begin on {r}')
        else:       lst.append(f'{"Left" if prevDir == "Right" else "Right"} on {r}')
        prevDir = d
    return lst

from collections import deque

def solve(arr):
    flip = {'Left': 'Right', 'Right': 'Left'}
    
    # Build the prefixes
    directions = deque([
        flip.get(s, s) 
        for s in [s.split()[0] for s in arr]
    ])
    directions.reverse()
    directions.rotate(1)
    
    # Get the rest of the directions    
    streets = [' '.join(s.split()[1:]) for s in arr][::-1]
    
    # Zip and concatenate each pair 
    return [f'{direction} {street}' for direction, street in zip(directions, streets)]

def solve(arr):
    route = [road.split() for road in arr]
    l, re= len(arr), []    
    dir = {'Left': 'Right', 'Right': 'Left', 'Begin': 'Begin'}
    for i in range(l):
        re.insert(0, ' '.join([dir[route[(i+1)%l][0]]] + route[i][1:]))
    return re

def solve(directions):
    positions, turns = [], []
    for d in directions[::-1]:
        t, p = d.split(' on ')
        turns.append('Right' if t == 'Left' else 'Left')
        positions.append(p)
    result = [f'{t} on {p}' for t, p in zip(turns, positions[1:])]
    return [f'Begin on {positions[0]}'] + result

def solve(arr):
    
    rev = list(reversed(arr))
    go = []
    direction = 'Begin'
    
    for i in rev:
        nextdirection = i.split(' ')[0]
        go.append(i.replace(nextdirection, direction))
        if nextdirection == 'Left':
            direction = 'Right'
        else:
            direction = 'Left'
            
    return go
        


def solve(a):
    ans,last = [],len(a)-1
    for i,x in enumerate(a):
        s = 'Begin' if i == last else 'Right' if a[i+1][0] == 'L' else 'Left'
        ans.insert(0,s + x[x.index(' '):])
    return ans

solve = lambda arr: list(reversed([{'Right': 'Left', 'Left': 'Right'}[arr[i + 1].split(' ')[0]] + ' ' + ' '.join(arr[i].split(' ')[1:]) if i < len(arr)-1 else 'Begin ' + ' '.join(arr[i].split(' ')[1:]) for i in range(len(arr))]))


def solve(arr):
    t1,t2=[],[]
    for i in arr:
        t1.append(' '.join(i.split(' ')[:2]))
        t2.append(' '.join(i.split(' ')[2:]))
    print(t1,t2)
    t2 = t2[::-1]
    t1 = t1[::-1]
    for i in range(len(t1)):
        if "Right" in t1[i]:
            t1[i] = t1[i].replace('Right','Left')
        elif "Left" in t1[i]:
            t1[i] = t1[i].replace('Left','Right')
    t1 = [t1[-1]]+t1[:-1]
    return ["%s %s"%(e,f) for e,f in zip(t1,t2)]