function solution(numbers, hand) {
let lHand = '10' , rHand = '12';
return numbers.reduce((acc, el) => {
if(el == 0) {
el = 11;
};
const temp = el % 3;
if(temp == 0){
rHand = el;
acc += 'R';
}else if(temp == 1){
lHand = el;
acc += 'L';
}else{
const r_position = Math.abs(Math.ceil(el / 3) - Math.ceil(rHand / 3)) + (rHand % 3 == temp ? 0 : 1);
const l_position = Math.abs(Math.ceil(el / 3) - Math.ceil(lHand / 3)) + (lHand % 3 == temp ? 0 : 1);
if(r_position > l_position){
lHand = el;
acc += 'L';
}else if (r_position < l_position){
rHand = el;
acc += 'R';
}else if (r_position == l_position){
if(hand == 'right'){
rHand = el;
acc += 'R';
}else{
lHand = el;
acc += 'L';
}
}
}
return acc;
}, [])
}