Example #1
0
def test_new_nice():
    # qjhvhtzxzqqjkmpb is nice because is has a pair that appears twice (qj) and a letter that repeats with exactly one letter between them (zxz).
    assert True == newnicestring.is_nice("qjhvhtzxzqqjkmpb")
    # 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.
    assert True == newnicestring.is_nice("xxyxx")
Example #2
0
def test_new_naughty():
    # uurcxstgmygtbstg is naughty because it has a pair (tg) but no repeat with a single letter between them.
    assert False == newnicestring.is_nice("uurcxstgmygtbstg")
    # ieodomkazucvgmuy is naughty because it has a repeating letter with one between (odo), but no pair that appears twice.
    assert False == newnicestring.is_nice("ieodomkazucvgmuy")
Example #3
0
from newnicestring import is_nice

nice_strings = 0
with open("input.txt", "rb") as handle:
    for string in handle:
        nice_strings += 1 if is_nice(string) else 0

print "Found %d Nice Strings" % nice_strings