2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -0,0 +1,26 @@
(function () {
'use strict';
// maxCombine :: [Int] -> Int
function maxCombine(xs) {
return parseInt(
xs.sort(
function (x, y) {
var a = x.toString(),
b = y.toString(),
ab = parseInt(a + b),
ba = parseInt(b + a);
return ab > ba ? -1 : (ab < ba ? 1 : 0);
}
)
.join(''), 10
);
}
return [
[1, 34, 3, 98, 9, 76, 45, 4],
[54, 546, 548, 60]
].map(maxCombine);
})();

View file

@ -0,0 +1,7 @@
var maxCombine = (a) => +(a.sort((x, y) => +("" + y + x) - +("" + x + y)).join(''));
// test & output
console.log([
[1, 34, 3, 98, 9, 76, 45, 4],
[54, 546, 548, 60]
].map(maxCombine));