Skip to content

Instantly share code, notes, and snippets.

@dregenor
Created April 21, 2021 13:41
Show Gist options
  • Save dregenor/178eaf76c9fe565cf39ff6613de8ce8e to your computer and use it in GitHub Desktop.
Save dregenor/178eaf76c9fe565cf39ff6613de8ce8e to your computer and use it in GitHub Desktop.
function countCh(result, itm) {
if (itm % 2) {
result.nch++;
} else {
result.ch++;
}
return result;
}
const md5 = require('md5');
let preset = [1, 3, 5, 7, 9, 13, 2,4 ,6, 8, 10, 12, 14, 16, 18, 44, 28, 24];
// for (let i=1; i < 10; i++ ) {
// if (i % 2) {
// preset.push(i);
// }
// }
// for (let i=1; i < 30; i++ ) {
// if (!(i % 2)) {
// preset.push(i);
// }
// }
console.warn(JSON.stringify(preset));
console.warn(JSON.stringify(preset.reduce(countCh, {ch:0, nch:0})));
const hashed = preset.map((item) => {
return md5(item, {asBytes: true}).shift();
});
console.warn(JSON.stringify(hashed));
console.warn(JSON.stringify(hashed.reduce(countCh, {ch:0, nch:0})));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment