Skip to content

Instantly share code, notes, and snippets.

@StillManic
Created December 24, 2015 06:08
Show Gist options
  • Save StillManic/e35bcf6e056e4558ac07 to your computer and use it in GitHub Desktop.
Save StillManic/e35bcf6e056e4558ac07 to your computer and use it in GitHub Desktop.
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