forked from HackYourFuture/JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-password-validation.js
More file actions
23 lines (21 loc) · 1.01 KB
/
Copy path3-password-validation.js
File metadata and controls
23 lines (21 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
* Credit to https://adventofcode.com/ for this exercise
*
* Each object in the passwordList gives a password policy and then the password.
* The times field says the minimal and maximal amount of times the letter should be in the password. So 1-3 means at least 1 time, at most 3 times.
* The letter field gives which letter should be counted
* The password field gives the password
*
* In the list 2 passwords are valid, the middle one is not as there is no b in the password.
*
* We expect the output:
*
* 'abcde' is VALID, a is present 1 times and should have been present at least 1 and at most 3 times
* 'cdefg' is INVALID, b is present 0 times and should have been present at least 1 and at most 3 times
* 'ccccccccc' is VALID, c is present 9 times and should have been present at least 2 and at most 9 times
*/
const passwordList = [
{ times: '1-3', letter: 'a', password: 'abcde'},
{ times: '1-3', letter: 'b', password: 'cdefg'},
{ times: '2-9', letter: 'c', password: 'ccccccccc'}
];