The TransCompilator

Solved LeetCode program · 849 of 1,000

#1138 · Alphabet Board Path

Medium String chunk-17.md

Original English source

The target is "leet". The moves is an empty list of text. The line is 0. The column is 0. The last is the last position of target.
For every spot from 0 to last.
The symbol is character spot of target. The code is symbol minus character 0 of "a". The wantline is code divided by 5. The wantcolumn is code modulo 5. Repeat while line is less than wantline, Place "D" into moves, Add 1 to line. Repeat while line is more than wantline, Place "U" into moves, Subtract 1 from line. Repeat while column is less than wantcolumn, Place "R" into moves, Add 1 to column. Repeat while column is more than wantcolumn, Place "L" into moves, Subtract 1 from column. Place "!" into moves.

The path is join moves with "". Show path.

Open in Playground Browse all 1,000 problems

Expected stdout

DDR!UURRR!!DDD!