Exemplo n.º 1
0
 def test_checksum(self):
     ids = [
         "abcdef", "bababc", "abbcde", "abcccd", "aabcdd", "abcdee",
         "ababab"
     ]
     stu = day02.checksum(ids)
     self.assertEqual(stu, 12)
Exemplo n.º 2
0
 def test_checksum(self):
     self.assertEqual((0, 0), checksum("abcdef"))
     self.assertEqual((1, 1), checksum("bababc"))
     self.assertEqual((1, 0), checksum("abbcde"))
     self.assertEqual((0, 1), checksum("abcccd"))
     self.assertEqual((1, 0), checksum("aabcdd"))
     self.assertEqual((1, 0), checksum("abcdee"))
     self.assertEqual((0, 1), checksum("ababab"))
Exemplo n.º 3
0
 def test_part_one(self):
     self.assertEqual(linediff('5\t1\t9\t5'), 8)
     self.assertEqual(linediff('7\t5\t3'), 4)
     self.assertEqual(linediff('2\t4\t6\t8'), 6)
     self.assertEqual(checksum('5\t1\t9\t5\n7\t5\t3\n2\t4\t6\t8', linediff),
                      18)
Exemplo n.º 4
0
 def test_part_two(self):
     self.assertEqual(linediv('5\t9\t2\t8'), 4)
     self.assertEqual(linediv('9\t4\t7\t3'), 3)
     self.assertEqual(linediv('3\t8\t6\t5'), 2)
     self.assertEqual(
         checksum('5\t9\t2\t8\n9\t4\t7\t3\n3\t8\t6\t5', linediv), 9)
Exemplo n.º 5
0
def test_checksum():
    assert checksum([[5, 1, 9, 5], [7, 5, 3], [2, 4, 6, 8]]) == 18
Exemplo n.º 6
0
def test_day02_part2():
    sample_data = [(5, 9, 2, 8), (9, 4, 7, 3), (3, 8, 6, 5)]
    actual = day02.checksum(sample_data, day02.div_checksum)
    assert actual == 9
Exemplo n.º 7
0
def test_day02_part1():
    sample_data = [(5, 1, 9, 5), (7, 5, 3), (2, 4, 6, 8)]
    actual = day02.checksum(sample_data, day02.diff_checksum)
    assert actual == 18
Exemplo n.º 8
0
 def test_part_one(self):
     self.assertEqual(linediff('5\t1\t9\t5'), 8)
     self.assertEqual(linediff('7\t5\t3'), 4)
     self.assertEqual(linediff('2\t4\t6\t8'), 6)
     self.assertEqual(checksum('5\t1\t9\t5\n7\t5\t3\n2\t4\t6\t8', linediff), 18)
Exemplo n.º 9
0
 def test_part_two(self):
     self.assertEqual(linediv('5\t9\t2\t8'), 4)
     self.assertEqual(linediv('9\t4\t7\t3'), 3)
     self.assertEqual(linediv('3\t8\t6\t5'), 2)
     self.assertEqual(checksum('5\t9\t2\t8\n9\t4\t7\t3\n3\t8\t6\t5', linediv), 9)
Exemplo n.º 10
0
 def test_checksum(self, input_part1):
     input_str, expected = input_part1
     assert checksum(input_str) == expected
Exemplo n.º 11
0
def test_checksum():
    with open("test_day02.txt") as fh:
        assert 12 == checksum(fh)
Exemplo n.º 12
0
 def test_full(self):
     stu = day02.checksum(day02.read("test.txt"))
     self.assertEqual(stu, 12)