Day 3: Toboggan Trajectory

Classes:

InputLine(line)

Represent a line of the input map.

Functions:

parse_input(lines)

Parse the input map given as lines.

count_trees(width, height, input_string)

Count the trees in the input_string.

class InputLine(line: str)[source]

Represent a line of the input map.

parse_input(lines: Sequence[InputLine]) Tuple[int, int, str][source]

Parse the input map given as lines.

Requires
  • len(lines) > 0

  • all(
        len(line) == len(lines[0])
        for line in lines
    )
    
Ensures
  • result[0] * result[1] == len(result[2])

count_trees(width: int, height: int, input_string: str) int[source]

Count the trees in the input_string.

Requires
  • width * height == len(input_string)

  • re.match(r"^[.#]*", input_string)

  • width > 0 and height > 0

Ensures
  • result <= height / STEP_SIZE_VERTICAL