Approach
Written by Isaiah Iliffe from CSESoc Education
A very short solution involves keeping track of , the number Joseph's finger is currently over, initially 1, and treating each character as follows:
L: decrement by 1.R: increment by 1.U: decrement by 3.D: increment by 3.P: print the digit .
Alternatively, a 2D array representing the keypad will do the trick.