Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function div(a, b){
- return Math.floor(a/b)
- }
- function roundDown(a){
- var d = 1;
- while(d <= a){
- d *= 10;
- }
- return d/10;
- }
- function merge(a, b){
- var r = 0,
- da = roundDown(a),
- db = roundDown(b);
- while(da >= 1 && db >= 1){
- r = 100*r + 10 * div(a, da) + div(b, db);
- a = a % da;
- b = b % db;
- da /= 10;
- db /= 10;
- }
- if(a > 0 || b > 0){
- r = r*Math.max(da, db)*10 + Math.max(a, b);
- }
- return r;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement