mirror of
https://github.com/chylex/Advent-of-Code.git
synced 2025-05-31 18:34:07 +02:00
Add 2022 - Day 1 - Part 1
This commit is contained in:
parent
0fd3573077
commit
fb795c2a38
24
2022/.idea/runConfigurations/Day_01.xml
Normal file
24
2022/.idea/runConfigurations/Day_01.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Day 01" type="PythonConfigurationType" factoryName="Python">
|
||||
<module name="2022" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/01" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/01/main.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
2262
2022/01/input.txt
Normal file
2262
2022/01/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
12
2022/01/main.py
Normal file
12
2022/01/main.py
Normal file
@ -0,0 +1,12 @@
|
||||
from itertools import groupby
|
||||
|
||||
from utils.input import read_input
|
||||
|
||||
lines = read_input()
|
||||
groups = [list(group) for is_group, group in groupby(lines, lambda x: x != '') if is_group]
|
||||
|
||||
carrying_calories = ((int(item) for item in group) for group in groups)
|
||||
carrying_total_calories = (sum(group) for group in carrying_calories)
|
||||
most_calories_carried = max(carrying_total_calories)
|
||||
|
||||
print(f"Most calories carried: {most_calories_carried}")
|
3
2022/utils/input.py
Normal file
3
2022/utils/input.py
Normal file
@ -0,0 +1,3 @@
|
||||
def read_input() -> list[str]:
|
||||
with open("input.txt") as f:
|
||||
return [line.strip() for line in f.readlines()]
|
@ -55,3 +55,7 @@ The versions should not matter, but I used Visual Studio 2019 with `MSVC v142 (1
|
||||
| | | | / | 2020 | 06 | Rust | / | 2021 | 06 | Kotlin |
|
||||
| | | | / | 2020 | 07 | Rust | / | 2021 | 07 | Kotlin |
|
||||
| | | | / | 2020 | 08 | Rust | / | 2021 | 08 | Kotlin |
|
||||
|
||||
| Year | Day | Language |
|
||||
|-----:|----:|----------|
|
||||
| 2022 | 01 | Python |
|
||||
|
Loading…
Reference in New Issue
Block a user