import unittest

from day_4 import is_passphrase_valid, valid_passphrases, sorted_word
from challenge_day_4 import challenge


class TestPart1(unittest.TestCase):
    """
    --- Day 4: High-Entropy Passphrases ---

    A new system policy has been put in place that requires all accounts to use
    a passphrase instead of simply a password. A passphrase consists of a series
    of words (lowercase letters) separated by spaces.

    To ensure security, a valid passphrase must contain no duplicate words.

    For example:

    - aa bb cc dd ee is valid.
    - aa bb cc dd aa is not valid - the word aa appears more than once.
    - aa bb cc dd aaa is valid - aa and aaa count as different words.

    The system's full passphrase list is available as your puzzle input. How
    many passphrases are valid?
    """

    def test_simple_matches(self):
        self.assertTrue(is_passphrase_valid("aa bb cc dd ee"))
        self.assertFalse(is_passphrase_valid("aa bb cc dd aa"))
        self.assertTrue(is_passphrase_valid("aa bb cc dd aaaa"))
        self.assertEqual(2, len(valid_passphrases((
            "aa bb cc dd ee",
            "aa bb cc dd aa",
            "aa bb cc dd aaaa"
        ))))

    def test_challenge(self):
        self.assertEqual(337, len(valid_passphrases((challenge))))


class TestPart2(unittest.TestCase):
    """
    --- Part Two ---

    For added security, yet another system policy has been put in place. Now, a
    valid passphrase must contain no two words that are anagrams of each other
    - that is, a passphrase is invalid if any word's letters can be rearranged
    to form any other word in the passphrase.

    For example:

    - abcde fghij is a valid passphrase.
    - abcde xyz ecdab is not valid - the letters from the third word can be
      rearranged to form the first word.
    - a ab abc abd abf abj is a valid passphrase, because all letters need to be
      used when forming another word.
    - iiii oiii ooii oooi oooo is valid.
    - oiii ioii iioi iiio is not valid - any of these words can be rearranged to
      form any other word.

    Under this new system policy, how many passphrases are valid?
    """

    def test_simple_matches(self):
        self.assertTrue(is_passphrase_valid(
            "abcde fghij", trans=sorted_word))
        self.assertFalse(is_passphrase_valid(
            "abcde xyz ecdab", trans=sorted_word))
        self.assertEqual(1, len(valid_passphrases(
            ("abcde fghij", "abcde xyz ecdab"), trans=sorted_word)))

    def test_challenge(self):
        self.assertEqual(231, len(valid_passphrases(
            challenge, trans=sorted_word)))

22bb012a8d5b94179c6722e7b3adcfe7b7507303
<mask token>


class TestPart1(unittest.TestCase):
    <mask token>

    def test_simple_matches(self):
        self.assertTrue(is_passphrase_valid('aa bb cc dd ee'))
        self.assertFalse(is_passphrase_valid('aa bb cc dd aa'))
        self.assertTrue(is_passphrase_valid('aa bb cc dd aaaa'))
        self.assertEqual(2, len(valid_passphrases(('aa bb cc dd ee',
            'aa bb cc dd aa', 'aa bb cc dd aaaa'))))
    <mask token>


class TestPart2(unittest.TestCase):
    """
    --- Part Two ---

    For added security, yet another system policy has been put in place. Now, a
    valid passphrase must contain no two words that are anagrams of each other
    - that is, a passphrase is invalid if any word's letters can be rearranged
    to form any other word in the passphrase.

    For example:

    - abcde fghij is a valid passphrase.
    - abcde xyz ecdab is not valid - the letters from the third word can be
      rearranged to form the first word.
    - a ab abc abd abf abj is a valid passphrase, because all letters need to be
      used when forming another word.
    - iiii oiii ooii oooi oooo is valid.
    - oiii ioii iioi iiio is not valid - any of these words can be rearranged to
      form any other word.

    Under this new system policy, how many passphrases are valid?
    """

    def test_simple_matches(self):
        self.assertTrue(is_passphrase_valid('abcde fghij', trans=sorted_word))
        self.assertFalse(is_passphrase_valid('abcde xyz ecdab', trans=
            sorted_word))
        self.assertEqual(1, len(valid_passphrases(('abcde fghij',
            'abcde xyz ecdab'), trans=sorted_word)))

    def test_challenge(self):
        self.assertEqual(231, len(valid_passphrases(challenge, trans=
            sorted_word)))

<mask token>


class TestPart1(unittest.TestCase):
    <mask token>

    def test_simple_matches(self):
        self.assertTrue(is_passphrase_valid('aa bb cc dd ee'))
        self.assertFalse(is_passphrase_valid('aa bb cc dd aa'))
        self.assertTrue(is_passphrase_valid('aa bb cc dd aaaa'))
        self.assertEqual(2, len(valid_passphrases(('aa bb cc dd ee',
            'aa bb cc dd aa', 'aa bb cc dd aaaa'))))

    def test_challenge(self):
        self.assertEqual(337, len(valid_passphrases(challenge)))


class TestPart2(unittest.TestCase):
    """
    --- Part Two ---

    For added security, yet another system policy has been put in place. Now, a
    valid passphrase must contain no two words that are anagrams of each other
    - that is, a passphrase is invalid if any word's letters can be rearranged
    to form any other word in the passphrase.

    For example:

    - abcde fghij is a valid passphrase.
    - abcde xyz ecdab is not valid - the letters from the third word can be
      rearranged to form the first word.
    - a ab abc abd abf abj is a valid passphrase, because all letters need to be
      used when forming another word.
    - iiii oiii ooii oooi oooo is valid.
    - oiii ioii iioi iiio is not valid - any of these words can be rearranged to
      form any other word.

    Under this new system policy, how many passphrases are valid?
    """

    def test_simple_matches(self):
        self.assertTrue(is_passphrase_valid('abcde fghij', trans=sorted_word))
        self.assertFalse(is_passphrase_valid('abcde xyz ecdab', trans=
            sorted_word))
        self.assertEqual(1, len(valid_passphrases(('abcde fghij',
            'abcde xyz ecdab'), trans=sorted_word)))

    def test_challenge(self):
        self.assertEqual(231, len(valid_passphrases(challenge, trans=
            sorted_word)))

<mask token>


class TestPart1(unittest.TestCase):
    """
    --- Day 4: High-Entropy Passphrases ---

    A new system policy has been put in place that requires all accounts to use
    a passphrase instead of simply a password. A passphrase consists of a series
    of words (lowercase letters) separated by spaces.

    To ensure security, a valid passphrase must contain no duplicate words.

    For example:

    - aa bb cc dd ee is valid.
    - aa bb cc dd aa is not valid - the word aa appears more than once.
    - aa bb cc dd aaa is valid - aa and aaa count as different words.

    The system's full passphrase list is available as your puzzle input. How
    many passphrases are valid?
    """

    def test_simple_matches(self):
        self.assertTrue(is_passphrase_valid('aa bb cc dd ee'))
        self.assertFalse(is_passphrase_valid('aa bb cc dd aa'))
        self.assertTrue(is_passphrase_valid('aa bb cc dd aaaa'))
        self.assertEqual(2, len(valid_passphrases(('aa bb cc dd ee',
            'aa bb cc dd aa', 'aa bb cc dd aaaa'))))

    def test_challenge(self):
        self.assertEqual(337, len(valid_passphrases(challenge)))


class TestPart2(unittest.TestCase):
    """
    --- Part Two ---

    For added security, yet another system policy has been put in place. Now, a
    valid passphrase must contain no two words that are anagrams of each other
    - that is, a passphrase is invalid if any word's letters can be rearranged
    to form any other word in the passphrase.

    For example:

    - abcde fghij is a valid passphrase.
    - abcde xyz ecdab is not valid - the letters from the third word can be
      rearranged to form the first word.
    - a ab abc abd abf abj is a valid passphrase, because all letters need to be
      used when forming another word.
    - iiii oiii ooii oooi oooo is valid.
    - oiii ioii iioi iiio is not valid - any of these words can be rearranged to
      form any other word.

    Under this new system policy, how many passphrases are valid?
    """

    def test_simple_matches(self):
        self.assertTrue(is_passphrase_valid('abcde fghij', trans=sorted_word))
        self.assertFalse(is_passphrase_valid('abcde xyz ecdab', trans=
            sorted_word))
        self.assertEqual(1, len(valid_passphrases(('abcde fghij',
            'abcde xyz ecdab'), trans=sorted_word)))

    def test_challenge(self):
        self.assertEqual(231, len(valid_passphrases(challenge, trans=
            sorted_word)))

import unittest
from day_4 import is_passphrase_valid, valid_passphrases, sorted_word
from challenge_day_4 import challenge


class TestPart1(unittest.TestCase):
    """
    --- Day 4: High-Entropy Passphrases ---

    A new system policy has been put in place that requires all accounts to use
    a passphrase instead of simply a password. A passphrase consists of a series
    of words (lowercase letters) separated by spaces.

    To ensure security, a valid passphrase must contain no duplicate words.

    For example:

    - aa bb cc dd ee is valid.
    - aa bb cc dd aa is not valid - the word aa appears more than once.
    - aa bb cc dd aaa is valid - aa and aaa count as different words.

    The system's full passphrase list is available as your puzzle input. How
    many passphrases are valid?
    """

    def test_simple_matches(self):
        self.assertTrue(is_passphrase_valid('aa bb cc dd ee'))
        self.assertFalse(is_passphrase_valid('aa bb cc dd aa'))
        self.assertTrue(is_passphrase_valid('aa bb cc dd aaaa'))
        self.assertEqual(2, len(valid_passphrases(('aa bb cc dd ee',
            'aa bb cc dd aa', 'aa bb cc dd aaaa'))))

    def test_challenge(self):
        self.assertEqual(337, len(valid_passphrases(challenge)))


class TestPart2(unittest.TestCase):
    """
    --- Part Two ---

    For added security, yet another system policy has been put in place. Now, a
    valid passphrase must contain no two words that are anagrams of each other
    - that is, a passphrase is invalid if any word's letters can be rearranged
    to form any other word in the passphrase.

    For example:

    - abcde fghij is a valid passphrase.
    - abcde xyz ecdab is not valid - the letters from the third word can be
      rearranged to form the first word.
    - a ab abc abd abf abj is a valid passphrase, because all letters need to be
      used when forming another word.
    - iiii oiii ooii oooi oooo is valid.
    - oiii ioii iioi iiio is not valid - any of these words can be rearranged to
      form any other word.

    Under this new system policy, how many passphrases are valid?
    """

    def test_simple_matches(self):
        self.assertTrue(is_passphrase_valid('abcde fghij', trans=sorted_word))
        self.assertFalse(is_passphrase_valid('abcde xyz ecdab', trans=
            sorted_word))
        self.assertEqual(1, len(valid_passphrases(('abcde fghij',
            'abcde xyz ecdab'), trans=sorted_word)))

    def test_challenge(self):
        self.assertEqual(231, len(valid_passphrases(challenge, trans=
            sorted_word)))

import unittest

from day_4 import is_passphrase_valid, valid_passphrases, sorted_word
from challenge_day_4 import challenge


class TestPart1(unittest.TestCase):
    """
    --- Day 4: High-Entropy Passphrases ---

    A new system policy has been put in place that requires all accounts to use
    a passphrase instead of simply a password. A passphrase consists of a series
    of words (lowercase letters) separated by spaces.

    To ensure security, a valid passphrase must contain no duplicate words.

    For example:

    - aa bb cc dd ee is valid.
    - aa bb cc dd aa is not valid - the word aa appears more than once.
    - aa bb cc dd aaa is valid - aa and aaa count as different words.

    The system's full passphrase list is available as your puzzle input. How
    many passphrases are valid?
    """

    def test_simple_matches(self):
        self.assertTrue(is_passphrase_valid("aa bb cc dd ee"))
        self.assertFalse(is_passphrase_valid("aa bb cc dd aa"))
        self.assertTrue(is_passphrase_valid("aa bb cc dd aaaa"))
        self.assertEqual(2, len(valid_passphrases((
            "aa bb cc dd ee",
            "aa bb cc dd aa",
            "aa bb cc dd aaaa"
        ))))

    def test_challenge(self):
        self.assertEqual(337, len(valid_passphrases((challenge))))


class TestPart2(unittest.TestCase):
    """
    --- Part Two ---

    For added security, yet another system policy has been put in place. Now, a
    valid passphrase must contain no two words that are anagrams of each other
    - that is, a passphrase is invalid if any word's letters can be rearranged
    to form any other word in the passphrase.

    For example:

    - abcde fghij is a valid passphrase.
    - abcde xyz ecdab is not valid - the letters from the third word can be
      rearranged to form the first word.
    - a ab abc abd abf abj is a valid passphrase, because all letters need to be
      used when forming another word.
    - iiii oiii ooii oooi oooo is valid.
    - oiii ioii iioi iiio is not valid - any of these words can be rearranged to
      form any other word.

    Under this new system policy, how many passphrases are valid?
    """

    def test_simple_matches(self):
        self.assertTrue(is_passphrase_valid(
            "abcde fghij", trans=sorted_word))
        self.assertFalse(is_passphrase_valid(
            "abcde xyz ecdab", trans=sorted_word))
        self.assertEqual(1, len(valid_passphrases(
            ("abcde fghij", "abcde xyz ecdab"), trans=sorted_word)))

    def test_challenge(self):
        self.assertEqual(231, len(valid_passphrases(
            challenge, trans=sorted_word)))
