def test(self): self.assertEqual(part1.get_location("ne,ne,ne"), (6, 3)) self.assertEqual(part1.get_location("ne,ne,sw,sw"), (0, 0)) self.assertEqual(part1.get_location("ne,ne,s,s"), (4, -2)) self.assertEqual(part1.get_location("se,sw,se,sw,sw"), (-2, -5)) self.assertEqual(part1.get_answer("ne,ne,ne"), 3) self.assertEqual(part1.get_answer("ne,ne,sw,sw"), 0) self.assertEqual(part1.get_answer("ne,ne,s,s"), 2) self.assertEqual(part1.get_answer("se,sw,se,sw,sw"), 3)
def test_part1(self): self.assertEqual(part1.perform_redistribution([0, 2, 7, 0]), [2, 4, 1, 2]) self.assertEqual(part1.perform_redistribution([2, 4, 1, 2]), [3, 1, 2, 3]) self.assertEqual(part1.perform_redistribution([3, 1, 2, 3]), [0, 2, 3, 4]) self.assertEqual(part1.perform_redistribution([0, 2, 3, 4]), [1, 3, 4, 1]) self.assertEqual(part1.perform_redistribution([1, 3, 4, 1]), [2, 4, 1, 2]) self.assertEqual(part1.get_answer([0, 2, 7, 0]), 5) self.assertEqual(part1.get_answer([1, 3, 4, 1]), 4)
def test_get_answer_part1(self): data = [ "pbga (66)", "xhth (57)", "ebii (61)", "havc (66)", "ktlj (57)", "fwft (72) -> ktlj, cntj, xhth", "qoyq (66)", "padx (45) -> pbga, havc, qoyq", "tknk (41) -> ugml, padx, fwft", "jptl (61)", "ugml (68) -> gyxo, ebii, jptl", "gyxo (61)", "cntj (57)" ] self.assertEqual(part1.get_answer(data), "tknk")
def test_part1(self): self.assertEqual(part1.do_move(['a', 'b', 'c', 'd', 'e'], "s3"), ['c', 'd', 'e', 'a', 'b']) self.assertEqual(part1.do_move(['a', 'b', 'c', 'd', 'e'], "s1"), ['e', 'a', 'b', 'c', 'd']) self.assertEqual(part1.do_move(['e', 'a', 'b', 'c', 'd'], "x3/4"), ['e', 'a', 'b', 'd', 'c']) self.assertEqual(part1.do_move(['e', 'a', 'b', 'd', 'c'], "pe/b"), ['b', 'a', 'e', 'd', 'c']) self.assertEqual(part1.get_answer(['s1', 'x3/4', 'pe/b'], "abcde"), 'baedc')
def test_part1(self): data=["0 <-> 2", "1 <-> 1", "2 <-> 0, 3, 4", "3 <-> 2, 4", "4 <-> 2, 3, 6", "5 <-> 6", "6 <-> 4, 5"] graph = part1.get_graph(data) self.assertEqual(part1.get_answer(data), 6) self.assertEqual(len(part1.get_reachable_from(graph, '1')), 1)
def test(self): self.assertEqual(part1.get_register("js inc 257 if wn < 9"), "js") self.assertEqual(part1.get_sign("js inc 257 if wn < 9"), 1) self.assertEqual(part1.get_sign("js dec 257 if wn < 9"), -1) self.assertEqual(part1.get_value("js dec 257 if wn < 9"), 257) self.assertEqual(part1.get_conditional_register("js dec 257 if wn < 9"), "wn") self.assertEqual(part1.get_conditional("js dec 257 if wn < 9"), "< 9") in_data =["b inc 5 if a > 1", "a inc 1 if b < 5", "c dec -10 if a >= 1", "c inc -20 if c == 10"] self.assertEqual(part1.get_answer(in_data), 1) self.assertEqual(part2.get_answer(in_data), 10)
def test(self): self.assertEqual(part1.get_answer("{}"), 1) self.assertEqual(part1.get_answer("{{{}}}"), 6) self.assertEqual(part1.get_answer("{{{},{},{{}}}}"), 16) self.assertEqual(part1.get_answer("{<a>,<a>,<a>,<a>}"), 1) self.assertEqual(part1.get_answer("{{<ab>},{<ab>},{<ab>},{<ab>}}"), 9) self.assertEqual(part1.get_answer("{{<!!>},{<!!>},{<!!>},{<!!>}}"), 9) self.assertEqual(part1.get_answer("{{<a!>},{<a!>},{<a!>},{<ab>}}"), 3) self.assertEqual( part1.get_answer( "{{<a!>},{<a!>},{<a!>},{<ab>}}{{<a!>},{<a!>},{<a!>},{<ab>}}"), 6) self.assertEqual(part1.get_answer("{{<!>},{<!>},{<!>},{<a>}}"), 3) self.assertEqual(part2.get_answer("<>"), 0) self.assertEqual(part2.get_answer("<random characters>"), 17) self.assertEqual(part2.get_answer("<<<<>"), 3) self.assertEqual(part2.get_answer("<{!>}>"), 2) self.assertEqual(part2.get_answer("<!!>"), 0) self.assertEqual(part2.get_answer("<!!!>>"), 0) self.assertEqual(part2.get_answer("<{o\"i!a,<{i<a>"), 10) self.assertEqual(part2.get_answer("{{<a>},{<a>},{<a>},{<a>}}"), 4)
def test(self): self.assertEqual(part1.get_answer([3, 4, 1, 5], 5), 12)
def test_part1(self): self.assertEqual(part1.lowest_16_bits_are_equal(245556042, 1431495498), True) self.assertEqual(part1.lowest_16_bits_are_equal(1092455, 430625591), False) self.assertEqual(part1.get_answer(65, 8921), 588)
def test_jumps(self): self.assertEqual(part1.get_answer([0, 3, 0, 1, -3]), 5) self.assertEqual(part1.get_answer([0]), 2) self.assertEqual(part2.get_answer([0, 3, 0, 1, -3]), 10)
def test_part1(self): data = ["0: 3", "1: 2", "4: 4", "6: 4"] self.assertEqual(part1.get_answer(data), 24)
def test_part1(self): self.assertEqual(part1.get_answer("flqrgnkx"), 8108)