Last active
December 18, 2017 15:16
-
-
Save humancatfood/59f033f8623ab69aa001de0e2ef51e8f to your computer and use it in GitHub Desktop.
Advent Of Code 2017 - 04(1) http://adventofcode.com/2017/day/4
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
const phrases = ` | |
oaoe rxeq vssdqtu xrk cjv yaoqp loo | |
mveua dogbam szydvri hyzk lbega abzqw xwjn wniug kwbre | |
npaoy uivpxwd oynpa rcdk uixpvdw | |
yserir iikzcm ieuroca iuwcfov rvb giti crdpdcv mxpps | |
spyuhgo lucasl ucllsa bymnjig yflbv nxitmlf | |
xlxyhwz xla mpye fvjegwg fezlfrt inetrh vhg xpvstx ydhvq | |
xgue cvtmh myg ontvvyw ygm oqzrdrw | |
srdfsjf dli kccb kauk kauk apa doefc cdffkhh cdffkhh | |
msizb elqiov lqn epamk onmnlst baawab ncafwaf jrataml iyzhy svycuec | |
wdzqpcn dkgdumv wdzqpcn qxdmwib cjsigi bgcihgh fmua | |
`; // rest omitted .. | |
const result = phrases | |
.trim().split('\n').map(line => line.split(' ')) | |
.map(line => line.length === (new Set(line)).size) | |
.reduce((res, isEqual) => res + (isEqual ? 1 : 0), 0); |
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
const phrases = ` | |
oaoe rxeq vssdqtu xrk cjv yaoqp loo | |
mveua dogbam szydvri hyzk lbega abzqw xwjn wniug kwbre | |
npaoy uivpxwd oynpa rcdk uixpvdw | |
yserir iikzcm ieuroca iuwcfov rvb giti crdpdcv mxpps | |
spyuhgo lucasl ucllsa bymnjig yflbv nxitmlf | |
xlxyhwz xla mpye fvjegwg fezlfrt inetrh vhg xpvstx ydhvq | |
xgue cvtmh myg ontvvyw ygm oqzrdrw | |
srdfsjf dli kccb kauk kauk apa doefc cdffkhh cdffkhh | |
msizb elqiov lqn epamk onmnlst baawab ncafwaf jrataml iyzhy svycuec | |
wdzqpcn dkgdumv wdzqpcn qxdmwib cjsigi bgcihgh fmua | |
`; // rest omitted .. | |
const result = phrases | |
.trim().split('\n').map(line => line.split(' ')) | |
.map(line => line.map(word => word.split('').sort().join(''))) | |
.map(line => line.length === (new Set(line)).size) | |
.reduce((res, isEqual) => res + (isEqual ? 1 : 0), 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment