示例#1
0
 def test_example1(self):
     example_input = """
         0,0,0,0
         3,0,0,0
         0,3,0,0
         0,0,3,0
         0,0,0,3
         0,0,0,6
         9,0,0,0
         12,0,0,0
     """
     s = Solver(from_str=example_input)
     self.assertEqual(s.solve_part_one(), 2)
示例#2
0
 def test_example4(self):
     example_input = """
         1,-1,-1,-2
         -2,-2,0,1
         0,2,1,3
         -2,3,-2,1
         0,2,3,-2
         -1,-1,1,-2
         0,-2,-1,0
         -2,2,3,-1
         1,2,2,0
         -1,-2,0,-2
         """
     s = Solver(from_str=example_input)
     self.assertEqual(s.solve_part_one(), 8)
示例#3
0
 def test_example3(self):
     example_input = """
         1,-1,0,1
         2,0,-1,0
         3,2,-1,0
         0,0,3,1
         0,0,-1,-1
         2,3,-2,0
         -2,2,0,0
         2,-2,0,-1
         1,-1,0,-1
         3,2,0,2
     """
     s = Solver(from_str=example_input)
     self.assertEqual(s.solve_part_one(), 3)
示例#4
0
 def test_example2(self):
     example_input = """
         -1,2,2,0
         0,0,2,-2
         0,0,0,-2
         -1,2,0,0
         -2,-2,-2,2
         3,0,2,-1
         -1,3,2,2
         -1,0,-1,0
         0,2,1,-2
         3,0,0,0
     """
     s = Solver(from_str=example_input)
     self.assertEqual(s.solve_part_one(), 4)
示例#5
0
 def test_sum_of_natural_numbers(self):
     self.assertEqual(Solver.sum_of_natural_numbers(1), 1)
     self.assertEqual(Solver.sum_of_natural_numbers(2), 3)
     self.assertEqual(Solver.sum_of_natural_numbers(3), 6)
     self.assertEqual(Solver.sum_of_natural_numbers(4), 10)
     self.assertEqual(Solver.sum_of_natural_numbers(5), 15)
     self.assertEqual(Solver.sum_of_natural_numbers(6), 21)
示例#6
0
 def test_solution(self):
     s = Solver(from_file="input/december25.input")
     self.assertEqual(s.solve_part_one(), 370)
示例#7
0
 def test_solution(self):
     one = Solver(from_file='input/dec25.in').solve()
     self.assertEqual(one, 19980801)
示例#8
0
 def test_example_codes(self):
     self.assertEqual(Solver.code_for_row_col(1, 1), 20151125)
     self.assertEqual(Solver.code_for_row_col(2, 1), 31916031)
     self.assertEqual(Solver.code_for_row_col(3, 1), 16080970)
     self.assertEqual(Solver.code_for_row_col(4, 1), 24592653)
     self.assertEqual(Solver.code_for_row_col(5, 1), 77061)
     self.assertEqual(Solver.code_for_row_col(6, 1), 33071741)
     self.assertEqual(Solver.code_for_row_col(1, 2), 18749137)
     self.assertEqual(Solver.code_for_row_col(2, 2), 21629792)
     self.assertEqual(Solver.code_for_row_col(3, 2), 8057251)
     self.assertEqual(Solver.code_for_row_col(4, 2), 32451966)
     self.assertEqual(Solver.code_for_row_col(5, 2), 17552253)
     self.assertEqual(Solver.code_for_row_col(6, 2), 6796745)
     self.assertEqual(Solver.code_for_row_col(1, 3), 17289845)
     self.assertEqual(Solver.code_for_row_col(2, 3), 16929656)
     self.assertEqual(Solver.code_for_row_col(3, 3), 1601130)
     self.assertEqual(Solver.code_for_row_col(4, 3), 21345942)
     self.assertEqual(Solver.code_for_row_col(5, 3), 28094349)
     self.assertEqual(Solver.code_for_row_col(6, 3), 25397450)
     self.assertEqual(Solver.code_for_row_col(1, 4), 30943339)
     self.assertEqual(Solver.code_for_row_col(2, 4), 7726640)
     self.assertEqual(Solver.code_for_row_col(3, 4), 7981243)
     self.assertEqual(Solver.code_for_row_col(4, 4), 9380097)
     self.assertEqual(Solver.code_for_row_col(5, 4), 6899651)
     self.assertEqual(Solver.code_for_row_col(6, 4), 24659492)
     self.assertEqual(Solver.code_for_row_col(1, 5), 10071777)
     self.assertEqual(Solver.code_for_row_col(2, 5), 15514188)
     self.assertEqual(Solver.code_for_row_col(3, 5), 11661866)
     self.assertEqual(Solver.code_for_row_col(4, 5), 10600672)
     self.assertEqual(Solver.code_for_row_col(5, 5), 9250759)
     self.assertEqual(Solver.code_for_row_col(6, 5), 1534922)
     self.assertEqual(Solver.code_for_row_col(1, 6), 33511524)
     self.assertEqual(Solver.code_for_row_col(2, 6), 4041754)
     self.assertEqual(Solver.code_for_row_col(3, 6), 16474243)
     self.assertEqual(Solver.code_for_row_col(4, 6), 31527494)
     self.assertEqual(Solver.code_for_row_col(5, 6), 31663883)
     self.assertEqual(Solver.code_for_row_col(6, 6), 27995004)
示例#9
0
 def test_code_number_given_row_and_column(self):
     self.assertEqual(Solver.code_no_for_row_col(1, 1), 1)
     self.assertEqual(Solver.code_no_for_row_col(2, 1), 2)
     self.assertEqual(Solver.code_no_for_row_col(3, 1), 4)
     self.assertEqual(Solver.code_no_for_row_col(4, 1), 7)
     self.assertEqual(Solver.code_no_for_row_col(5, 1), 11)
     self.assertEqual(Solver.code_no_for_row_col(6, 1), 16)
     self.assertEqual(Solver.code_no_for_row_col(1, 2), 3)
     self.assertEqual(Solver.code_no_for_row_col(2, 2), 5)
     self.assertEqual(Solver.code_no_for_row_col(3, 2), 8)
     self.assertEqual(Solver.code_no_for_row_col(4, 2), 12)
     self.assertEqual(Solver.code_no_for_row_col(5, 2), 17)
     self.assertEqual(Solver.code_no_for_row_col(1, 3), 6)
     self.assertEqual(Solver.code_no_for_row_col(2, 3), 9)
     self.assertEqual(Solver.code_no_for_row_col(3, 3), 13)
     self.assertEqual(Solver.code_no_for_row_col(4, 3), 18)
     self.assertEqual(Solver.code_no_for_row_col(1, 4), 10)
     self.assertEqual(Solver.code_no_for_row_col(2, 4), 14)
     self.assertEqual(Solver.code_no_for_row_col(3, 4), 19)
     self.assertEqual(Solver.code_no_for_row_col(1, 5), 15)
     self.assertEqual(Solver.code_no_for_row_col(2, 5), 20)
     self.assertEqual(Solver.code_no_for_row_col(1, 6), 21)