//sample solution
//pad function courtesy of stack overflow
function pad(n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
function arrayPacking(a) {
var someString=""
for(i=0; i<a.length; i++){
someString = pad((a[i] >>> 0).toString(2),8) + someString;
}
return parseInt(someString,2);
}
No comments:
Post a Comment