Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 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));