Last active
          December 4, 2017 07:13 
        
      - 
      
 - 
        
Save evilj0e/ceed1f10da4b824ad45f852f9b9fc738 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
evilj0e revised this gist
Dec 4, 2017 . 1 changed file with 30 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ var fs = require('fs'); var text = fs.readFileSync('input.txt', 'utf8'); var data = text.split('\n'); function isValid(password) { var parts = password.split(' '); var isValid = true; var hash = {}; for (var i = 0; i < parts.length; i++) { var part = parts[i].split('').sort().join(''); if (hash[part] && hash[part] === 1) { isValid = false; break; } else { hash[part] = hash[part] ? (hash[part] + 1) : 1; } }; return isValid; } function checkArray(data) { return data.reduce(function (acc, item) { return acc + isValid(item); }, 0); } console.log(checkArray(data));  - 
        
evilj0e created this gist
Dec 4, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ var fs = require('fs'); var text = fs.readFileSync('input.txt', 'utf8'); var data = text.split('\n'); function isValid(password) { var parts = password.split(' '); var isValid = true; var hash = {}; for (var i = 0; i < parts.length; i++) { var part = parts[i]; if (hash[part] && hash[part] === 1) { isValid = false; break; } else { hash[part] = hash[part] ? (hash[part] + 1) : 1; } }; return isValid; } function checkArray(data) { return data.reduce(function (acc, item) { return acc + isValid(item); }, 0); } console.log(checkArray(data));