advent_of_code_2021

My attempts to work through the 2021 Advent of Code problems.
git clone https://git.eamoncaddigan.net/advent_of_code_2021.git
Log | Files | Refs | README | LICENSE

commit c12bbbf0b1d86c50ccf9dc07a6354e42ed125bb7
parent 65d4a43f44d74070b4fe8e886383abe1aaa6f54a
Author: Eamon Caddigan <eamon.caddigan@gmail.com>
Date:   Tue, 14 Dec 2021 08:31:56 -0500

Added a word count helper so that I can get quick stats on the puzzle input

Diffstat:
Mutils.py | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/utils.py b/utils.py @@ -1,7 +1,7 @@ """A collection of utilities that should be useful for more than one puzzle.""" import os.path -from typing import Any +from typing import Any, Tuple import requests import numpy as np import pandas as pd @@ -16,6 +16,13 @@ def convert_int_line_to_series(input_string: str) -> pd.Series: integers to a pandas Series""" return pd.Series(input_string.rstrip().split(',')).astype(np.int64) +def wc(input_string: str) -> Tuple[int, int, int]: + """Returns the newline, word, and character counts of the given input + string""" + return (sum([1 for _ in input_string if _ == '\n']), + len(input_string.split()), + len(input_string)) + def get_puzzle_input(day_number: int, binary: bool = False) -> Any: """Downloads and returns the input data for the puzzle on a given day. Note: requires a 'session' cookie string to be stored in