Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let count = Number(input.shift());
- let pattern = /^(\S+)>(?<nums>[0-9]{3})\|(?<low>[a-z]{3})\|(?<upper>[A-Z]{3})\|(?<symbol>[^<>]{3})<\1$/gm;
- for (const line of input) {
- if (Array.from(line.matchAll(pattern)).length > 0) {
- let result = Array.from(line.matchAll(pattern))[0].groups;
- console.log(
- `Password: ${result.nums}${result.low}${result.upper}${result.symbol}`
- );
- } else {
- console.log("Try another password!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment