Skip to content

Instantly share code, notes, and snippets.

@Mellen
Created December 8, 2021 09:02
Show Gist options
  • Save Mellen/c730f217e27bf35913266b96e896c3b5 to your computer and use it in GitHub Desktop.
Save Mellen/c730f217e27bf35913266b96e896c3b5 to your computer and use it in GitHub Desktop.
(function(inp)
{
let lines = inp.split('\n');
const oneLength = 2;
const fourLength = 4;
const sevenLength = 3;
const eightLength = 7;
let easycount = lines.reduce((count, line) =>
{
if(line.length > 0)
{
let [_, output] = line.split('|');
let numbers = output.split(' ');
count += numbers.filter(n => n.length == oneLength || n.length == fourLength || n.length == sevenLength || n.length == eightLength).length;
}
return count;
},0);
return easycount;
})(document.querySelector('pre').textContent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment