The cat wants to lay down on the table, but the problem is that we don't know where it is in the room!

You'll get in input:
 - the cat coordinates as a list of length 2, with the row on the map and the column on the map.
 - the map of the room as a list of lists where every element can be 0 if empty or 1 if is the table (there can be only one 1 in the room / lists will never be empty).

# Task:

You'll need to return the route to the table, beginning from the cat's starting coordinates, as a String. The route must be a sequence of letters U, D, R, L that means Up, Down, Right, Left. The order of the letters in the output isn't important.

# Outputs:

* The route for the cat to reach the table, as a string
* If there isn't a table in the room you must return "NoTable"
* if the cat is outside of the room you must return "NoCat" (this output has the precedence on the above one).
* If the cat is alredy on the table, you can return an empty String.

# Example: 

```
cat = [0,1]
room =[[0,0,0], [0,0,0], [0,0,1]]

The route will be "RDD", or "DRD" or "DDR"
```

Difficulty: introductory

Starter code:

def put_the_cat_on_the_table(cat, room):
	

Solutions:
def put_the_cat_on_the_table(cat, room):
    (cy, cx), h, w = cat, len(room), len(room[0])
    if not (0 <= cy < h and 0 <= cx < w):
        return "NoCat"
    ty, tx = next(((y, x) for y in range(h) for x in range(w) if room[y][x]), (-1, -1))
    if ty < 0:
        return "NoTable"
    ver, dy = "U" if ty < cy else "D", abs(ty - cy)
    hor, dx = "L" if tx < cx else "R", abs(tx - cx)
    return f"{hor * dx}{ver * dy}"


def put_the_cat_on_the_table(cat, room):
    try:
        ci, cj = cat
        if not (0 <= ci < len(room) and 0 <= cj < len(room[0])):
            return "NoCat"
        ti, tj = next((i, j) for i,row in enumerate(room) for j,x in enumerate(row) if x)
        return "{}{}".format("UD"[ti>ci]*abs(ti-ci), "LR"[tj>cj]*abs(tj-cj))
    except StopIteration:
        return "NoTable"

def put_the_cat_on_the_table(pos, c):
    if not (0<=pos[0]<len(c) and 0<=pos[1]<len(c[0])) : return "NoCat"
    find_one = next(([i, j.index(1)] for i, j in enumerate(c) if 1 in j),None)
    if not find_one : return "NoTable"
    f = ("D" if pos[0] < find_one[0] else "U") * abs(pos[0] - find_one[0])
    s = ("R" if pos[1] < find_one[1] else "L") * abs(pos[1] - find_one[1])
    return f + s

def put_the_cat_on_the_table(cat, room):
    if cat[0] < 0 or cat[0] >= len(room) or cat[1] < 0 or cat[1] >= len(room[0]):
        return "NoCat"
    tableCoord = [-1, -1]
    for row in range(len(room)):
        for col in range(len(room[row])):
            if room[row][col]==1:
                tableCoord[0] = row
                tableCoord[1] = col
    if tableCoord == [-1, -1]:
        return "NoTable"
    if cat == tableCoord:
        return ""
    move = [0, 0]
    move[0] = tableCoord[0] - cat[0]
    move[1] = tableCoord[1] - cat[1]
    
    retStr = ""
    while move != [0, 0]:
        if move[0] > 0:
            retStr += "D"
            move[0] -= 1
        if move[0] < 0:
            retStr += "U"
            move[0] += 1
        if move[1] > 0:
            retStr += "R"
            move[1] -= 1
        if move[1] < 0:
            retStr += "L"
            move[1] += 1
    return retStr

def put_the_cat_on_the_table(cat, room):
    nr, nc = len(room), len(room[0])
    cr, cc = cat
    if not (cr in range(nr) and cc in range(nc)):
        return 'NoCat'
    try:
        tr, tc = next((r, c) for r in range(nr) for c in range(nc) if room[r][c])
    except StopIteration:
        return 'NoTable'
    dr, dc = tr - cr, tc - cc
    return 'D' * dr + 'U' * -dr + 'R' * dc + 'L' * -dc

def put_the_cat_on_the_table(a, b):
    cx, cy = a
    if not (0 <= cx < len(b) and 0 <= cy < len(b[0])):
        return "NoCat"
    if not any(any(x) for x in b):
        return "NoTable"
    tx, ty = next((i, j) for i, x in enumerate(b) for j, y in enumerate(x) if y)
    return "L" * (cy - ty) + "R" * (ty - cy) + "U" * (cx - tx) + "D" * (tx - cx)

def put_the_cat_on_the_table(cat, room):
    ty,tx = next(((i,j) for i,row in enumerate(room) for j,v in enumerate(row) if v==1),('No','Table'))
    cy,cx = cat
    if cy<0 or cx<0 or cy+1>len(room) or cx+1>len(room[0]): return 'NoCat'
    if ty+tx == 'NoTable': return ty+tx   
    return ('U' if (ty-cy)<0 else 'D')*(abs(ty-cy)) + ('L' if (tx-cx)<0 else 'R')*(abs(tx-cx))

def put_the_cat_on_the_table(cat, room):
    if not (0 <= cat[0] < len(room) and 0 <= cat[1] < len(room[0])):
        return 'NoCat'
    t = ([(y, x) for y, row in enumerate(room) for x, col in enumerate(row) if col == 1] + [None])[0]
    if not t:
        return 'NoTable'
    h = 'L' * abs(t[1] - cat[1]) if t[1] - cat[1] < 0 else 'R' * (t[1] - cat[1])
    return h + ('U' * abs(t[0] - cat[0]) if t[0] - cat[0] < 0 else 'D' * (t[0] - cat[0]))

def put_the_cat_on_the_table(cat, room):
    if not (0 <= cat[0] < len(room) and 0 <= cat[1] < len(room[0])):
        return 'NoCat'
    aim = None
    for row, rows in enumerate(room):
        for col, place in enumerate(rows):
            if place == 1:
                aim = (row, col)
                break
    if not  aim:
        return 'NoTable'
    else:
        route = cat[0] - aim[0], cat[1] - aim[1]
    if cat == aim:
        return ''
    else:
        return ('U' * route[0] if route[0] >= 0 else 'D' * abs(route[0])) + (
            'L' * route[1] if route[1] >= 0 else 'R' * abs(route[1]))