Created
December 24, 2015 06:08
-
-
Save StillManic/e35bcf6e056e4558ac07 to your computer and use it in GitHub Desktop.
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 characters
private static void day5() { | |
int niceStrings = 0; | |
Pattern patternPairs = Pattern.compile("\\w+?(ab|cd|pq|xy)+\\w+?"); | |
Pattern patternVowels = Pattern.compile("\\w+?(a|e|i|o|u){3,}\\w+?"); | |
Pattern patternDoubles = Pattern.compile("\\w+?(\\w\\w)+\\w+?"); | |
for (String input : inputList) { | |
if (patternVowels.asPredicate().and(patternDoubles.asPredicate().and(patternPairs.asPredicate().negate())).test(input)) niceStrings++; | |
} | |
System.out.println(niceStrings); | |
// System.out.println(inputList.stream().filter(input -> pattern.asPredicate().negate().test(input)).findAny()); | |
// inputList.forEach(input -> {if (pattern.matcher(input).matches()) System.out.println(input);}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment