class TestTriangles(TestCase): my_file = data_file(2016, "day_03_mine.txt") def test_1_example(self): self.assertFalse(check_triangle([5, 10, 25])) self.assertFalse(check_triangle([10, 5, 25])) self.assertFalse(check_triangle([10, 25, 5])) self.assertFalse(check_triangle([25, 10, 5])) self.assertFalse(check_triangle([5, 25, 10])) self.assertFalse(check_triangle([25, 5, 10])) self.assertFalse(check_triangle(map(int, " 139 444 640".split()))) self.assertTrue(check_triangle(map(int, " 171 757 815".split()))) def test_1_mine(self): self.assertEqual( 993, check_all_triangles(self.my_file, make_triangles_rows)) def test_2_example(self): example_file = data_file(2016, "day_03_2_example.txt") self.assertEqual( 4, check_all_triangles(example_file, make_triangles_columns)) def test_2_mine(self): self.assertEqual( 1849, check_all_triangles(self.my_file, make_triangles_columns))
class TestPasswordValidator(TestCase): my_data_file = data_file(2017, "day_04_1_mine.txt") def test_no_same_word_1(self): self.assertTrue(no_same_words("aa bb cc dd ee")) def test_no_same_word_2(self): self.assertFalse(no_same_words("aa bb cc dd aa")) def test_no_same_word_3(self): self.assertTrue(no_same_words("aa bb cc dd aaa")) def test_no_same_word_mine(self): self.assertEqual(477, count_valid(self.my_data_file, no_same_words)) def test_no_anagram_1(self): self.assertTrue(no_anagram("abcde fghij")) def test_no_anagram_2(self): self.assertFalse(no_anagram("abcde xyz ecdab")) def test_no_anagram_3(self): self.assertTrue(no_anagram("a ab abc abd abf abj")) def test_no_anagram_4(self): self.assertTrue(no_anagram("iiii oiii ooii oooi oooo")) def test_no_anagram_5(self): self.assertFalse(no_anagram("oiii ioii iioi iiio")) def test_no_anagram_mine(self): self.assertEqual(167, count_valid(self.my_data_file, no_anagram))
def __init__(self, filename): self.dance_plan = data_file(2017, filename) self.moves = self.gen_moves() self.moves_per_iteration = len(self.moves) self.num_iterations = None self.iteration = None self.i = None
class TestSolveMaze(unittest.TestCase): example_data_file = data_file(2017, "day_05_1_example.txt") my_data_file = data_file(2017, "day_05_1_mine.txt") def test_1_example(self): self.assertEqual( 5, solve_maze_file(self.example_data_file, alteration_one)) def test_1_mine(self): self.assertEqual(374269, solve_maze_file(self.my_data_file, alteration_one)) def test_2_example(self): self.assertEqual( 10, solve_maze_file(self.example_data_file, alteration_two)) @unittest.skip("Takes too long") def test_2_mine(self): self.assertEqual(27720699, solve_maze_file(self.my_data_file, alteration_two))
def test_2_mine(self): self.assertEqual( 984, find_objects_location(data_file(2016, "day_04_mine.txt")))
def test_1_mine(self): self.assertEqual( 185371, sum_valid_rooms_sectors(data_file(2016, "day_04_mine.txt")))
def test_1_examples_file(self): self.assertEqual( 1514, sum_valid_rooms_sectors(data_file(2016, "day_04_example.txt")))
def test_2_example(self): example_file = data_file(2016, "day_03_2_example.txt") self.assertEqual( 4, check_all_triangles(example_file, make_triangles_columns))
def __init__(self, filename): self.registers = defaultdict(lambda: 0) self.program = open(data_file(2017, filename)) self.max_register_ever = 0