Skip to content

Instantly share code, notes, and snippets.

@AdamMescher
Created December 3, 2020 04:44
Show Gist options
  • Save AdamMescher/5c4cafd1899725681656604826fc877a to your computer and use it in GitHub Desktop.
Save AdamMescher/5c4cafd1899725681656604826fc877a to your computer and use it in GitHub Desktop.
2020 Advent of Code Day 02 Part Two Solution in JavaScript
input.reduce((accum, item) => {
const pos1 = item[0].split('-')[0] - 1
const pos2 = item[0].split('-')[1] - 1
const char = item[1]
const password = item[2]
if( password.charAt(pos1) === char ^ password.charAt(pos2) === char) {
accum++
}
return accum
}, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment