SHARE
TWEET

Untitled

Siri0n Nov 5th, 2017 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function div(a, b){
  2.     return Math.floor(a/b)
  3. }
  4.  
  5. function roundDown(a){
  6.     var d = 1;
  7.     while(d <= a){
  8.         d *= 10;
  9.     }
  10.     return d/10;
  11. }
  12.  
  13. function merge(a, b){
  14.     var r = 0,
  15.         da = roundDown(a),
  16.         db = roundDown(b);
  17.     while(da >= 1 && db >= 1){
  18.         r = 100*r + 10 * div(a, da) + div(b, db);
  19.         a = a % da;
  20.         b = b % db;
  21.         da /= 10;
  22.         db /= 10;
  23.     }
  24.     if(a > 0 || b > 0){
  25.         r = r*Math.max(da, db)*10 + Math.max(a, b);
  26.     }
  27.     return r;
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top