Created
December 3, 2020 04:44
-
-
Save AdamMescher/5c4cafd1899725681656604826fc877a to your computer and use it in GitHub Desktop.
2020 Advent of Code Day 02 Part Two Solution in JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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