def test_down(self): tree_map = [] load_file_to_list('../Resources/Day3.txt', tree_map) fifth_count = Trees.count_trees_on_slope(1, 2, tree_map) print_debug("Fifth: " + str(fifth_count), 1) print_debug("", 1) self.assertEqual(fifth_count, 32)
def test_check_all(self): passwords_list = [] load_file_to_list('../Resources/Day2.txt', passwords_list) part_1 = Passwords.check_all(passwords_list, self.DEBUG_ON) print_debug("Day 2 - Part 1:", self.DEBUG_ON) print_debug(part_1, self.DEBUG_ON) self.assertEqual(part_1, 477)
def test_valid_passports_1(self): raw_passports = [] passport_list = [Passport()] load_file_to_list('../Resources/Day4.txt', raw_passports) valid_passport_counter = 0 Passports.populate_from_raw(raw_passports, passport_list) for k in range(len(passport_list)): if passport_list[k].is_passport_valid_1(): valid_passport_counter += 1 print_debug("", 1) print_debug("***********************************", 1) print_debug("Day4 - Passport Processing: Part2 ", 1) print_debug("The counts of valid passports is: ", 1) print_debug(str(valid_passport_counter), 1) self.assertEqual(valid_passport_counter, 256)
def test_get_sorted_seats(self): boarding_passes = [] load_file_to_list('../Resources/Day5.txt', boarding_passes) sorted_seats = BoardingPass.get_sorted_seats(boarding_passes) print_debug("***********************************", 1) print_debug("Day5 - Binary Boarding: Part1 ", 1) print_debug("The highest seat is: ") print_debug(str(sorted_seats[0]))
def test_get_unanimous(self): form_list = [] my_form = Forms load_file_to_list('../Resources/Day6.txt', form_list) my_form.get_groups(my_form, form_list) print_debug("***********************************", 1) print_debug("Day6 - Custom Customs: Part1 ", 1) print_debug("The count of answers is: ") print_debug(str(my_form.get_yes_counts(my_form, False)), 1)
def test_boot_bug_finder(self): instruction_list = [] path = '../Resources/Day8.txt' load_file_to_list(path, instruction_list) my_boot = Boots bug_line = my_boot.boot_bug_finder(my_boot, instruction_list) print_debug("***********************************", self.DEBUG_ON) print_debug("Day8 - Handheld Halting: Part2 ", self.DEBUG_ON) print_debug("The bug is on line: ", self.DEBUG_ON) print_debug(bug_line, self.DEBUG_ON) self.assertTrue(bug_line, 224)
def test_boot(self): instruction_list = [] path = '../Resources/Day8.txt' load_file_to_list(path, instruction_list) my_boot = Boots my_boot.boot(my_boot, instruction_list) print_debug("***********************************", self.DEBUG_ON) print_debug("Day8 - Handheld Halting: Part1 ", self.DEBUG_ON) print_debug("The value of the accumulator is: ", self.DEBUG_ON) accumulator = my_boot.get_accumulator(my_boot) print_debug(accumulator, self.DEBUG_ON) self.assertTrue(accumulator, 1654)
def test_fix_and_boot(self): instruction_list = [] path = '../Resources/Day8.txt' load_file_to_list(path, instruction_list) my_boot = Boots bug_line = my_boot.boot_bug_finder(my_boot, instruction_list) bug_line -= 1 my_boot.fix_bug(my_boot, instruction_list, bug_line) my_boot.boot(my_boot, instruction_list) print_debug("***********************************", self.DEBUG_ON) print_debug("Day8 - Handheld Halting: Part2 ", self.DEBUG_ON) print_debug("The value of the accumulator once the bug is fixed is: ", self.DEBUG_ON) accumulator = my_boot.get_accumulator(my_boot) print_debug(accumulator, self.DEBUG_ON) self.assertTrue(accumulator, 833)
def test_part1(self): expense_list = [] my_sum = Sums() print_debug("Loading Day 1 data", self.DEBUG_ON) load_file_to_list('../Resources/Day1.txt', expense_list) print_debug( "Day 1 Part 1: Running find_sum for target: 2020 and combination of 2 numbers", self.DEBUG_ON) return_list = my_sum.find_sum(2020, list(map(int, expense_list)), 2) print_debug(return_list, self.DEBUG_ON) self.assertEqual(return_list[0], 1882) self.assertEqual(return_list[1], 138) self.assertEqual(return_list[2], 259716)
def test_across(self): tree_map = [] load_file_to_list('../Resources/Day3.txt', tree_map) first_count = Trees.count_trees_on_slope(1, 1, tree_map) second_count = Trees.count_trees_on_slope(3, 1, tree_map) third_count = Trees.count_trees_on_slope(5, 1, tree_map) fourth_count = Trees.count_trees_on_slope(7, 1, tree_map) print_debug("***********************************", 1) print_debug("Day3 - Toboggan Trajectory: Part1 ", 1) print_debug("The counts of #'s encountered are: ", 1) print_debug("First: " + str(first_count), 1) print_debug("", 1) print_debug("Second: " + str(second_count), 1) print_debug("", 1) print_debug("Third: " + str(third_count), 1) print_debug("", 1) print_debug("Fourth: " + str(fourth_count), 1) print_debug("", 1) print_debug("For the Slope: Right 3, Down 1 the count of trees encountered is :", 1) print_debug(second_count, 1) self.assertEqual(second_count, 191)
def test_across_down(self): tree_map = [] load_file_to_list('../Resources/Day3.txt', tree_map) first_count = Trees.count_trees_on_slope(1, 1, tree_map) second_count = Trees.count_trees_on_slope(3, 1, tree_map) third_count = Trees.count_trees_on_slope(5, 1, tree_map) fourth_count = Trees.count_trees_on_slope(7, 1, tree_map) fifth_count = Trees.count_trees_on_slope(1, 2, tree_map) print_debug("", 1) print_debug("***********************************", 1) print_debug("Day3 - Toboggan Trajectory: Part2 ", 1) print_debug("The counts of #'s encountered are: ", 1) print_debug("First: " + str(first_count), 1) print_debug("", 1) print_debug("Second: " + str(second_count), 1) print_debug("", 1) print_debug("Third: " + str(third_count), 1) print_debug("", 1) print_debug("Fourth: " + str(fourth_count), 1) print_debug("", 1) print_debug("Fifth: " + str(fifth_count), 1) print_debug("", 1) print_debug("If you multiply the counts for each slope you get:", 1) test_product = first_count * second_count * third_count * fourth_count * fifth_count print_debug("Total Product = " + str(test_product), 1) self.assertEqual(test_product, 1478615040)