JSFiddle - React, Tailwind, and code Playground
HTML
<div id="line1">sxgsugcylgsfgznrktgp</div>
<div id="line2">cgsylsgnggkzurgptfxs</div>
<div id="moves">10:u 10:r 10:r 10:r 10:r 10:r 10:r 10:r 10:r 10:r 1:u 1:r 1:r 1:r 1:r 1:r 1:r 1:r 1:r 1:r 1:r 1:r 1:r 1:r 1:r 1:r 1:r 1:r 11:u 11:r 11:r 11:r 11:r 11:r 11:r 4:u 4:r 4:r 4:r 4:r 4:r 4:r 4:r 4:r 6:d 6:l 6:l 6:l 6:l 6:l 6:l 2:d 2:l 7:d 7:l 7:l 7:l 7:l 8:d 8:l 8:l 8:l 8:l 14:d 14:l 14:l 14:l 14:l 14:l 14:l 14:l 16:d 16:l 16:l 16:l 16:l 16:l 16:l 17:d 17:l 0:r 3:r 5:r 9:l 12:l 15:l 18:l 0:r 3:r 12:l 13:l 18:l 19:l 12:l 13:l 15:l 18:l 19:l 18:l 19:l 19:l 10:d 1:d 11:d 4:d 6:u 2:u 7:u 8:u 14:u 16:u 17:u</div>
CSS
#line1 {position:absolute;top:100px;}
#line2 {color:gray;position:absolute;top:250px;}
#moves {display:none;}
span {float:left;font-family:monospace;font-size:50px;position:absolute;width:50px;}
JavaScript
$('div:not(#moves)').each(function(){
c = $(this).text().split("");
$this = $(this);
$this.empty();
i = 0;
$.each(c, function(x, y) {
$this.append("<span>" + y + "</span>");
$('span').last().css({top: "0px", left: (i++ * 50) + "px"});
});
});
moves = $('#moves').text().split(" ");
function animateNextMove() {
m = moves.shift().split(":");
if (m[1] == 'l') o = {left:"-=50"};
if (m[1] == 'r') o = {left:"+=50"};
if (m[1] == 'u') o = {top:"-=50"};
if (m[1] == 'd') o = {top:"+=50"};
$('#line1 span:nth-child(' + ++m[0] + ')').animate(o, 125, 'linear', animateNextMove);
}
animateNextMove();