Skip to content

Commit

Permalink
Add main function and its execution
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Katzuv committed Dec 2, 2021
1 parent 99d332e commit a3d954c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion 2021/d02/p2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Iterator

import directions
from p1 import Command
from p1 import INPUT_FILE_PATH, get_commands_from_input, Command


def get_position(commands: Iterator[Command], horizontal: int = 0, depth: int = 0, aim: int = 0) -> tuple[int, int]:
Expand All @@ -25,3 +25,16 @@ def get_position(commands: Iterator[Command], horizontal: int = 0, depth: int =
aim -= step

return horizontal, depth


def main():
input_text = INPUT_FILE_PATH.read_text()
measurements = get_commands_from_input(input_text)

horizontal_position, depth = get_position(measurements)
product = horizontal_position * depth
print(f"Product of the submarine's positional position with its depth: {product}")


if __name__ == '__main__':
main()

0 comments on commit a3d954c

Please sign in to comment.