Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 0.57 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE html>
  2. <title>solveAlgebraicEquation</title>
  3. <div>Output: <b id="ret"></b></div>
  4. <script>
  5.   var myFunction = function(a,b,c,d,e){c="^";for(d=0;e=a[d++];)c+="(,*)\\"+d+"{"+~-e+"}";return((Array(-~b)+"").match(c+"$")||"").slice(1)};
  6.   // The input should be ([a, b, c, ...], sum)
  7.   // e.g. Solve 11x + 2y + 5z = 115
  8.   var solution = myFunction([11, 2, 5], 115);
  9.   document.getElementById( "ret" ).innerHTML = 'One of the solutions of 11x + 2y + 5z = 115 is x = ' +
  10.     solution[0].length + ', y = ' +
  11.     solution[1].length + ', z = ' +
  12.     solution[2].length;
  13. </script>