adventofcode.year_2021.day_2021_02.readable

Module Contents

Classes

Submarine

Abstraction for a submarine

SubmarineWithoutAim

A special submarine that moves following commands, without an aim.

SubmarineWithAim

A special submarine, the moves of which depend on its changing aim.

Functions

part1()

part2()

Attributes

commands

adventofcode.year_2021.day_2021_02.readable.commands
class adventofcode.year_2021.day_2021_02.readable.Submarine

Abstraction for a submarine

It’s only defined by its original position and how we compute the answer.

answer(self)

Give the answer to the challenge (horizontal position x depth)

Returns:

int: The answer

class adventofcode.year_2021.day_2021_02.readable.SubmarineWithoutAim

Bases: Submarine

A special submarine that moves following commands, without an aim.

move(self, command, value)

Move the submarine according to the command type and its value

Args:

command (str): The command given to the submarine, either ‘forward’ or ‘updown’ value (int): The number of space units to use for the command

class adventofcode.year_2021.day_2021_02.readable.SubmarineWithAim

Bases: Submarine

A special submarine, the moves of which depend on its changing aim.

move(self, command, value)

Move the submarine according to the command type and its value, using the aim

Args:

command (str): The command given to the submarine, either ‘forward’ or ‘updown’ value (int): The number of space units to use for the command

adventofcode.year_2021.day_2021_02.readable.part1()
adventofcode.year_2021.day_2021_02.readable.part2()