def test_part_2(self): self.assertEqual(part2.get_list("1,2,3"), [49, 44, 50, 44, 51, 17, 31, 73, 47, 23]) self.assertEqual(part2.get_answer("1,2,3"), "3efbe78a8d82f29979031a4aa0b16a9d") self.assertEqual(part2.get_answer("1,2,4"), "63960835bcdc130f0b66d7ff4f6a5a8e") self.assertEqual(part2.get_answer("AoC 2017"), "33efeb34ea91902bb2f59c9920caa6cd") self.assertEqual(part2.get_answer(""), "a2582a3a0e66e6e86e3812dcb672a272")
def test_part_2(self): self.assertEqual(part2.get_weight("a (1) -> b, d"), 1) self.assertEqual(part2.get_weight("a (445)"), 445) 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)" ] graph, weights = part2.get_graph_and_weights(data) self.assertEqual(weights["gyxo"], 61) self.assertEqual(graph["gyxo"], []) self.assertEqual(graph["tknk"], ["ugml", "padx", "fwft"]) self.assertEqual(part2.get_total_weight(graph, weights, "ugml"), 251) self.assertEqual(part2.get_total_weight(graph, weights, "cntj"), 57) self.assertEqual(part2.is_balanced(graph, weights, "cntj"), True) self.assertEqual(part2.is_balanced(graph, weights, "ugml"), True) self.assertEqual(part2.is_balanced(graph, weights, "tknk"), False) self.assertEqual(part2.is_balanced(graph, weights, "padx"), True) self.assertEqual(part2.is_balanced(graph, weights, "fwft"), True) self.assertEqual(part2.is_balanced(graph, weights, "ktlj"), True) self.assertEqual(part2.get_answer(data), 60)
def test_part2(self): data=["0 <-> 2", "1 <-> 1", "2 <-> 0, 3, 4", "3 <-> 2, 4", "4 <-> 2, 3, 6", "5 <-> 6", "6 <-> 4, 5"] self.assertEqual(part2.get_answer(data), 2)
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_part2(self): self.assertEqual(part2.get_answer(65, 8921), 309)
def test_part2(self): a = [0, 2, 7, 0] part2.perform_redistribution(a) self.assertEqual(a, [2, 4, 1, 2]) self.assertEqual(part2.get_answer([0, 2, 7, 0]), 4)
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_part2(self): data = ["0: 3", "1: 2", "4: 4", "6: 4"] self.assertEqual(part2.get_answer(data), 10)
def test_part2(self): self.assertEqual(part2.get_answer("flqrgnkx"), 1242)