Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for [old] Bigger Together by kurosawa4434
"use strict";
function biggerTogether(ints) {
const strs = ints.map((x)=>x.toString());
strs.sort((a, b)=>parseInt(a+b, 10)-parseInt(b+a, 10));
const small = parseInt(strs.join(''), 10);
const big = parseInt(strs.reverse().join(''), 10);
return big - small;
}
var assert = require('assert');
if (!global.is_checking) {
assert.equal(biggerTogether([1,2,3,4]), 3087, "4321 - 1234 = 3087")
assert.equal(biggerTogether([1,2,3,4, 11, 12]), 32099877, "43212111 - 11112234 = 32099877")
assert.equal(biggerTogether([0, 1]), 9, "10 - 01 = 9")
assert.equal(biggerTogether([100]), 0, "100 - 100 = 0")
console.log("Done! I feel like you good enough to click Check");
}
Aug. 11, 2017