Go: package main

import (
	"bufio"
	"os"
	"strings"
	"strconv"
	"fmt"
)

var points [5][5][4]bool

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for i := 0; i < 9; i++ {
		y := i/2
		if i%2 == 0 {
			scanner.Scan()
			info := strings.Split(scanner.Text(), "")
			for k := range info {
				e, _ := strconv.Atoi(info[k])
				if e != 0 {
					points[y][k][1], points[y][k+1][3] = true, true
				}
			}
		} else {
			scanner.Scan()
			info := strings.Split(scanner.Text(), "")
			for k := range info {
				e, _ := strconv.Atoi(info[k])
				if e != 0 {
					points[y][k][2], points[y+1][k][0] = true, true
				}
			}
		}
	}
	x := 1
	y := 0
	dir := 1
	dx := []int{0, 1, 0, -1}
	dy := []int{-1, 0, 1, 0}
	ds := "URDL"
	fmt.Printf("%s", string(ds[dir]))
	for !(x == 0 && y == 0) {
		if points[y][x][(dir+3)%4] {
			dir = (dir+3)%4
		} else if points[y][x][dir] {

		} else if points[y][x][(dir+1)%4] {
			dir = (dir+1)%4
		} else {
			dir = (dir+2)%4
		}
		x += dx[dir]
		y += dy[dir]
		fmt.Printf("%s", string(ds[dir]))
	}
	fmt.Println()
}

Python: #!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def make_destination(wx, wy):
    data = [[] for _ in range(5)]

    x1 = wx[0]
    y1 = wy[0]
    append = data[0].append
    append(('R' if x1[0] == '1' else '.') +
           ('D' if y1[0] == '1' else '.') + '..')
    for i in range(3):
        append(('R' if x1[i+1] == '1' else '.') +
               ('D' if y1[i+1] == '1' else '.') +
               ('L' if x1[i] == '1' else '.') + '.')
    append('.' + ('D' if y1[4] == '1' else '.') +
           ('L' if x1[3] == '1' else '.') + '.')

    for j in range(1, 4):
        y0 = y1
        x1 = wx[j]
        y1 = wy[j]
        append = data[j].append
        append(('R' if x1[0] == '1' else '.') +
               ('D' if y1[0] == '1' else '.') + '.' +
               ('U' if y0[0] == '1' else '.'))
        for i in range(3):
            append(('R' if x1[i+1] == '1' else '.') +
                   ('D' if y1[i+1] == '1' else '.') +
                   ('L' if x1[i] == '1' else '.') +
                   ('U' if y0[i+1] == '1' else '.'))
        append('.' + ('D' if y1[4] == '1' else '.') +
               ('L' if x1[3] == '1' else '.') +
               ('U' if y0[4] == '1' else '.'))

    y0 = y1
    x1 = wx[4]
    append = data[4].append
    append(('R' if x1[0] == '1' else '.') + '..' +
           ('U' if y0[0] == '1' else '.'))
    for i in range(3):
        append(('R' if x1[i+1] == '1' else '.') + '.' +
               ('L' if x1[i] == '1' else '.') +
               ('U' if y0[i+1] == '1' else '.'))
    append('..' + ('L' if x1[3] == '1' else '.') +
           ('U' if y0[4] == '1' else '.'))

    return data


def walk(data):
    destination = {'R': (1, 0), 'D': (0, 1), 'L': (-1, 0), 'U': (0, -1)}
    permutation = {'R': (3, 0, 1, 2), 'D': (0, 1, 2, 3),
                   'L': (1, 2, 3, 0), 'U': (2, 3, 0, 1)}

    print('R', end='')

    x = 1
    y = 0
    move = 'R'

    while x != 0 or y != 0:
        ways = data[y][x]
        for per in permutation[move]:
            m = ways[per]
            dest = destination.get(m)
            if dest is not None:
                break
        x += dest[0]
        y += dest[1]
        move = m
        print(move, end='')
    print()


def main():
    wall = stdin.read().split()
    walk(make_destination(wall[::2], wall[1::2]))
    exit(0)


main()

Python: grid = []
for i in range(9):
    grid += [input()]

position = [0, 0]
direction = 'R'
path = ''
while True:
    print(direction)
    if direction == 'R':
        path += direction
        position[1] += 1
        if position[0] > 0 and grid[position[0] - 1][position[1]] == '1':
            direction = 'U'
        elif position[1] < 4 and grid[position[0]][position[1]] == '1':
            direction = 'R'
        elif position[0] < 8 and grid[position[0] + 1][position[1]] == '1':
            direction = 'D'
        else:
            direction = 'L'
    elif direction == 'L':
        path += direction
        position[1] -= 1
        if position[0] < 8 and grid[position[0] + 1][position[1]] == '1':
            direction = 'D'
        elif position[1] > 0 and grid[position[0]][position[1] - 1] == '1':
            direction = 'L'
        elif position[0] > 0 and grid[position[0] - 1][position[1]] == '1':
            direction = 'U'
        else:
            if position[0] == position[1] == 0:
                break
            direction = 'R'
    elif direction == 'D':
        path += direction
        position[0] += 2
        if position[1] < 4 and grid[position[0]][position[1]] == '1':
            direction = 'R'
        elif position[0] < 8 and grid[position[0] + 1][position[1]] == '1':
            direction = 'D'
        elif position[1] > 0 and grid[position[0]][position[1] - 1] == '1':
            direction = 'L'
        else:
            direction = 'U'
    else:
        path += direction
        position[0] -= 2
        if position[1] > 0 and grid[position[0]][position[1] - 1] == '1':
            print('hello')
            direction = 'L'
        elif position[0] > 0 and grid[position[0] - 1][position[1]] == '1':
            direction = 'U'
        elif position[1] < 4 and grid[position[0]][position[1]] == '1':
            direction = 'R'
        else:
            direction = 'D'
print(path)

Python: # Aizu Problem 0037: Path on a Grid
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

DIRS = ['R', 'D', 'L', 'U']
DX = [0, 1, 0, -1]
DY = [1, 0, -1, 0]

board = [[[False for _ in range(4)] for __ in range(6)] for ___ in range(6)]
for i in range(9):
    l = 4 + i % 2
    walls = input().strip()
    for j in range(4 + i % 2):
        n = int(walls[j])
        if n == 1:
            if i % 2 == 0:
                board[i//2][j+1][1] = True
                board[i//2+1][j+1][3] = True
            else:
                board[i//2+1][j][0] = True
                board[i//2+1][j+1][2] = True
    
out = ""
direc = 0
nx, ny = 0, 1
while True:
    if (nx == 1 and ny == 0 and direc == 2) or \
       (nx == 0 and ny == 0 and direc == 2):
        break
    x = nx + DX[direc]
    y = ny + DY[direc]
    if not board[nx][ny][(direc+1)%4]:
        direc = (direc + 1) % 4
        nx += DX[direc]
        ny += DY[direc]
    elif board[nx][ny][direc]:
        out += DIRS[direc]
        direc = (direc - 1 + 4) % 4
    else:
        out += DIRS[direc]
        nx = x
        ny = y
print(out)

Python: import sys
n = [input() for i in range(9)]
path = [[0 for i in range(5)] for j in range(5)]

for i, v in enumerate([a[1] for a in enumerate(n) if a[0] % 2 == 0]):
    for j in range(4):
        if v[j] == '1':
            path[i][j] += 1
            path[i][j+1] += 2


for i, v in enumerate([a[1] for a in enumerate(n) if a[0] % 2 != 0]):
    for j in range(5):
        if v[j] == '1':
            path[i][j] += 4
            path[i+1][j] += 8

dur = {'R':(1, 0, 1),
       'L':(2, 0, -1),
       'U':(8, -1, 0),
       'D':(4, 1, 0)}

dur_next = {'R':('U','R','D'),
            'L':('D','L','U'),
            'U':('L','U','R'),
            'D':('R','D','L')}
def walk():
    global cx, cy
    cx = dur[d][2] + cx
    cy = dur[d][1] + cy

def next_D():
    global cx,cy,d,dur
    for nd in dur_next[d]:
        if path[cy][cx] & dur[nd][0]:
            d = nd
            break

cx = cy = 0
d = 'R'
log = []

while 1:
    log.append(d)
    walk()
    if cx == cy == 0:
        break

    next_D()

print(''.join(log))