def setUp(self):
     if self.module is None:
         raise NotImplementedError(
             "subclasses of TestSolution must provide module to test")
     if self.expected is None:
         raise NotImplementedError(
             "subclasses of TestSolution must provide expected value")
     self.input_path = SOLUTION_DIR.joinpath(self.input_filename)
     self.input_text = get_input(self.input_path)
Exemple #2
0
            most_consistent_guard = guard_id
            guards_most_slept_minute = sleepiest_minute

    return (most_consistent_guard, guards_most_slept_minute)


def solve(input_text):
    shifts = create_shift_objects(parse(input_text))
    sleep_times = guard_sleep_times(shifts)

    guard, minute = find_most_consistent_sleeper_and_minute(sleep_times)

    return guard * minute


if __name__ == '__main__':
    from shared.utils import get_input
    from timeit import default_timer as timer

    start = timer()

    input_path = Path(__file__).parent.joinpath("input.txt")
    input_text = get_input(input_path)
    solution = solve(input_text)
    print(solution)

    end = timer()
    print()
    print("-" * 80)
    print("Time elapsed: {:.3f}s".format(end - start))
Exemple #3
0
 def get_input(self, filename):
     input_path = SOLUTION_DIR.joinpath(filename)
     input_text = get_input(input_path)
     return input_text