Пример #1
0
def test_naughty():
    # 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.
    assert False == is_nice("jchzalrnumimnmhp")
    assert False == is_nice("haegwjzuvuyypxyu")
    assert False == is_nice("dvszwmarrgswjxmb")
Пример #2
0
def test_nice():
    # 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.
    assert True == is_nice("ugknbfddgicrmopn")
    assert True == is_nice("aaa")
Пример #3
0
from nicestring 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