$( document ).ready(function() {
  var firstNumStr = '';
  var secondNumStr = '';
  var thirdNumStr = '';
  var whichNum = 1;
  
  var feet = 0;
  var shouldSum = false;
  var content = $('#lol').text().split('');
  
  for(var i = 0; i < content.length;++i) {
    if($.isNumeric(content[i])) {
      if(whichNum == 1) {
        firstNumStr += content[i];
      } else if(whichNum == 2) {
        secondNumStr += content[i];
      } else if(whichNum == 3) {
        thirdNumStr += content[i];
        if(i == content.length - 1)
          shouldSum = true;
      }
    } else if(content[i] == 'x') {
      whichNum++;
    } else {
      shouldSum = true; 
    }
    
    if(shouldSum) {
      
      var firstNum = parseInt(firstNumStr);
      var secondNum = parseInt(secondNumStr);
      var thirdNum = parseInt(thirdNumStr);
      
      var orderedNums = [firstNum, secondNum, thirdNum].sort(sortNumber);
      feet += (2 * orderedNums[0] + 2 * orderedNums[1]);
      feet += (firstNum * secondNum * thirdNum);
      
      /*var firstPseudoArea = firstNum * secondNum;
      var secondPseudoArea = firstNum * thirdNum;
      var thirdPseudoArea = secondNum * thirdNum;
      
      feet += ( 2 * firstPseudoArea) + (2 * secondPseudoArea) + (2 * thirdPseudoArea);
      
      feet += [firstPseudoArea, secondPseudoArea, thirdPseudoArea].sort(sortNumber)[0];
      */
      whichNum = 1;
      firstNumStr = '';
      secondNumStr = '';
      thirdNumStr = ''; 
      shouldSum = false;
    }
  }
  $('#result').text('Result = ' + feet);
});

function sortNumber(a,b) {
    return a - b;
}

@@ -32,159 +32,30 @@
 %7B%0A  
-var firstNumStr = '';%0A  var secondNumStr = '';%0A  var thirdNumStr = '';%0A  var whichNum = 1;%0A  %0A  var feet = 0;%0A  var shouldSum = false;%0A  var content = 
+%0A  var steps = $.trim(
 $('#
@@ -70,17 +70,8 @@
 xt()
-.split(''
 );%0A 
@@ -97,1269 +97,57 @@
 i %3C 
-content.length;++i) %7B%0A    if($.isNumeric(content%5Bi%5D)) %7B%0A      if(whichNum == 1) %7B%0A        firstNumStr += content%5Bi%5D;%0A      %7D else if(whichNum == 2) %7B%0A        secondNumStr += content%5Bi%5D;%0A      %7D else if(whichNum == 3) %7B%0A        thirdNumStr += content%5Bi%5D;%0A        if(i == content.length - 1)%0A          shouldSum = true;%0A      %7D%0A    %7D else if(content%5Bi%5D == 'x') %7B%0A      whichNum++;%0A    %7D else %7B%0A      shouldSum = true; %0A    %7D%0A    %0A    if(shouldSum) %7B%0A      %0A      var firstNum = parseInt(firstNumStr);%0A      var secondNum = parseInt(secondNumStr);%0A      var thirdNum = parseInt(thirdNumStr);%0A      %0A      var orderedNums = %5BfirstNum, secondNum, thirdNum%5D.sort(sortNumber);%0A      feet += (2 * orderedNums%5B0%5D + 2 * orderedNums%5B1%5D);%0A      feet += (firstNum * secondNum * thirdNum);%0A      %0A      /*var firstPseudoArea = firstNum * secondNum;%0A      var secondPseudoArea = firstNum * thirdNum;%0A      var thirdPseudoArea = secondNum * thirdNum;%0A      %0A      feet += ( 2 * firstPseudoArea) + (2 * secondPseudoArea) + (2 * thirdPseudoArea);%0A      %0A      feet += %5BfirstPseudoArea, secondPseudoArea, thirdPseudoArea%5D.sort(sortNumber)%5B0%5D;%0A      */%0A      whichNum = 1;%0A      firstNumStr = '';%0A      secondNumStr = '';%0A      thirdNumStr = ''; %0A      shouldSum = false;%0A    %7D%0A  %7D
+steps.length;++i) %7B%0A    var move = steps%5Bi%5D;%0A  %7D%0A
 %0A  $

Update custom.js