While it appears you validated the passwords correctly, they don’t seem to be what the Official Toboggan Corporate Authentication System is expecting.

The shopkeeper suddenly realizes that he just accidentally explained the password policy rules from his old job at the sled rental place down the street! The Official Toboggan Corporate Policy actually works a little differently.

Each policy actually describes two positions in the password, where 1 means the first character, 2 means the second character, and so on. (; ) Exactly one of these positions must contain the given letter. Other occurrences of the letter are irrelevant for the purposes of policy enforcement.

Be careful

The Official Toboggan Corporate Policy has no concept of “index zero”!

Given the same example list of passwords:

1-3 a: abcde
1-3 b: cdefg
2-9 c: ccccccccc

we have that

Assignment

Write a static function isValidPassword that takes two strings (String): i) a password and ii) a corporate policy when the password was set. The function must return a Boolean value (boolean) that indicates whether the given password is valid according to the new interpretation of the given policy.

This static function must be located in the class Submission.

Example

> Submission.isValidPassword("abcde", "1-3 a")
true
> Submission.isValidPassword("cdefg", "1-3 b")
false
> Submission.isValidPassword("ccccccccc", "2-9 c")
false