Santa needs help figuring out which strings in his text file are naughty or nice.
A nice string is one with all of the following properties:
aeiou only), like aei, xazegov, or aeiouaeiouaeiou.xx, abcdde (dd), or aabbccdd (aa, bb, cc, or dd).ab, cd, pq, or xy, even if they are part of one of the other requirements.For example:
ugknbfddgicrmopn is nice because it has at least three vowels (u...i...o...), 
a double letter (...dd...), and none of the disallowed substrings.aaa is nice because it has at least three vowels and a double letter, even though the letters used by different rules overlap.jchzalrnumimnmhp is naughty because it has no double letter.haegwjzuvuyypxyu is naughty because it contains the string xy.dvszwmarrgswjxmb is naughty because it contains only one vowel.How many strings are nice?
In [1]:
    
has3vowels=: 3 <: [: +/ e.&'aeiou'
hasDouble=: [: +./ 2 =/\ ]
noBadStrings=: -.@(+./)@((_2 ]\ 'abcdpqxy') +./@E."1 ])
isNiceString=: noBadStrings *. hasDouble *. has3vowels
input=: 'b' freads '~AoC/2015/aoc05_input.txt'
echo 'Day5 Part1: ',": +/ isNiceString &> input
    
    
Realizing the error of his ways, Santa has switched to a better model of determining whether a string is naughty or nice. None of the old rules apply, as they are all clearly ridiculous.
Now, a nice string is one with all of the following properties:
xyxy (xy) or aabcdefgaa (aa), but not like aaa (aa, but it overlaps).xyx, abcdefeghi (efe), or even aaa.For example:
qjhvhtzxzqqjkmpb is nice because is has a pair that appears twice (qj) and a letter that repeats with exactly one letter between them (zxz).xxyxx is nice because it has a pair that appears twice and a letter that repeats with one between, even though the letters used by each rule overlap.uurcxstgmygtbstg is naughty because it has a pair (tg) but no repeat with a single letter between them.ieodomkazucvgmuy is naughty because it has a repeating letter with one between (odo), but no pair that appears twice.How many strings are nice under these new rules? )
In [2]:
    
NB. http://code.jsoftware.com/wiki/Essays/Non-Overlapping_Substrings
tc  =: ,&_1 {~^:a: 0:
findNonOverlapStr=: i.@#@] e. #@[ (tc@(] I. +) { _1 ,~ ]) I.@E.
hasPair2Letters=: 1 < [: >./ [: +/"1 ] findNonOverlapStr"1~ 2 ]\ ]
hasRepeatedLetter=: [: +./ ] = '55' ,~ 2&}.
isNiceString2=: hasPair2Letters *. hasRepeatedLetter
echo 'Day5 Part2: ',": +/ isNiceString2 &> input