├── 2015 ├── 10 │ ├── .meta │ └── main.py ├── 11 │ ├── .meta │ └── main.py ├── 12 │ ├── .meta │ └── main.py ├── 13 │ ├── .meta │ └── main.py ├── 14 │ ├── .meta │ └── main.py ├── 15 │ ├── .meta │ └── main.py ├── 16 │ ├── .meta │ └── main.py ├── 17 │ ├── .meta │ ├── main.py │ └── 17.md ├── 18 │ ├── .meta │ └── main.py ├── 19 │ └── .meta ├── 20 │ ├── .meta │ └── main.py ├── 21 │ ├── .meta │ ├── short.py │ └── main.py ├── 22 │ └── .meta ├── 23 │ ├── .meta │ └── main.py ├── 24 │ ├── .meta │ └── main.py ├── 25 │ ├── .meta │ └── main.py ├── .meta ├── 01 │ ├── .meta │ └── main.py ├── 02 │ ├── .meta │ └── main.py ├── 03 │ ├── .meta │ └── main.py ├── 04 │ ├── .meta │ ├── main.py │ └── 4.md ├── 05 │ ├── .meta │ └── main.py ├── 06 │ ├── .meta │ └── main.py ├── 07 │ ├── .meta │ └── main.py ├── 08 │ ├── .meta │ └── main.py └── 09 │ ├── .meta │ └── main.py ├── 2016 ├── 10 │ └── .meta ├── 11 │ └── .meta ├── 12 │ ├── .meta │ └── main.py ├── 13 │ └── .meta ├── 14 │ └── .meta ├── 15 │ ├── .meta │ └── main.py ├── 16 │ ├── .meta │ └── main.py ├── 17 │ └── .meta ├── 18 │ ├── .meta │ └── main.py ├── 19 │ ├── .meta │ └── main.py ├── 20 │ ├── .meta │ └── main.py ├── 21 │ └── .meta ├── 22 │ └── .meta ├── 23 │ └── .meta ├── 24 │ └── .meta ├── 25 │ └── .meta ├── .meta ├── 01 │ ├── .meta │ └── main.py ├── 02 │ ├── .meta │ └── main.py ├── 03 │ ├── .meta │ ├── main.py │ └── 3.md ├── 04 │ ├── .meta │ └── main.py ├── 05 │ ├── .meta │ └── main.py ├── 06 │ ├── .meta │ └── main.py ├── 07 │ ├── .meta │ └── main.py ├── 08 │ └── .meta └── 09 │ ├── .meta │ └── main.py ├── 2017 ├── 10 │ ├── .meta │ └── main.py ├── 11 │ ├── .meta │ └── 11.md ├── 12 │ ├── .meta │ └── main.py ├── 13 │ ├── .meta │ └── main.py ├── 14 │ └── .meta ├── 15 │ ├── .meta │ └── main.py ├── 16 │ ├── .meta │ └── main.py ├── 17 │ ├── .meta │ └── main.py ├── 18 │ └── .meta ├── 19 │ ├── .meta │ └── main.py ├── 20 │ ├── .meta │ └── main.py ├── 21 │ ├── .meta │ └── main.py ├── 22 │ ├── .meta │ └── main.py ├── 23 │ ├── .meta │ ├── op.txt │ └── op.org.txt ├── 24 │ ├── .meta │ └── main.py ├── 25 │ ├── .meta │ └── main.py ├── .meta ├── 01 │ ├── .meta │ └── main.py ├── 02 │ ├── .meta │ └── main.py ├── 03 │ ├── .meta │ └── main.py ├── 04 │ ├── .meta │ └── main.py ├── 05 │ ├── .meta │ └── main.py ├── 06 │ ├── .meta │ └── main.py ├── 07 │ └── .meta ├── 08 │ └── .meta └── 09 │ ├── .meta │ └── main.py ├── 2018 ├── 10 │ └── .meta ├── 11 │ ├── .meta │ └── main.py ├── 12 │ └── .meta ├── 13 │ └── .meta ├── 14 │ └── .meta ├── 15 │ └── .meta ├── 16 │ └── .meta ├── 17 │ └── .meta ├── 18 │ └── .meta ├── 19 │ ├── .meta │ └── main.py ├── 20 │ └── .meta ├── 21 │ ├── .meta │ └── main.py ├── 22 │ └── .meta ├── 23 │ ├── .meta │ └── main.py ├── 24 │ └── .meta ├── 25 │ ├── .meta │ └── main.py ├── .meta ├── 01 │ ├── .meta │ └── main.py ├── 02 │ ├── .meta │ └── main.py ├── 03 │ ├── .meta │ └── main.py ├── 04 │ └── .meta ├── 05 │ ├── .meta │ └── main.py ├── 06 │ └── .meta ├── 07 │ └── .meta ├── 08 │ ├── .meta │ └── main.py └── 09 │ └── .meta ├── 2019 ├── 10 │ └── .meta ├── 11 │ └── .meta ├── 12 │ └── .meta ├── 13 │ └── .meta ├── 14 │ └── .meta ├── 15 │ └── .meta ├── 16 │ ├── .meta │ └── tmp.py ├── 17 │ └── .meta ├── 18 │ └── .meta ├── 19 │ └── .meta ├── 20 │ └── .meta ├── 21 │ └── .meta ├── 22 │ └── .meta ├── 23 │ └── .meta ├── 24 │ └── .meta ├── 25 │ └── .meta ├── .meta ├── 01 │ ├── .meta │ └── main.py ├── 02 │ ├── .meta │ └── main.py ├── 03 │ └── .meta ├── 04 │ └── .meta ├── 05 │ └── .meta ├── 06 │ └── .meta ├── 07 │ └── .meta ├── 08 │ ├── .meta │ └── main.py └── 09 │ └── .meta ├── 2020 ├── 10 │ └── .meta ├── 11 │ └── .meta ├── 12 │ └── .meta ├── 13 │ ├── .meta │ └── main.py ├── 14 │ └── .meta ├── 15 │ ├── .meta │ └── main.py ├── 16 │ └── .meta ├── 17 │ ├── .meta │ └── main.py ├── 18 │ └── .meta ├── 19 │ └── .meta ├── 20 │ └── .meta ├── 21 │ └── .meta ├── 22 │ ├── .meta │ └── main.py ├── 23 │ └── .meta ├── 24 │ └── .meta ├── 25 │ ├── .meta │ └── main.py ├── .meta ├── 01 │ ├── .meta │ └── main.py ├── 02 │ ├── .meta │ └── main.py ├── 03 │ ├── .meta │ └── main.py ├── 04 │ └── .meta ├── 05 │ ├── .meta │ └── main.py ├── 06 │ ├── .meta │ └── main.py ├── 07 │ └── .meta ├── 08 │ └── .meta └── 09 │ └── .meta ├── 2021 ├── 10 │ ├── .meta │ └── main.py ├── 11 │ ├── .meta │ └── main.py ├── 12 │ └── .meta ├── 13 │ ├── .meta │ └── img.png ├── 14 │ ├── .meta │ └── main.py ├── 15 │ └── .meta ├── 16 │ └── .meta ├── 17 │ ├── .meta │ └── main.py ├── 18 │ └── .meta ├── 19 │ └── .meta ├── 20 │ ├── .meta │ └── main.py ├── 21 │ └── .meta ├── 22 │ └── .meta ├── 23 │ └── .meta ├── 24 │ └── .meta ├── 25 │ ├── .meta │ └── main.py ├── .meta ├── 01 │ ├── .meta │ └── main.py ├── 02 │ ├── .meta │ └── main.py ├── 03 │ ├── .meta │ └── main.py ├── 04 │ └── .meta ├── 05 │ ├── .meta │ └── main.py ├── 06 │ ├── .meta │ └── main.py ├── 07 │ ├── .meta │ └── main.py ├── 08 │ └── .meta └── 09 │ └── .meta ├── 2022 ├── 10 │ └── .meta ├── 11 │ └── .meta ├── 12 │ └── .meta ├── 13 │ └── .meta ├── 14 │ └── .meta ├── 15 │ ├── .meta │ └── thinking.txt ├── 16 │ ├── .meta │ ├── sorted.txt │ └── optimal.txt ├── 17 │ └── .meta ├── 18 │ └── .meta ├── 19 │ └── .meta ├── 20 │ └── .meta ├── 21 │ └── .meta ├── 22 │ └── .meta ├── 23 │ └── .meta ├── 24 │ └── .meta ├── 25 │ └── .meta ├── .meta ├── 04 │ ├── .meta │ └── main.py ├── 05 │ └── .meta ├── 06 │ ├── .meta │ └── main.py ├── 07 │ └── .meta ├── 08 │ └── .meta ├── 09 │ └── .meta ├── 01 │ ├── .meta │ └── main.py ├── 02 │ ├── .meta │ └── main.py ├── 2022.md └── 03 │ └── main.py ├── 2023 ├── 10 │ └── .meta ├── 11 │ └── .meta ├── 12 │ └── .meta ├── 13 │ └── .meta ├── 14 │ └── .meta ├── 15 │ └── .meta ├── 16 │ └── .meta ├── 17 │ ├── .meta │ └── test.py ├── 18 │ └── .meta ├── 19 │ └── .meta ├── 20 │ └── .meta ├── 21 │ └── .meta ├── 22 │ └── .meta ├── 23 │ └── .meta ├── 24 │ └── .meta ├── 25 │ └── .meta ├── .meta ├── 01 │ ├── .meta │ └── main.py ├── 02 │ ├── .meta │ └── main.py ├── 03 │ └── .meta ├── 04 │ └── .meta ├── 05 │ └── .meta ├── 06 │ ├── .meta │ └── main.py ├── 07 │ └── .meta ├── 08 │ └── .meta └── 09 │ └── .meta ├── 2024 ├── 10 │ └── .meta ├── 11 │ └── .meta ├── 12 │ └── .meta ├── 13 │ ├── .meta │ └── tmp.py ├── 14 │ └── .meta ├── 15 │ └── .meta ├── 16 │ └── .meta ├── 17 │ ├── .meta │ └── tmp.py ├── 18 │ └── .meta ├── 19 │ └── .meta ├── 20 │ └── .meta ├── 21 │ └── .meta ├── 22 │ └── .meta ├── 23 │ └── .meta ├── 24 │ └── .meta ├── 25 │ └── .meta ├── .meta ├── 01 │ └── .meta ├── 02 │ └── .meta ├── 03 │ └── .meta ├── 04 │ └── .meta ├── 05 │ └── .meta ├── 06 │ └── .meta ├── 07 │ └── .meta ├── 08 │ └── .meta └── 09 │ └── .meta ├── 2025 ├── 10 │ ├── .meta │ ├── tsconfig.json │ └── package.json ├── 11 │ ├── .meta │ ├── package.json │ └── bun.lock ├── 12 │ ├── .meta │ ├── tsconfig.json │ ├── package.json │ ├── .vscode │ │ └── launch.json │ └── solve.ts ├── .gitignore ├── .meta ├── 08 │ ├── fulllogs.txt │ ├── .meta │ ├── package.json │ └── bun.lock ├── 01 │ ├── .meta │ ├── package.json │ ├── solve.ts │ └── bun.lock ├── 02 │ ├── .meta │ ├── package.json │ ├── bun.lock │ └── solve.ts ├── 03 │ ├── .meta │ ├── package.json │ ├── bun.lock │ └── solve.ts ├── 04 │ ├── .meta │ ├── package.json │ └── bun.lock ├── 05 │ ├── .meta │ ├── package.json │ └── bun.lock ├── 06 │ ├── .meta │ ├── package.json │ ├── bun.lock │ └── solve.ts ├── 07 │ ├── .meta │ ├── package.json │ └── bun.lock ├── 09 │ ├── .meta │ ├── package.json │ └── bun.lock └── claude.sh ├── .vscode └── settings.json ├── .gitignore ├── req-manual.txt ├── next.sh └── req.txt /2025/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /2023/.meta: -------------------------------------------------------------------------------- 1 | dir=>ROOT 2 | year=>2023 3 | -------------------------------------------------------------------------------- /2024/.meta: -------------------------------------------------------------------------------- 1 | dir=>ROOT 2 | year=>2024 3 | -------------------------------------------------------------------------------- /2025/.meta: -------------------------------------------------------------------------------- 1 | dir=>ROOT 2 | year=>2025 3 | -------------------------------------------------------------------------------- /2025/08/fulllogs.txt: -------------------------------------------------------------------------------- 1 | Correct! Part 2 complete. 2 | -------------------------------------------------------------------------------- /2015/.meta: -------------------------------------------------------------------------------- 1 | dir=>ROOT 2 | user=>main 3 | year=>2015 4 | -------------------------------------------------------------------------------- /2016/.meta: -------------------------------------------------------------------------------- 1 | dir=>ROOT 2 | user=>main 3 | year=>2016 4 | -------------------------------------------------------------------------------- /2017/.meta: -------------------------------------------------------------------------------- 1 | dir=>ROOT 2 | user=>main 3 | year=>2017 4 | -------------------------------------------------------------------------------- /2018/.meta: -------------------------------------------------------------------------------- 1 | dir=>ROOT 2 | user=>main 3 | year=>2018 4 | -------------------------------------------------------------------------------- /2019/.meta: -------------------------------------------------------------------------------- 1 | dir=>ROOT 2 | user=>main 3 | year=>2019 4 | -------------------------------------------------------------------------------- /2020/.meta: -------------------------------------------------------------------------------- 1 | dir=>ROOT 2 | user=>main 3 | year=>2020 4 | -------------------------------------------------------------------------------- /2021/.meta: -------------------------------------------------------------------------------- 1 | dir=>ROOT 2 | user=>main 3 | year=>2021 4 | -------------------------------------------------------------------------------- /2022/.meta: -------------------------------------------------------------------------------- 1 | dir=>ROOT 2 | user=>main 3 | year=>2022 4 | -------------------------------------------------------------------------------- /2022/04/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>4 4 | part=>2 5 | -------------------------------------------------------------------------------- /2022/05/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>5 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/06/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>6 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/07/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>7 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/08/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>8 4 | part=>1 5 | -------------------------------------------------------------------------------- /2022/09/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>9 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/10/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>10 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/11/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>11 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/12/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>12 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/13/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>13 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/14/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>14 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/15/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>15 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/16/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>16 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/17/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>17 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/18/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>18 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/19/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>19 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/20/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>20 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/21/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>21 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/22/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>22 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/23/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>23 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/24/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>24 4 | part=>3 5 | -------------------------------------------------------------------------------- /2022/25/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2022 3 | day=>25 4 | part=>1 5 | -------------------------------------------------------------------------------- /2023/01/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>1 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/02/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>2 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/03/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>3 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/04/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>4 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/05/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>5 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/06/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>6 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/07/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>7 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/08/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>8 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/09/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>9 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/10/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>10 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/11/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>11 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/12/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>12 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/13/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>13 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/14/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>14 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/15/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>15 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/16/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>16 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/17/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>17 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/18/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>18 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/19/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>19 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/20/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>20 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/21/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>21 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/22/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>22 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/23/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>23 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/24/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>24 4 | part=>3 5 | -------------------------------------------------------------------------------- /2023/25/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2023 3 | day=>25 4 | part=>1 5 | -------------------------------------------------------------------------------- /2024/01/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>1 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/02/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>2 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/03/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>3 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/04/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>4 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/05/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>5 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/06/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>6 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/07/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>7 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/08/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>8 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/09/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>9 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/10/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>10 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/11/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>11 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/12/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>12 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/13/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>13 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/14/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>14 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/15/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>15 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/16/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>16 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/17/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>17 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/18/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>18 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/19/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>19 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/20/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>20 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/21/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>21 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/22/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>22 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/23/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>23 4 | part=>3 5 | -------------------------------------------------------------------------------- /2024/24/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>24 4 | part=>2 5 | -------------------------------------------------------------------------------- /2024/25/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2024 3 | day=>25 4 | part=>2 5 | -------------------------------------------------------------------------------- /2025/01/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2025 3 | day=>1 4 | part=>3 5 | -------------------------------------------------------------------------------- /2025/02/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2025 3 | day=>2 4 | part=>2 5 | -------------------------------------------------------------------------------- /2025/03/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2025 3 | day=>3 4 | part=>2 5 | -------------------------------------------------------------------------------- /2025/04/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2025 3 | day=>4 4 | part=>2 5 | -------------------------------------------------------------------------------- /2025/05/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2025 3 | day=>5 4 | part=>3 5 | -------------------------------------------------------------------------------- /2025/06/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2025 3 | day=>6 4 | part=>3 5 | -------------------------------------------------------------------------------- /2025/07/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2025 3 | day=>7 4 | part=>3 5 | -------------------------------------------------------------------------------- /2025/08/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2025 3 | day=>8 4 | part=>3 5 | -------------------------------------------------------------------------------- /2025/09/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2025 3 | day=>9 4 | part=>3 5 | -------------------------------------------------------------------------------- /2025/10/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2025 3 | day=>10 4 | part=>3 5 | -------------------------------------------------------------------------------- /2025/11/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2025 3 | day=>11 4 | part=>3 5 | -------------------------------------------------------------------------------- /2025/12/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | year=>2025 3 | day=>12 4 | part=>2 5 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.formatting.provider": "black" 3 | } -------------------------------------------------------------------------------- /2015/01/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>1 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/02/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>2 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/03/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>3 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/04/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>4 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/05/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>5 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/06/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>6 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/07/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>7 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/08/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>8 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/09/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>9 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/10/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>10 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/11/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>11 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/12/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>12 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/13/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>13 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/14/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>14 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/15/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>15 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/16/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>16 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/17/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>17 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/18/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>18 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/19/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>19 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/20/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>20 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/21/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>21 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/22/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>22 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/23/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>23 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/24/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>24 5 | part=>3 6 | -------------------------------------------------------------------------------- /2015/25/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2015 4 | day=>25 5 | part=>2 6 | -------------------------------------------------------------------------------- /2016/01/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>1 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/02/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>2 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/03/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>3 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/04/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>4 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/05/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>5 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/06/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>6 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/07/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>7 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/08/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>8 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/09/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>9 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/10/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>10 5 | part=>2 6 | -------------------------------------------------------------------------------- /2016/11/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>11 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/12/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>12 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/13/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>13 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/14/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>14 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/15/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>15 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/16/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>16 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/17/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>17 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/18/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>18 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/19/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>19 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/20/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>20 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/21/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>21 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/22/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>22 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/23/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>23 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/24/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>24 5 | part=>3 6 | -------------------------------------------------------------------------------- /2016/25/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2016 4 | day=>25 5 | part=>2 6 | -------------------------------------------------------------------------------- /2017/01/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>1 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/02/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>2 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/03/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>3 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/04/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>4 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/05/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>5 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/06/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>6 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/07/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>7 5 | part=>1 6 | -------------------------------------------------------------------------------- /2017/08/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>8 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/09/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>9 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/10/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>10 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/11/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>11 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/12/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>12 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/13/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>13 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/14/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>14 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/15/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>15 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/16/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>16 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/17/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>17 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/18/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>18 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/19/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>19 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/20/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>20 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/21/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>21 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/22/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>22 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/23/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>23 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/24/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>24 5 | part=>3 6 | -------------------------------------------------------------------------------- /2017/25/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2017 4 | day=>25 5 | part=>2 6 | -------------------------------------------------------------------------------- /2018/01/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>1 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/02/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>2 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/03/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>3 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/04/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>4 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/05/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>5 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/06/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>6 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/07/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>7 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/08/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>8 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/09/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>9 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/10/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>10 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/11/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>11 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/12/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>12 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/13/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>13 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/14/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>14 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/15/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>15 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/16/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>16 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/17/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>17 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/18/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>18 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/19/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>19 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/20/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>20 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/21/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>21 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/22/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>22 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/23/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>23 5 | part=>3 6 | -------------------------------------------------------------------------------- /2018/24/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>24 5 | part=>1 6 | -------------------------------------------------------------------------------- /2018/25/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2018 4 | day=>25 5 | part=>2 6 | -------------------------------------------------------------------------------- /2019/01/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>1 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/02/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>2 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/03/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>3 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/04/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>4 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/05/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>5 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/06/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>6 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/07/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>7 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/08/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>8 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/09/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>9 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/10/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>10 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/11/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>11 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/12/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>12 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/13/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>13 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/14/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>14 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/15/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>15 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/16/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>16 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/17/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>17 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/18/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>18 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/19/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>19 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/20/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>20 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/21/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>21 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/22/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>22 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/23/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>23 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/24/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>24 5 | part=>3 6 | -------------------------------------------------------------------------------- /2019/25/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2019 4 | day=>25 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/01/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>1 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/02/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>2 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/03/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>3 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/04/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>4 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/05/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>5 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/06/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>6 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/07/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>7 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/08/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>8 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/09/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>9 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/10/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>10 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/11/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>11 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/12/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>12 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/13/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>13 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/14/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>14 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/15/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>15 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/16/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>16 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/17/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>17 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/18/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>18 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/19/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>19 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/20/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>20 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/21/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>21 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/22/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>22 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/23/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>23 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/24/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>24 5 | part=>3 6 | -------------------------------------------------------------------------------- /2020/25/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2020 4 | day=>25 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/01/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>1 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/02/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>2 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/03/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>3 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/04/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>4 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/05/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>5 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/06/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>6 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/07/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>7 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/08/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>8 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/09/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>9 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/10/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>10 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/11/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>11 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/12/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>12 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/13/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>13 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/14/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>14 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/15/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>15 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/16/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>16 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/17/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>17 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/18/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>18 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/19/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>19 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/20/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>20 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/21/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>21 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/22/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>22 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/23/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>23 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/24/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>24 5 | part=>3 6 | -------------------------------------------------------------------------------- /2021/25/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2021 4 | day=>25 5 | part=>3 6 | -------------------------------------------------------------------------------- /2022/01/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2022 4 | day=>1 5 | part=>3 6 | -------------------------------------------------------------------------------- /2022/02/.meta: -------------------------------------------------------------------------------- 1 | dir=>DAY 2 | user=>main 3 | year=>2022 4 | day=>2 5 | part=>1 6 | -------------------------------------------------------------------------------- /2021/13/img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yspreen/adventofcode/HEAD/2021/13/img.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.pyenv/ 2 | .DS_Store 3 | *.pyc 4 | .aoc.secret 5 | 6 | .answers.log 7 | input 8 | -------------------------------------------------------------------------------- /2025/01/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": {}, 3 | "devDependencies": { 4 | "@types/bun": "^1.3.4" 5 | } 6 | } -------------------------------------------------------------------------------- /2025/02/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": {}, 3 | "devDependencies": { 4 | "@types/bun": "^1.3.4" 5 | } 6 | } -------------------------------------------------------------------------------- /2025/03/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": {}, 3 | "devDependencies": { 4 | "@types/bun": "^1.3.4" 5 | } 6 | } -------------------------------------------------------------------------------- /2025/04/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": {}, 3 | "devDependencies": { 4 | "@types/bun": "^1.3.4" 5 | } 6 | } -------------------------------------------------------------------------------- /2025/05/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": {}, 3 | "devDependencies": { 4 | "@types/bun": "^1.3.4" 5 | } 6 | } -------------------------------------------------------------------------------- /2025/06/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": {}, 3 | "devDependencies": { 4 | "@types/bun": "^1.3.4" 5 | } 6 | } -------------------------------------------------------------------------------- /2025/07/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": {}, 3 | "devDependencies": { 4 | "@types/bun": "^1.3.4" 5 | } 6 | } -------------------------------------------------------------------------------- /2025/08/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": {}, 3 | "devDependencies": { 4 | "@types/bun": "^1.3.4" 5 | } 6 | } -------------------------------------------------------------------------------- /2025/09/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": {}, 3 | "devDependencies": { 4 | "@types/bun": "^1.3.4" 5 | } 6 | } -------------------------------------------------------------------------------- /2025/11/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": {}, 3 | "devDependencies": { 4 | "@types/bun": "^1.3.4" 5 | } 6 | } -------------------------------------------------------------------------------- /req-manual.txt: -------------------------------------------------------------------------------- 1 | black 2 | Cython 3 | httpx 4 | llist 5 | numpy 6 | Pillow 7 | sympy 8 | scipy 9 | z3-solver 10 | vulture 11 | -------------------------------------------------------------------------------- /2022/16/sorted.txt: -------------------------------------------------------------------------------- 1 | 03 MJ 2 | 04 AC 3 | 06 KW 4 | 08 OU 5 | 10 OI 6 | 11 ID 7 | 13 DI 8 | 15 RH 9 | 18 BO 10 | 19 TO 11 | 21 KL 12 | 22 YS 13 | 23 DY 14 | 24 DT 15 | 25 CD 16 | -------------------------------------------------------------------------------- /2022/01/main.py: -------------------------------------------------------------------------------- 1 | f = open("input") 2 | elves = f.read().split("\n\n") 3 | elves = list(map(lambda e: list(map(int, e.splitlines())), elves)) 4 | elves = list(map(sum, elves)) 5 | print(max(elves)) 6 | print(sum(sorted(elves)[-3:])) 7 | -------------------------------------------------------------------------------- /2025/12/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES5", 4 | "module": "CommonJS", 5 | "outDir": "out", 6 | "sourceMap": true, 7 | "skipLibCheck": true 8 | }, 9 | "include": ["solve.ts"] 10 | } -------------------------------------------------------------------------------- /2015/01/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | with open(pathlib.Path(__file__).parent.absolute() / "input") as f: 4 | s = f.read() 5 | print(s.count("(") - s.count(")")) 6 | print([i for i in range(len(s)) if s[:i].count("(") - s[:i].count(")") == -1][0]) 7 | -------------------------------------------------------------------------------- /2025/10/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2022", 4 | "module": "esnext", 5 | "strictNullChecks": true, 6 | "moduleResolution": "bundler" 7 | }, 8 | 9 | "include": ["solve.ts"] 10 | 11 | } -------------------------------------------------------------------------------- /2017/23/op.txt: -------------------------------------------------------------------------------- 1 | $B = 108400 2 | $C = 125400 3 | $D = 0 4 | $E = 0 5 | 6 | WHILE TRUE: 7 | $F = 1 8 | $D = 2 9 | WHILE $D != $B: 10 | $E = $B 11 | 12 | IF $D * $E == $B: 13 | $F = 0 14 | 15 | $D += 1 16 | 17 | IF $F == 0: 18 | $H += 1 19 | IF $B == $C: 20 | return 21 | $B += 17 22 | -------------------------------------------------------------------------------- /next.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | main() { 4 | ( ! ([ -f ./.meta ] || [ -f ../.meta ])) && return 5 | [ "$(cat .meta | head -1)" = 'dir=>DAY' ] && cd .. 6 | n=$(ls -1 | grep -E '^\d{2}$' | sort | tail -1 || echo "00") 7 | n=$((n + 1)) 8 | aoc -d $n 9 | cd "$(printf "%02d" $n)" 10 | cp ../../template.py ./main.py 11 | code $n.md input main.py 12 | } 13 | main 14 | -------------------------------------------------------------------------------- /2025/10/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "glpk.js": "^4.0.2" 4 | }, 5 | "devDependencies": { 6 | "@eslint/eslintrc": "^3.3.3", 7 | "@types/bun": "^1.3.4", 8 | "eslint": "^9.39.2", 9 | "eslint-config-next": "^16.1.0", 10 | "eslint-config-prettier": "^10.1.8", 11 | "eslint-plugin-drizzle": "^0.2.3", 12 | "eslint-plugin-prettier": "^5.5.4", 13 | "next": "^16.1.0", 14 | "typescript-eslint": "^8.50.0" 15 | } 16 | } -------------------------------------------------------------------------------- /2025/12/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "glpk.js": "^4.0.2" 4 | }, 5 | "devDependencies": { 6 | "@eslint/eslintrc": "^3.3.3", 7 | "@types/bun": "^1.3.4", 8 | "eslint": "^9.39.2", 9 | "eslint-config-next": "^16.1.0", 10 | "eslint-config-prettier": "^10.1.8", 11 | "eslint-plugin-drizzle": "^0.2.3", 12 | "eslint-plugin-prettier": "^5.5.4", 13 | "next": "^16.1.0", 14 | "typescript-eslint": "^8.50.0" 15 | } 16 | } -------------------------------------------------------------------------------- /2018/01/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | input = list( 4 | map(int, open(pathlib.Path(__file__).parent / "input").read().splitlines()) 5 | ) 6 | 7 | currents = dict() 8 | current = 0 9 | done = False 10 | print(sum(input)) 11 | while not done: 12 | for i in input: 13 | current += i 14 | if currents.get(current, False): 15 | print(current) 16 | done = True 17 | break 18 | currents[current] = True 19 | -------------------------------------------------------------------------------- /2022/2022.md: -------------------------------------------------------------------------------- 1 | Year 2022: 4/50 * 2 | -------------------------------------------------------------- 3 | -~------' ~ ~ '--~-----~-~----___________-- 2 ** 4 | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 1 ** 5 | 6 | --------Part 1--------- --------Part 2--------- 7 | Day Time Rank Score Time Rank Score 8 | 2 15:19:24 103642 0 15:22:55 96908 0 9 | 1 >24h 151766 0 >24h 145716 0 10 | -------------------------------------------------------------------------------- /2025/claude.sh: -------------------------------------------------------------------------------- 1 | ls -1 | grep -v claude | grep -v 02 | grep -v 01 | grep -v 12 | while read n 2 | do 3 | cd $n 4 | cat .meta | grep 'part=>1' && echo solving $n && claude --dangerously-skip-permissions -p "Please try to solve the first part of the puzzle in the markdown file in this directory. Read $n.md, Write code in solve.ts to solve the first part, Run `bun solve.ts` to run your code. Once you've got the answer, run "'`aoc -s "$answer"`'" to see if you're right." || echo $n solved already & 5 | cd .. 6 | done -------------------------------------------------------------------------------- /2021/06/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | s = f.read() if teststr == "" else teststr 7 | return [s.count(str(i)) for i in range(9)] 8 | 9 | 10 | def run(days): 11 | a = t[:] 12 | for _ in range(days): 13 | a = a[1:] + [a[0]] 14 | a[6] += a[8] 15 | return sum(a) 16 | 17 | 18 | teststr = """""" 19 | DIR = pathlib.Path(__file__).parent.absolute() 20 | t = read() 21 | if __name__ == "__main__": 22 | print(run(80)) 23 | print(run(256)) 24 | -------------------------------------------------------------------------------- /2022/16/optimal.txt: -------------------------------------------------------------------------------- 1 | optimal 2 | ['AA', 'OU', 'OU', 'TO', 'TO', 'DY', 'DY', 'DI', 'DI', 'RH', 'RH', 'OU', 'OI', 'OI', 'BO', 'BO', 'MJ'] 3 | optimal 4 | ['AA', 'OU', 'OU', 'TO', 'TO', 'DY', 'DY', 'DI', 'DI', 'RH', 'RH', 'OU', 'OI', 'OI', 'BO', 'BO', 'ID'] 5 | optimal 6 | ['AA', 'OU', 'OU', 'TO', 'TO', 'DY', 'DY', 'DI', 'DI', 'RH', 'RH', 'OU', 'OI', 'OI', 'BO', 'BO', 'OI'] 7 | 1659 8 | 9 | 10 | 11 | aa 30 12 | zv 29 13 | ou 28 14 | ou 27 8 15 | nz 26 16 | to 25 17 | to 24 19 18 | zv 23 19 | iu 22 20 | dy 21 21 | dy 20 23 22 | zp 19 23 | di 18 24 | di 17 13 -------------------------------------------------------------------------------- /2025/12/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "program": "${workspaceFolder}/solve.ts", 12 | "preLaunchTask": "tsc: build - tsconfig.json", 13 | "outFiles": ["${workspaceFolder}/out/**/*.js"] 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /req.txt: -------------------------------------------------------------------------------- 1 | anyio==4.7.0 2 | autoflake==2.3.1 3 | black==24.10.0 4 | certifi==2024.8.30 5 | click==8.1.7 6 | Cython==3.0.11 7 | Deprecated==1.2.15 8 | h11==0.14.0 9 | httpcore==1.0.7 10 | httpx==0.28.1 11 | idna==3.10 12 | llist==0.7.1 13 | mpmath==1.3.0 14 | mypy-extensions==1.0.0 15 | networkx==2.8.8 16 | numpy==2.2.0 17 | packaging==24.2 18 | pathspec==0.12.1 19 | pillow==11.0.0 20 | platformdirs==4.3.6 21 | pyflakes==3.2.0 22 | scipy==1.14.1 23 | setuptools==75.6.0 24 | sniffio==1.3.1 25 | sympy==1.13.3 26 | tabulate==0.8.10 27 | tsplib95==0.7.1 28 | vulture==2.14 29 | wrapt==1.17.0 30 | z3-solver==4.13.3.0 31 | -------------------------------------------------------------------------------- /2017/01/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | t = list(map(int, f.read().splitlines()[0])) 7 | return t 8 | 9 | 10 | def easy(): 11 | s, last = 0, 0 12 | for i in t + [t[0]]: 13 | s += i if i == last else 0 14 | last = i 15 | print(s) 16 | 17 | 18 | def hard(): 19 | t_, s = t + t, 0 20 | for i, n in enumerate(t): 21 | s += n if t_[i + len(t) // 2] == n else 0 22 | print(s) 23 | 24 | 25 | DIR = pathlib.Path(__file__).parent.absolute() 26 | t = read() 27 | if __name__ == "__main__": 28 | easy() 29 | hard() 30 | -------------------------------------------------------------------------------- /2018/19/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | t = f.read().splitlines() 7 | return t[0], [[i[:4], *map(int, i[5:].split(" "))] for i in t[1:]] 8 | 9 | 10 | def fact(N): 11 | n = 0 12 | for a in range(N): 13 | if N % (a + 1) == 0: 14 | n += a + 1 15 | print(n) 16 | 17 | 18 | def easy(): 19 | fact(945) 20 | 21 | 22 | def hard(): 23 | fact(10551345) 24 | 25 | 26 | DIR = pathlib.Path(__file__).parent.absolute() 27 | ip, t = read() 28 | ip = int(ip[4]) 29 | 30 | 31 | if __name__ == "__main__": 32 | easy() 33 | hard() 34 | -------------------------------------------------------------------------------- /2024/17/tmp.py: -------------------------------------------------------------------------------- 1 | nums = list([2, 4, 1, 5, 7, 5, 1, 6, 0, 3, 4, 6, 5, 5, 3, 0]) 2 | 3 | 4 | def calc(A, nums): 5 | try: 6 | return (((A % 8) ^ nums[3]) ^ nums[7]) ^ (A // 2 ** ((A % 8) ^ nums[3])) % 8 7 | except Exception: 8 | return 9 | 10 | 11 | def find_number(i=0, prev=0): 12 | if i == len(nums): 13 | return prev // 8 14 | for A in range(prev, prev + 8): 15 | if calc(A, nums) != nums[-i - 1]: 16 | continue 17 | future = find_number(i + 1, prev=A * 8) 18 | if future is not None: 19 | return future 20 | 21 | return None 22 | 23 | 24 | print(find_number()) 25 | -------------------------------------------------------------------------------- /2015/02/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from math import prod 3 | 4 | 5 | def read(): 6 | with open(DIR / "input") as f: 7 | s = (f.read() if teststr == "" else teststr).splitlines() 8 | print(sum(map(lambda r: area(*map(int, r.split("x"))), s))) 9 | print(sum(map(lambda r: bow(*map(int, r.split("x"))), s))) 10 | 11 | 12 | def area(l, w, h): 13 | return 2 * l * w + 2 * w * h + 2 * h * l + prod(sorted([l, w, h])[:2]) 14 | 15 | 16 | def bow(l, w, h): 17 | return l * w * h + 2 * sum(sorted([l, w, h])[:2]) 18 | 19 | 20 | teststr = """""" 21 | DIR = pathlib.Path(__file__).parent.absolute() 22 | if __name__ == "__main__": 23 | read() 24 | -------------------------------------------------------------------------------- /2015/08/main.py: -------------------------------------------------------------------------------- 1 | import re 2 | import pathlib 3 | import codecs 4 | 5 | 6 | def read(): 7 | with open(DIR / "input") as f: 8 | s, e = (f.read() if teststr == "" else teststr).splitlines(), "unicode_escape" 9 | for i, v in enumerate(s): 10 | s[i] = (v, codecs.decode(re.sub(r'\\x[^"]{2}', "\\\\x61", v)[1:-1], e)) 11 | return len("".join(map(lambda i: i[0], s))), s 12 | 13 | 14 | teststr = """\"\" 15 | "abc" 16 | "aaa\\"aaa" 17 | "\\x27\"""" 18 | teststr = "" 19 | DIR = pathlib.Path(__file__).parent.absolute() 20 | N, t = read() 21 | if __name__ == "__main__": 22 | print(N - len("".join(map(lambda i: i[1], t)))) 23 | print(sum(map(lambda i: 2 + i[0].count('"') + i[0].count("\\"), t))) 24 | -------------------------------------------------------------------------------- /2015/10/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | return (f.read() if teststr == "" else teststr).splitlines()[0] 7 | 8 | 9 | def next(seq): 10 | r, prev, count = "", "", 0 11 | for e in seq: 12 | if e != prev and prev != "": 13 | r += str(count) + prev 14 | count = 0 15 | count += 1 16 | prev = e 17 | return r + str(count) + prev 18 | 19 | 20 | teststr = """""" 21 | DIR = pathlib.Path(__file__).parent.absolute() 22 | t = read() 23 | if __name__ == "__main__": 24 | for _ in range(40): 25 | t = next(t) 26 | print(len(t)) 27 | for _ in range(10): 28 | t = next(t) 29 | print(len(t)) 30 | -------------------------------------------------------------------------------- /2019/16/tmp.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | N = 10 4 | 5 | 6 | def pprint(l): 7 | for i in l: 8 | print((" " + str(i))[-3:], end="") 9 | print() 10 | 11 | 12 | # last = [0 for _ in range(N)] 13 | # for j in range(N): 14 | # curr = [[0, 1, 0, -1][(i // (j + 1)) % 4] for i in range(N)] 15 | # # pprint([a - b for a, b in zip(curr, last)]) 16 | # last = curr 17 | 18 | 19 | def ppprint(A): 20 | for r in A: 21 | pprint(r) 22 | 23 | 24 | A = np.zeros((N, N), np.int32) 25 | 26 | 27 | for i in range(N): 28 | x = [-1, 1, 1, -1][i % 4] 29 | for j in range(1, N + 1): 30 | y = j // (i + 1) 31 | if y >= N: 32 | continue 33 | A[y, j - 1] += x 34 | ppprint(A) -------------------------------------------------------------------------------- /2021/01/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | return (f.read() if teststr == "" else teststr).splitlines() 7 | 8 | 9 | def easy(): 10 | n, b = 0, 9999 11 | for a in t: 12 | if int(a) > b: 13 | n += 1 14 | b = int(a) 15 | print(n) 16 | 17 | 18 | def hard(): 19 | n = 0 20 | b = 9999 21 | for i in range(len(t) - 2): 22 | a = int(t[i]) + int(t[i + 1]) + int(t[i + 2]) 23 | if a > b: 24 | n += 1 25 | b = a 26 | print(n) 27 | 28 | 29 | teststr = """""" 30 | DIR = pathlib.Path(__file__).parent.absolute() 31 | t = read() 32 | if __name__ == "__main__": 33 | easy() 34 | hard() 35 | -------------------------------------------------------------------------------- /2025/01/solve.ts: -------------------------------------------------------------------------------- 1 | const input = await Bun.file("input").text(); 2 | const lines = input.trim().split("\n"); 3 | 4 | let i = 50 5 | let zeros = 0 6 | let zerosTwo = 0 7 | let before = i 8 | for (const line of lines) { 9 | if (line.slice(0, 1) === 'L') { 10 | i -= +line.slice(1) 11 | } else { 12 | i += +line.slice(1) 13 | } 14 | while (i < 0) { i += 100 } 15 | i %= 100 16 | if (i == 0) zeros += 1; 17 | 18 | if (line.slice(0, 1) === 'L') { 19 | if (i > before) zerosTwo++ 20 | } else { 21 | if (i < before) zerosTwo++ 22 | } 23 | zerosTwo += ~~((+line.slice(1)) / 100) 24 | before = i; 25 | } 26 | 27 | console.log(zeros) 28 | console.log(zerosTwo) 29 | 30 | export { } -------------------------------------------------------------------------------- /2021/07/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | s = (f.read() if teststr == "" else teststr).splitlines()[0] 7 | return lmap(int, s.split(",")) 8 | 9 | 10 | def run(mod): 11 | m = (inf, inf) 12 | for i in range(mi, ma): 13 | cost = 0 14 | for num in t: 15 | cost += mod(abs(num - i)) 16 | if cost < m[0]: 17 | m = (cost, i) 18 | print(m[0]) 19 | 20 | 21 | teststr = """""" 22 | DIR = pathlib.Path(__file__).parent.absolute() 23 | lmap = lambda *a: list(map(*a)) 24 | inf = float("inf") 25 | t = read() 26 | mi, ma = min(t), max(t) 27 | if __name__ == "__main__": 28 | run(int) 29 | run(lambda i: (i * (i + 1)) // 2) 30 | -------------------------------------------------------------------------------- /2024/13/tmp.py: -------------------------------------------------------------------------------- 1 | from sympy import symbols, Eq, solve 2 | 3 | # Define variables 4 | x, y = symbols("x y") 5 | c1, c2, c3, d1, d2, d3 = ( 6 | 94, 7 | 22, 8 | 8400, 9 | 34, 10 | 67, 11 | 5400, 12 | ) # Substitute your constants directly 13 | 14 | # Define equations with constants 15 | eq1 = Eq(x * c1 + y * c2, c3) 16 | eq2 = Eq(x * d1 + y * d2, d3) 17 | 18 | # Solve for x and y 19 | solution = solve((eq1, eq2), (x, y)) 20 | 21 | # Extract values of x and y 22 | x_val = solution[x] 23 | y_val = solution[y] 24 | 25 | # Minimize x + y 26 | min_value = x_val + y_val 27 | 28 | solvable = min_value % 1 == 0 29 | 30 | # Display results 31 | print("Solution for x and y:", solution) 32 | print("Minimized value of x + y:", min_value % 1 == 0) 33 | -------------------------------------------------------------------------------- /2015/04/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from hashlib import md5 3 | 4 | 5 | def read(): 6 | with open(DIR / "input") as f: 7 | return (f.read() if teststr == "" else teststr).splitlines()[0] 8 | 9 | 10 | def hash(num): 11 | return str(md5((t + str(num)).encode()).hexdigest()) 12 | 13 | 14 | def easy(): 15 | i = 1 16 | while True: 17 | if hash(i).startswith("00000"): 18 | return print(i) 19 | i += 1 20 | 21 | 22 | def hard(): 23 | i = 1 24 | while True: 25 | if hash(i).startswith("000000"): 26 | return print(i) 27 | i += 1 28 | 29 | 30 | teststr = """""" 31 | DIR = pathlib.Path(__file__).parent.absolute() 32 | t = read() 33 | if __name__ == "__main__": 34 | easy() 35 | hard() 36 | -------------------------------------------------------------------------------- /2015/20/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | return (f.read() if teststr == "" else teststr).splitlines()[0] 7 | 8 | 9 | def presents(max_fact=9e9, mult=10, limit=1e6): 10 | max_fact, limit, houses = int(max_fact), int(limit), [0] * int(limit) 11 | for i in range(limit): 12 | for k, j in enumerate(range(limit)[:: (i + 1)][1:]): 13 | if k == max_fact or j >= limit: 14 | break 15 | houses[j] += i * mult 16 | if houses[j] >= t: 17 | return print(j) 18 | 19 | 20 | teststr = """""" 21 | DIR = pathlib.Path(__file__).parent.absolute() 22 | t = int(read()) 23 | if __name__ == "__main__": 24 | presents() 25 | presents(50, 11) 26 | -------------------------------------------------------------------------------- /2017/23/op.org.txt: -------------------------------------------------------------------------------- 1 | 0: $B = 84 2 | 1: $C = $B 3 | 2: GOTO 4 IF $A != 0 4 | 3: GOTO 8 5 | 2> 4: $B *= 100 6 | 5: $B += 100000 7 | 6: $C = $B 8 | 7: $C += 17000 9 | 31> 8: $F = 1 10 | 9: $D = 2 11 | 23> 10: $E = 2 12 | 19> 11: 13 | 12: 14 | 13: 15 | 14: IF $D * $E == $B: 16 | 15: $F = 0 17 | 14> 16: $E += 1 18 | 17: $G = $E 19 | 18: $G -= $B 20 | 19: GOTO 11 IF $G != 0 21 | 20: $D += 1 22 | 21: $G = $D 23 | 22: $G -= $B 24 | 23: GOTO 10 IF $G != 0 25 | 24: GOTO 26 IF $F != 0 26 | 25: $H += 1 27 | 24> 26: $G = $B 28 | 27: $G -= $C 29 | 28: GOTO 30 IF $G != 0 30 | 29: End. 31 | 28> 30: $B += 17 32 | 31: GOTO 8 33 | -------------------------------------------------------------------------------- /2015/12/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | import json 3 | 4 | 5 | def read(): 6 | with open(DIR / "input") as f: 7 | return json.loads((f.read() if teststr == "" else teststr).splitlines()[0]) 8 | 9 | 10 | def count(obj, red=1): 11 | if isinstance(obj, dict): 12 | if not red and "red" in obj.values(): 13 | return 0 14 | return sum(map(lambda i: count(i, red), obj.values())) 15 | if isinstance(obj, list): 16 | return sum(map(lambda i: count(i, red), obj)) 17 | if isinstance(obj, int) or isinstance(obj, float): 18 | return obj 19 | return 0 20 | 21 | 22 | teststr = """""" 23 | DIR = pathlib.Path(__file__).parent.absolute() 24 | t = read() 25 | if __name__ == "__main__": 26 | print(count(t)) 27 | print(count(t, red=0)) 28 | -------------------------------------------------------------------------------- /2015/05/main.py: -------------------------------------------------------------------------------- 1 | import re 2 | import pathlib 3 | 4 | 5 | def nice(s): 6 | return ( 7 | re.search(r"[aeiou].*[aeiou].*[aeiou]", s) 8 | and re.search(r"(.)\1", s) 9 | and not re.search(r"(ab|cd|pq|xy)", s) 10 | ) 11 | 12 | 13 | def nice2(s): 14 | return re.search(r"(..).*\1", s) and re.search(r"(.).\1", s) 15 | 16 | 17 | def read(): 18 | with open(DIR / "input") as f: 19 | return (f.read() if teststr == "" else teststr).splitlines() 20 | 21 | 22 | def easy(): 23 | print(sum([1 if nice(s) else 0 for s in t])) 24 | 25 | 26 | def hard(): 27 | print(sum([1 if nice2(s) else 0 for s in t])) 28 | 29 | 30 | teststr = """""" 31 | DIR = pathlib.Path(__file__).parent.absolute() 32 | t = read() 33 | if __name__ == "__main__": 34 | easy() 35 | hard() 36 | -------------------------------------------------------------------------------- /2017/13/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | s = f.read() if teststr == "" else teststr 11 | return lmap(lambda r: lmap(int, r.split(": ")), s.splitlines()) 12 | 13 | 14 | def easy(): 15 | s = 0 16 | for a, b in t: 17 | if a % ((b - 1) * 2) == 0: 18 | s += a * b 19 | print(s) 20 | 21 | 22 | def hard(): 23 | n = 0 24 | while True: 25 | n += 1 26 | for a, b in t: 27 | if (a + n) % ((b - 1) * 2) == 0: 28 | break 29 | if a == t[-1][0]: 30 | print(n) 31 | return 32 | 33 | 34 | teststr = "" 35 | DIR = pathlib.Path(__file__).parent.absolute() 36 | t = read() 37 | if __name__ == "__main__": 38 | easy() 39 | hard() 40 | -------------------------------------------------------------------------------- /2020/25/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | DIR = pathlib.Path(__file__).parent.absolute() 4 | 5 | 6 | def read(): 7 | with open(DIR / "input") as f: 8 | t = f.read().replace("\r", "").splitlines() 9 | return [int(i) for i in t] 10 | 11 | 12 | t = read() 13 | 14 | 15 | def find_loop(pub, subject=7): 16 | k = i = 1 17 | while k != pub: 18 | k = encrypt(k, subject, 1) 19 | i += 1 20 | return i - 1 21 | 22 | 23 | def encrypt(value, subject, loop): 24 | for _ in range(loop): 25 | value = (value * subject) % 20201227 26 | return value 27 | 28 | 29 | def easy(): 30 | _ = find_loop(t[0]) 31 | # print(loop_card) 32 | loop_door = find_loop(t[1]) 33 | print(encrypt(1, t[0], loop_door)) 34 | 35 | 36 | def hard(): 37 | return 38 | 39 | 40 | if __name__ == "__main__": 41 | easy() 42 | hard() 43 | -------------------------------------------------------------------------------- /2020/06/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from functools import reduce 3 | from string import ascii_lowercase 4 | 5 | DIR = pathlib.Path(__file__).parent.absolute() 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | t = f.read().replace("\r", "").split("\n\n") 11 | if t[-1] == "": 12 | t.pop() 13 | t = [l.split("\n") for l in t] 14 | if t[-1][-1] == "": 15 | t[-1].pop() 16 | 17 | return t 18 | 19 | 20 | def easy(): 21 | t = read() 22 | 23 | t = [len(reduce(lambda a, b: a | set(list(b)), e, set())) for e in t] 24 | print(sum(t)) 25 | 26 | 27 | def hard(): 28 | t = read() 29 | 30 | t = [ 31 | len(reduce(lambda a, b: a & set(list(b)), e, set(list(ascii_lowercase)))) 32 | for e in t 33 | ] 34 | print(sum(t)) 35 | 36 | 37 | if __name__ == "__main__": 38 | easy() 39 | hard() 40 | -------------------------------------------------------------------------------- /2019/02/main.py: -------------------------------------------------------------------------------- 1 | def calc(a, b): 2 | import pathlib 3 | 4 | with open(pathlib.Path(__file__).parent.absolute() / "input") as f: 5 | t = f.read().replace("\r", "").split(",") 6 | if t[-1] == "": 7 | t.pop() 8 | 9 | t = [int(i) for i in t] 10 | t[1] = a 11 | t[2] = b 12 | 13 | i = 0 14 | while t[i] != 99: 15 | if t[i] == 1: 16 | t[t[i + 3]] = t[t[i + 1]] + t[t[i + 2]] 17 | else: 18 | t[t[i + 3]] = t[t[i + 1]] * t[t[i + 2]] 19 | 20 | i += 4 21 | 22 | return t[0] 23 | 24 | 25 | def easy(): 26 | print(calc(12, 2)) 27 | 28 | 29 | def hard(): 30 | for i in range(100): 31 | for j in range(100): 32 | if calc(i, j) == 19690720: 33 | print(100 * i + j) 34 | return 35 | 36 | 37 | if __name__ == "__main__": 38 | easy() 39 | hard() -------------------------------------------------------------------------------- /2017/02/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | t = lmap(lambda r: lmap(int, r.split("\t")), f.read().splitlines()) 11 | return t 12 | 13 | 14 | def easy(): 15 | print(sum(map(lambda r: max(r) - min(r), t))) 16 | 17 | 18 | def hard(): 19 | s = 0 20 | for r in t: 21 | try: 22 | for i, a in enumerate(r): 23 | for b in r[i + 1 :]: 24 | a_, b_ = (a, b) if a > b else (b, a) 25 | if a_ % b_ == 0: 26 | s += a_ // b_ 27 | raise Exception() 28 | except: 29 | pass 30 | print(s) 31 | 32 | 33 | DIR = pathlib.Path(__file__).parent.absolute() 34 | t = read() 35 | if __name__ == "__main__": 36 | easy() 37 | hard() 38 | -------------------------------------------------------------------------------- /2015/25/main.py: -------------------------------------------------------------------------------- 1 | import re 2 | import pathlib 3 | 4 | 5 | def read(): 6 | with open(DIR / "input") as f: 7 | s = re.sub(r"[,\.]", "", f.read() if teststr == "" else teststr).splitlines()[0] 8 | return int(s.split(" ")[-3]), int(s.split(" ")[-1]) 9 | 10 | 11 | def diag(x, y): 12 | return x + y - 2 13 | 14 | 15 | def sum_to(diag): 16 | return diag * (diag + 1) // 2 17 | 18 | 19 | def pos(x, y): 20 | return sum_to(diag(x, y)) + (diag(x, y) + 1 - y - 1 + 1) 21 | 22 | 23 | def next(n): 24 | return (n * 252533) % 33554393 25 | 26 | 27 | def easy(): 28 | n = 20151125 29 | for _ in range(pos(X, Y)): 30 | n = next(n) 31 | print(n) 32 | 33 | 34 | def hard(): 35 | return 36 | 37 | 38 | teststr = """""" 39 | DIR = pathlib.Path(__file__).parent.absolute() 40 | Y, X = read() 41 | if __name__ == "__main__": 42 | easy() 43 | hard() 44 | -------------------------------------------------------------------------------- /2015/21/short.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | from itertools import product 4 | 5 | 6 | W = np.array([[8, 4, 0], [10, 5, 0], [25, 6, 0], [40, 7, 0], [74, 8, 0]]) 7 | A = np.array([[13, 0, 1], [31, 0, 2], [53, 0, 3], [75, 0, 4], [102, 0, 5]]) 8 | R = np.array([[25, 1, 0], [50, 2, 0], [100, 3, 0], [20, 0, 1], [40, 0, 2], [80, 0, 3]]) 9 | A, R, n = np.vstack([A, [[0, 0, 0]]]), np.vstack([R, [[0, 0, 0]]]), len(R) 10 | R = np.vstack([R, *[R[i] + R[j] for i, j in product(range(n), repeat=2) if j <= i]]) 11 | with open(pathlib.Path(__file__).parent.absolute() / "input") as f: 12 | t = np.array(list(map(lambda r: int(r.split(" ")[-1]), f.read().splitlines()))) 13 | f = lambda a: 99 // max(1, t[1] - a[2]) + 1 >= (t[0] - 1) // max(1, a[1] - t[2]) + 1 14 | win = [(f(w + a + r), (w + a + r)[0]) for w, a, r in product(W, A, R)] 15 | print(min([c for w, c in win if w]), max([c for w, c in win if not w]), sep="\n") 16 | -------------------------------------------------------------------------------- /2020/15/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | DIR = pathlib.Path(__file__).parent.absolute() 4 | 5 | 6 | def read(): 7 | with open(DIR / "input") as f: 8 | t = f.read().split(",") 9 | return [int(i) for i in t] 10 | 11 | 12 | t = read() 13 | tick = mem = last_num = None 14 | 15 | 16 | def add_num(n): 17 | global last_num, tick 18 | tick += 1 19 | mem[last_num] = tick 20 | last_num = n 21 | 22 | 23 | def get_new_num(): 24 | return tick - mem.get(last_num, tick + 1) + 1 25 | 26 | 27 | def solve(N): 28 | global mem, last_num, tick 29 | mem = {} 30 | tick = last_num = -1 31 | for n in t: 32 | add_num(n) 33 | for _ in range(N - len(t)): 34 | add_num(get_new_num()) 35 | print(last_num) 36 | 37 | 38 | def easy(): 39 | solve(2020) 40 | 41 | 42 | def hard(): 43 | solve(30000000) 44 | 45 | 46 | if __name__ == "__main__": 47 | easy() 48 | hard() 49 | -------------------------------------------------------------------------------- /2015/03/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | move = {"v": (0, 1), "^": (0, -1), "<": (-1, 0), ">": (1, 0)} 5 | 6 | 7 | def read(): 8 | with open(DIR / "input") as f: 9 | s = (f.read() if teststr == "" else teststr).splitlines()[0] 10 | return lmap(lambda r: move[r], s) 11 | 12 | 13 | def easy(): 14 | p, visited = (0, 0), {(0, 0)} 15 | for m in t: 16 | p = (p[0] + m[0], p[1] + m[1]) 17 | visited.add(p) 18 | print(len(visited)) 19 | 20 | 21 | def hard(): 22 | p, visited, i = [(0, 0), (0, 0)], [{(0, 0)}, {(0, 0)}], 0 23 | for m in t: 24 | p[i] = (p[i][0] + m[0], p[i][1] + m[1]) 25 | visited[i].add(p[i]) 26 | i = 1 - i 27 | print(len(visited[0] | visited[1])) 28 | 29 | 30 | teststr = """""" 31 | lmap = lambda *a: list(map(*a)) 32 | DIR = pathlib.Path(__file__).parent.absolute() 33 | t = read() 34 | if __name__ == "__main__": 35 | easy() 36 | hard() 37 | -------------------------------------------------------------------------------- /2017/05/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | teststr = """""" 9 | 10 | 11 | def read(): 12 | with open(DIR / "input") as f: 13 | s = f.read() if teststr == "" else teststr 14 | return lmap(int, filter(None, s.splitlines())) 15 | 16 | 17 | def easy(): 18 | n = p = 0 19 | try: 20 | while True: 21 | t[p] += 1 22 | p += t[p] - 1 23 | n += 1 24 | except: 25 | pass 26 | print(n) 27 | 28 | 29 | def hard(): 30 | n = p = 0 31 | try: 32 | while True: 33 | x = -1 if t[p] >= 3 else 1 34 | t[p] += x 35 | p += t[p] - x 36 | n += 1 37 | except: 38 | pass 39 | print(n) 40 | 41 | 42 | DIR = pathlib.Path(__file__).parent.absolute() 43 | t = read() 44 | if __name__ == "__main__": 45 | easy() 46 | t = read() 47 | hard() 48 | -------------------------------------------------------------------------------- /2020/05/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | DIR = pathlib.Path(__file__).parent.absolute() 4 | 5 | 6 | def seat_id(s): 7 | return int(s, 2) 8 | 9 | 10 | def read(): 11 | with open(DIR / "input") as f: 12 | t = ( 13 | f.read() 14 | .replace("\r", "") 15 | .replace("F", "0") 16 | .replace("B", "1") 17 | .replace("L", "0") 18 | .replace("R", "1") 19 | .split("\n") 20 | ) 21 | if t[-1] == "": 22 | t.pop() 23 | 24 | t.sort() 25 | return t 26 | 27 | 28 | def easy(): 29 | t = read() 30 | print(seat_id(t[-1])) 31 | 32 | 33 | def hard(): 34 | t = [seat_id(s) for s in read()] 35 | 36 | last = -1 37 | for seat in t: 38 | if last == seat - 2: 39 | print(seat - 1) 40 | return 41 | last = seat 42 | 43 | 44 | if __name__ == "__main__": 45 | easy() 46 | hard() -------------------------------------------------------------------------------- /2016/19/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from llist import dllist as llist 3 | 4 | 5 | def read(): 6 | with open(DIR / "input") as f: 7 | s = (f.read() if teststr == "" else teststr).splitlines()[0] 8 | return int(s) 9 | 10 | 11 | def easy(): 12 | l = llist(range(t)) 13 | i = l.first 14 | for _ in range(t - 1): 15 | l.remove(i.next if i.next else l.first) 16 | i = i.next if i.next else l.first 17 | print(l[0] + 1) 18 | 19 | 20 | def hard(): 21 | l = llist(range(t)) 22 | i = l.nodeat(t // 2 - 1) 23 | odd = t % 2 24 | for _ in range(t - 1): 25 | l.remove(i.next if i.next else l.first) 26 | if odd: 27 | i = i.next if i.next else l.first 28 | odd = not odd 29 | print(l[0] + 1) 30 | 31 | 32 | teststr = "" # """5""" 33 | DIR = pathlib.Path(__file__).parent.absolute() 34 | t = read() 35 | if __name__ == "__main__": 36 | easy() 37 | hard() 38 | -------------------------------------------------------------------------------- /2016/03/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | s = (f.read() if teststr == "" else teststr).splitlines() 11 | return lmap(lambda r: lmap(int, [r[:5], r[5:10], r[10:]]), s) 12 | 13 | 14 | def easy(): 15 | counter = 0 16 | for a, b, c in t: 17 | if a < b + c and b < a + c and c < a + b: 18 | counter += 1 19 | print(counter) 20 | 21 | 22 | def hard(): 23 | counter = 0 24 | t_ = [i[0] for i in t] + [i[1] for i in t] + [i[2] for i in t] 25 | for i in range(len(t_))[::3]: 26 | a, b, c = t_[i], t_[i + 1], t_[i + 2] 27 | if a < b + c and b < a + c and c < a + b: 28 | counter += 1 29 | print(counter) 30 | 31 | 32 | teststr = """""" 33 | DIR = pathlib.Path(__file__).parent.absolute() 34 | t = read() 35 | if __name__ == "__main__": 36 | easy() 37 | hard() 38 | -------------------------------------------------------------------------------- /2015/09/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | from python_tsp.exact import solve_tsp_dynamic_programming 4 | 5 | 6 | def read(): 7 | with open(DIR / "input") as f: 8 | s = (f.read() if teststr == "" else teststr).splitlines() 9 | ns, costs = {}, {} 10 | for i in s: 11 | p1 = ns.get(i.split(" ")[0], len(ns)) 12 | ns[i.split(" ")[0]] = p1 13 | p2 = ns.get(i.split(" ")[2], len(ns)) 14 | ns[i.split(" ")[2]] = p2 15 | c = int(i.split(" ")[-1]) 16 | costs[(p1, p2)] = c 17 | A = np.zeros((len(ns) + 1, len(ns) + 1)) # + float("inf") 18 | for tup, c in costs.items(): 19 | A[tup[0] + 1, tup[1] + 1] = A[tup[1] + 1, tup[0] + 1] = c 20 | return A 21 | 22 | 23 | teststr = """""" 24 | DIR = pathlib.Path(__file__).parent.absolute() 25 | A = read() 26 | if __name__ == "__main__": 27 | print(int(solve_tsp_dynamic_programming(A)[1])) 28 | print(-int(solve_tsp_dynamic_programming(-A)[1])) 29 | -------------------------------------------------------------------------------- /2017/06/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | s = f.read() if teststr == "" else teststr 11 | return lmap(int, s.splitlines()[0].split("\t")) 12 | 13 | 14 | def step(): 15 | m = (0, 0) 16 | for i, v in enumerate(t): 17 | if v > m[0]: 18 | m = (v, i) 19 | c = m[0] 20 | i = m[1] 21 | t[i] = 0 22 | while c > 0: 23 | c -= 1 24 | i += 1 25 | i %= N 26 | t[i] += 1 27 | 28 | 29 | def easy(): 30 | seen = set() 31 | 32 | k = 0 33 | while tuple(t) not in seen: 34 | k += 1 35 | seen.add(tuple(t)) 36 | step() 37 | print(k) 38 | 39 | 40 | def hard(): 41 | easy() 42 | 43 | 44 | teststr = "" # """0 2 7 0""" 45 | DIR = pathlib.Path(__file__).parent.absolute() 46 | t = read() 47 | N = len(t) 48 | if __name__ == "__main__": 49 | easy() 50 | hard() 51 | -------------------------------------------------------------------------------- /2022/06/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import re 3 | import pathlib 4 | import json 5 | from functools import reduce 6 | from string import ascii_lowercase 7 | from math import prod, gcd, sqrt 8 | from itertools import permutations, product 9 | from llist import dllist as llist 10 | from copy import deepcopy 11 | from hashlib import md5, sha256 12 | 13 | 14 | def read(): 15 | with open(DIR / "input") as f: 16 | s = (f.read() if teststr == "" else teststr).splitlines() 17 | return s[0] 18 | 19 | 20 | def easy(): 21 | run(4) 22 | 23 | 24 | def hard(): 25 | run(14) 26 | 27 | 28 | def run(num): 29 | b, i = t[:num], num 30 | while len(set(b)) < num: 31 | b += t[i] 32 | b = b[1:] 33 | i += 1 34 | print(i) 35 | 36 | 37 | teststr = """""" 38 | DIR = pathlib.Path(__file__).parent.absolute() 39 | lmap = lambda *a: list(map(*a)) 40 | inf = float("inf") 41 | t = read() 42 | if __name__ == "__main__": 43 | easy() 44 | hard() 45 | -------------------------------------------------------------------------------- /2025/01/bun.lock: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "configVersion": 1, 4 | "workspaces": { 5 | "": { 6 | "devDependencies": { 7 | "@types/bun": "^1.3.4", 8 | }, 9 | }, 10 | }, 11 | "packages": { 12 | "@types/bun": ["@types/bun@1.3.4", "", { "dependencies": { "bun-types": "1.3.4" } }, "sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA=="], 13 | 14 | "@types/node": ["@types/node@25.0.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA=="], 15 | 16 | "bun-types": ["bun-types@1.3.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-5ua817+BZPZOlNaRgGBpZJOSAQ9RQ17pkwPD0yR7CfJg+r8DgIILByFifDTa+IPDDxzf5VNhtNlcKqFzDgJvlQ=="], 17 | 18 | "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2025/02/bun.lock: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "configVersion": 1, 4 | "workspaces": { 5 | "": { 6 | "devDependencies": { 7 | "@types/bun": "^1.3.4", 8 | }, 9 | }, 10 | }, 11 | "packages": { 12 | "@types/bun": ["@types/bun@1.3.4", "", { "dependencies": { "bun-types": "1.3.4" } }, "sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA=="], 13 | 14 | "@types/node": ["@types/node@25.0.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA=="], 15 | 16 | "bun-types": ["bun-types@1.3.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-5ua817+BZPZOlNaRgGBpZJOSAQ9RQ17pkwPD0yR7CfJg+r8DgIILByFifDTa+IPDDxzf5VNhtNlcKqFzDgJvlQ=="], 17 | 18 | "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2025/03/bun.lock: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "configVersion": 1, 4 | "workspaces": { 5 | "": { 6 | "devDependencies": { 7 | "@types/bun": "^1.3.4", 8 | }, 9 | }, 10 | }, 11 | "packages": { 12 | "@types/bun": ["@types/bun@1.3.4", "", { "dependencies": { "bun-types": "1.3.4" } }, "sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA=="], 13 | 14 | "@types/node": ["@types/node@25.0.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA=="], 15 | 16 | "bun-types": ["bun-types@1.3.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-5ua817+BZPZOlNaRgGBpZJOSAQ9RQ17pkwPD0yR7CfJg+r8DgIILByFifDTa+IPDDxzf5VNhtNlcKqFzDgJvlQ=="], 17 | 18 | "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2025/04/bun.lock: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "configVersion": 1, 4 | "workspaces": { 5 | "": { 6 | "devDependencies": { 7 | "@types/bun": "^1.3.4", 8 | }, 9 | }, 10 | }, 11 | "packages": { 12 | "@types/bun": ["@types/bun@1.3.4", "", { "dependencies": { "bun-types": "1.3.4" } }, "sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA=="], 13 | 14 | "@types/node": ["@types/node@25.0.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA=="], 15 | 16 | "bun-types": ["bun-types@1.3.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-5ua817+BZPZOlNaRgGBpZJOSAQ9RQ17pkwPD0yR7CfJg+r8DgIILByFifDTa+IPDDxzf5VNhtNlcKqFzDgJvlQ=="], 17 | 18 | "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2025/05/bun.lock: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "configVersion": 1, 4 | "workspaces": { 5 | "": { 6 | "devDependencies": { 7 | "@types/bun": "^1.3.4", 8 | }, 9 | }, 10 | }, 11 | "packages": { 12 | "@types/bun": ["@types/bun@1.3.4", "", { "dependencies": { "bun-types": "1.3.4" } }, "sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA=="], 13 | 14 | "@types/node": ["@types/node@25.0.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA=="], 15 | 16 | "bun-types": ["bun-types@1.3.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-5ua817+BZPZOlNaRgGBpZJOSAQ9RQ17pkwPD0yR7CfJg+r8DgIILByFifDTa+IPDDxzf5VNhtNlcKqFzDgJvlQ=="], 17 | 18 | "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2025/06/bun.lock: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "configVersion": 1, 4 | "workspaces": { 5 | "": { 6 | "devDependencies": { 7 | "@types/bun": "^1.3.4", 8 | }, 9 | }, 10 | }, 11 | "packages": { 12 | "@types/bun": ["@types/bun@1.3.4", "", { "dependencies": { "bun-types": "1.3.4" } }, "sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA=="], 13 | 14 | "@types/node": ["@types/node@25.0.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA=="], 15 | 16 | "bun-types": ["bun-types@1.3.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-5ua817+BZPZOlNaRgGBpZJOSAQ9RQ17pkwPD0yR7CfJg+r8DgIILByFifDTa+IPDDxzf5VNhtNlcKqFzDgJvlQ=="], 17 | 18 | "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2025/07/bun.lock: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "configVersion": 1, 4 | "workspaces": { 5 | "": { 6 | "devDependencies": { 7 | "@types/bun": "^1.3.4", 8 | }, 9 | }, 10 | }, 11 | "packages": { 12 | "@types/bun": ["@types/bun@1.3.4", "", { "dependencies": { "bun-types": "1.3.4" } }, "sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA=="], 13 | 14 | "@types/node": ["@types/node@25.0.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA=="], 15 | 16 | "bun-types": ["bun-types@1.3.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-5ua817+BZPZOlNaRgGBpZJOSAQ9RQ17pkwPD0yR7CfJg+r8DgIILByFifDTa+IPDDxzf5VNhtNlcKqFzDgJvlQ=="], 17 | 18 | "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2025/08/bun.lock: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "configVersion": 1, 4 | "workspaces": { 5 | "": { 6 | "devDependencies": { 7 | "@types/bun": "^1.3.4", 8 | }, 9 | }, 10 | }, 11 | "packages": { 12 | "@types/bun": ["@types/bun@1.3.4", "", { "dependencies": { "bun-types": "1.3.4" } }, "sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA=="], 13 | 14 | "@types/node": ["@types/node@25.0.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA=="], 15 | 16 | "bun-types": ["bun-types@1.3.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-5ua817+BZPZOlNaRgGBpZJOSAQ9RQ17pkwPD0yR7CfJg+r8DgIILByFifDTa+IPDDxzf5VNhtNlcKqFzDgJvlQ=="], 17 | 18 | "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2025/09/bun.lock: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "configVersion": 1, 4 | "workspaces": { 5 | "": { 6 | "devDependencies": { 7 | "@types/bun": "^1.3.4", 8 | }, 9 | }, 10 | }, 11 | "packages": { 12 | "@types/bun": ["@types/bun@1.3.4", "", { "dependencies": { "bun-types": "1.3.4" } }, "sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA=="], 13 | 14 | "@types/node": ["@types/node@25.0.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA=="], 15 | 16 | "bun-types": ["bun-types@1.3.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-5ua817+BZPZOlNaRgGBpZJOSAQ9RQ17pkwPD0yR7CfJg+r8DgIILByFifDTa+IPDDxzf5VNhtNlcKqFzDgJvlQ=="], 17 | 18 | "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2025/11/bun.lock: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "configVersion": 1, 4 | "workspaces": { 5 | "": { 6 | "devDependencies": { 7 | "@types/bun": "^1.3.4", 8 | }, 9 | }, 10 | }, 11 | "packages": { 12 | "@types/bun": ["@types/bun@1.3.4", "", { "dependencies": { "bun-types": "1.3.4" } }, "sha512-EEPTKXHP+zKGPkhRLv+HI0UEX8/o+65hqARxLy8Ov5rIxMBPNTjeZww00CIihrIQGEQBYg+0roO5qOnS/7boGA=="], 13 | 14 | "@types/node": ["@types/node@25.0.2", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-gWEkeiyYE4vqjON/+Obqcoeffmk0NF15WSBwSs7zwVA2bAbTaE0SJ7P0WNGoJn8uE7fiaV5a7dKYIJriEqOrmA=="], 15 | 16 | "bun-types": ["bun-types@1.3.4", "", { "dependencies": { "@types/node": "*" } }, "sha512-5ua817+BZPZOlNaRgGBpZJOSAQ9RQ17pkwPD0yR7CfJg+r8DgIILByFifDTa+IPDDxzf5VNhtNlcKqFzDgJvlQ=="], 17 | 18 | "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /2015/17/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | s = (f.read() if teststr == "" else teststr).splitlines() 7 | return list(reversed(sorted(map(int, s)))) 8 | 9 | 10 | def easy(): 11 | options = set() 12 | for num in range(2 ** len(t) - 1): 13 | b = "".join(reversed(("{:0" + str(len(t)) + "b}").format(num))) 14 | comb, s, i = [], 0, 0 15 | for i, e in enumerate(b): 16 | if e == "0": 17 | continue 18 | s += t[i] 19 | comb.append(t[i]) 20 | if s > 150: 21 | break 22 | if s == 150: 23 | options.add(b) # (tuple(sorted(comb))) 24 | print(len(options)) 25 | options = [o.count("1") for o in options] 26 | print(len([o for o in options if o == min(options)])) 27 | 28 | 29 | teststr = "" 30 | DIR = pathlib.Path(__file__).parent.absolute() 31 | t = read() 32 | if __name__ == "__main__": 33 | easy() 34 | -------------------------------------------------------------------------------- /2019/01/main.py: -------------------------------------------------------------------------------- 1 | def easy(): 2 | import pathlib 3 | 4 | with open(pathlib.Path(__file__).parent.absolute() / "input") as f: 5 | t = f.read().replace("\r", "").split("\n") 6 | if t[-1] == "": 7 | t.pop() 8 | 9 | t = [int(i) for i in t] 10 | t = [i // 3 for i in t] 11 | t = [i - 2 for i in t] 12 | 13 | print(sum(t)) 14 | 15 | 16 | def hard(): 17 | import pathlib 18 | 19 | with open(pathlib.Path(__file__).parent.absolute() / "input") as f: 20 | t = f.read().replace("\r", "").split("\n") 21 | if t[-1] == "": 22 | t.pop() 23 | 24 | t = [int(i) for i in t] 25 | t = [i // 3 for i in t] 26 | t = [i - 2 for i in t] 27 | 28 | s = sum(t) 29 | while sum(t) > 0: 30 | t = [int(i) for i in t] 31 | t = [i // 3 for i in t] 32 | t = [i - 2 for i in t] 33 | t = [(i if i > 0 else 0) for i in t] 34 | s += sum(t) 35 | 36 | print(s) 37 | 38 | 39 | if __name__ == "__main__": 40 | easy() 41 | hard() -------------------------------------------------------------------------------- /2017/24/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | s = (f.read() if teststr == "" else teststr).splitlines() 11 | return lmap(lambda r: lmap(int, r.split("/")), s) 12 | 13 | 14 | def resolve(a, seen, value=0, l=0): 15 | s = [] 16 | for b in T.get(a, []): 17 | if (a, b) in seen: 18 | continue 19 | s.extend(resolve(b, seen | {(a, b), (b, a)}, value + a + b, l + 1)) 20 | if not s and value > 0: 21 | s = [(value, l)] 22 | return s 23 | 24 | 25 | def easy(): 26 | for a, b in t: 27 | T[a] = T.get(a, []) + [b] 28 | T[b] = T.get(b, []) + [a] 29 | 30 | s = resolve(0, set()) 31 | print(max([a for a, b in s])) 32 | s.sort(key=lambda i: i[1] * 10000 + i[0]) 33 | print(s[-1][0]) 34 | 35 | 36 | teststr = """""" 37 | DIR = pathlib.Path(__file__).parent.absolute() 38 | t = read() 39 | T = {} 40 | if __name__ == "__main__": 41 | easy() 42 | -------------------------------------------------------------------------------- /2020/03/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | 4 | DIR = pathlib.Path(__file__).parent.absolute() 5 | 6 | 7 | def get(x, y): 8 | return A[y, x % A.shape[1]] 9 | 10 | 11 | A = None 12 | 13 | 14 | def check(x, y): 15 | global A 16 | with open(DIR / "input") as f: 17 | t = f.read().replace("\r", "").splitlines() 18 | 19 | t = [[1 if e == "#" else 0 for e in l] for l in t] 20 | A = np.matrix(t, dtype=np.uint32) 21 | 22 | pos = np.array([0, 0]) 23 | mov = np.array([x, y]) 24 | 25 | n = 0 26 | while True: 27 | pos += mov 28 | if pos[1] >= A.shape[0]: 29 | break 30 | n += get(*pos) 31 | return n 32 | 33 | 34 | def easy(): 35 | print(check(3, 1)) 36 | 37 | 38 | def hard(): 39 | a = [ 40 | (1, 1), 41 | (3, 1), 42 | (5, 1), 43 | (7, 1), 44 | (1, 2), 45 | ] 46 | a = [check(*t) for t in a] 47 | print(np.prod(a)) 48 | 49 | 50 | if __name__ == "__main__": 51 | easy() 52 | hard() 53 | -------------------------------------------------------------------------------- /2015/18/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | from itertools import product 4 | 5 | 6 | def read(): 7 | with open(pathlib.Path(__file__).parent.absolute() / "input") as f: 8 | s = (f.read() if teststr == "" else teststr).splitlines() 9 | return np.array(lmap(lambda r: lmap(lambda i: ".#".index(i), r), s), dtype=np.uint8) 10 | 11 | 12 | def step(q): 13 | global t, t_ 14 | for i, j in product(range(N), repeat=2): 15 | n = t[i : i + 3, j : j + 3] 16 | m, s = n[1, 1], n.sum() 17 | t_[i + 1, j + 1] = 1 if (m == 1 and 3 <= s <= 4) or (m == 0 and s == 3) else 0 18 | t, t_ = t_, t 19 | t[corners] = 1 if q else t[corners] 20 | 21 | 22 | teststr = """""" 23 | lmap, corners = lambda *a: list(map(*a)), ([1, 100, 1, 100], [1, 1, 100, 100]) 24 | t, t_, N = np.pad(read(), 1), np.zeros((102, 102), dtype=np.uint8), 100 25 | if __name__ == "__main__": 26 | [step(0) for _ in range(100)] 27 | print(t.sum()) 28 | t = np.pad(read(), 1) 29 | [step(1) for _ in range(100)] 30 | print(t.sum()) 31 | -------------------------------------------------------------------------------- /2016/06/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from string import ascii_lowercase 3 | 4 | 5 | def lmap(*a): 6 | return list(map(*a)) 7 | 8 | 9 | def read(): 10 | with open(DIR / "input") as f: 11 | s = (f.read() if teststr == "" else teststr).splitlines() 12 | return lmap(list, s) 13 | 14 | 15 | def easy(): 16 | s = "" 17 | for letter in list(zip(*t)): 18 | m = (0, 0) 19 | for c in ascii_lowercase: 20 | count = letter.count(c) 21 | if count > m[0]: 22 | m = (count, c) 23 | s += m[1] 24 | print(s) 25 | 26 | 27 | def hard(): 28 | s = "" 29 | for letter in list(zip(*t)): 30 | m = (inf, 0) 31 | for c in ascii_lowercase: 32 | count = letter.count(c) 33 | if count < m[0]: 34 | m = (count, c) 35 | s += m[1] 36 | print(s) 37 | 38 | 39 | teststr = """""" 40 | DIR = pathlib.Path(__file__).parent.absolute() 41 | inf = float("inf") 42 | t = read() 43 | if __name__ == "__main__": 44 | easy() 45 | hard() -------------------------------------------------------------------------------- /2017/17/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | class CircularNode: 5 | def __init__(self, value, next=None): 6 | self.value = value 7 | self.next = self if next is None else next 8 | 9 | def insert(self, value): 10 | self.next = self.__class__(value, self.next) 11 | return self.next 12 | 13 | 14 | def read(): 15 | with open(DIR / "input") as f: 16 | s = f.read() if teststr == "" else teststr 17 | return int(s.splitlines()[0]) 18 | 19 | 20 | def easy(): 21 | n = CircularNode(0) 22 | for i in range(2017): 23 | for _ in range(t): 24 | n = n.next 25 | n = n.insert(i + 1) 26 | print(n.next.value) 27 | 28 | 29 | def hard(): # 1, 7, 27 30 | n = l = 0 31 | for i in range(50000000): 32 | n += t + 1 33 | n %= i + 1 34 | if n == 0: 35 | l = i + 1 36 | print(l) 37 | 38 | 39 | teststr = """""" 40 | DIR = pathlib.Path(__file__).parent.absolute() 41 | t = read() 42 | if __name__ == "__main__": 43 | easy() 44 | hard() 45 | -------------------------------------------------------------------------------- /2021/02/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | return (f.read() if teststr == "" else teststr).splitlines() 7 | 8 | 9 | def easy(): 10 | b = a = 0 11 | 12 | for line in t: 13 | verb = line.split(" ")[0] 14 | num = int(line.split(" ")[-1]) 15 | if verb == "forward": 16 | a += num 17 | if verb == "up": 18 | b -= num 19 | if verb == "down": 20 | b += num 21 | print(a * b) 22 | 23 | 24 | def hard(): 25 | d = h = a = 0 26 | 27 | for line in t: 28 | verb = line.split(" ")[0] 29 | num = int(line.split(" ")[-1]) 30 | if verb == "forward": 31 | h += num 32 | d += num * a 33 | if verb == "up": 34 | a -= num 35 | if verb == "down": 36 | a += num 37 | print(h * d) 38 | 39 | 40 | teststr = """""" 41 | DIR = pathlib.Path(__file__).parent.absolute() 42 | t = read() 43 | if __name__ == "__main__": 44 | easy() 45 | hard() 46 | -------------------------------------------------------------------------------- /2021/25/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | 4 | 5 | def read(): 6 | with open(DIR / "input") as f: 7 | s = (f.read() if teststr == "" else teststr).splitlines() 8 | return np.array(lmap(lambda r: lmap(".>v".index, r), s)) 9 | 10 | 11 | def step(): 12 | moved = 0 13 | moves = [] 14 | for y, x in zip(*np.where(t == 1)): 15 | if t[y, (x + 1) % t.shape[1]] == 0: 16 | moves.append((y, x)) 17 | for y, x in moves: 18 | t[y, (x + 1) % t.shape[1]], t[y, x], moved = 1, 0, 1 19 | moves = [] 20 | for y, x in zip(*np.where(t == 2)): 21 | if t[(y + 1) % t.shape[0], x] == 0: 22 | moves.append((y, x)) 23 | for y, x in moves: 24 | t[(y + 1) % t.shape[0], x], t[y, x], moved = 2, 0, 1 25 | 26 | return moved 27 | 28 | 29 | def easy(): 30 | i = 0 31 | while step(): 32 | i += 1 33 | print(i + 1) 34 | 35 | 36 | teststr = "" 37 | DIR = pathlib.Path(__file__).parent.absolute() 38 | lmap = lambda *a: list(map(*a)) 39 | t = read() 40 | if __name__ == "__main__": 41 | easy() 42 | -------------------------------------------------------------------------------- /2018/21/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | t = f.read().splitlines() 7 | return [[i[:4], *map(int, i[5:].split(" "))] for i in t[1:]] 8 | 9 | 10 | def test(): 11 | s = set() 12 | b = c = d = i = 0 13 | while True: 14 | b = c | A 15 | c = C 16 | while True: 17 | c += b & 255 18 | c &= D 19 | c *= B 20 | c &= D 21 | if b < 256: 22 | if i == 0: 23 | print(c) 24 | if c in s: 25 | print(d) 26 | return 27 | d = c 28 | i = 1 29 | s.add(c) 30 | break 31 | else: 32 | b //= 256 33 | 34 | 35 | def easy(): 36 | return 37 | 38 | 39 | def hard(): 40 | test() 41 | 42 | 43 | DIR = pathlib.Path(__file__).parent.absolute() 44 | t = read() 45 | A, B, C, D = t[6][2], t[11][2], t[7][1], t[10][2] 46 | 47 | 48 | if __name__ == "__main__": 49 | easy() 50 | hard() 51 | -------------------------------------------------------------------------------- /2017/04/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from string import ascii_lowercase 3 | 4 | 5 | def lmap(*a): 6 | return list(map(*a)) 7 | 8 | 9 | def read(): 10 | with open(DIR / "input") as f: 11 | t = lmap(lambda r: r.split(" "), f.read().splitlines()) 12 | return t 13 | 14 | 15 | def easy(): 16 | c = 0 17 | for r in t: 18 | c += 1 19 | s = set() 20 | for w in r: 21 | if w in s: 22 | c -= 1 23 | break 24 | s.add(w) 25 | print(c) 26 | 27 | 28 | def vect(w): 29 | v = [0] * len(ascii_lowercase) 30 | for c in w: 31 | v[ascii_lowercase.index(c)] += 1 32 | return tuple(v) 33 | 34 | 35 | def hard(): 36 | c = 0 37 | for r in t: 38 | c += 1 39 | s = set() 40 | for w in r: 41 | w = vect(w) 42 | if w in s: 43 | c -= 1 44 | break 45 | s.add(w) 46 | print(c) 47 | 48 | 49 | DIR = pathlib.Path(__file__).parent.absolute() 50 | t = read() 51 | if __name__ == "__main__": 52 | easy() 53 | hard() 54 | -------------------------------------------------------------------------------- /2021/05/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | 4 | 5 | def read(): 6 | with open(DIR / "input") as f: 7 | s = (f.read() if teststr == "" else teststr).replace(" -> ", ",").splitlines() 8 | return lmap(lambda r: lmap(int, r.split(",")), s) 9 | 10 | 11 | def hard(): 12 | A = np.zeros((999, 999)) 13 | B = np.zeros((999, 999)) 14 | for a, b, c, d in t: 15 | if a != c and b != d: 16 | dx = 1 if c > a else -1 17 | dy = 1 if d > b else -1 18 | while a != c: 19 | B[a, b] += 1 20 | a += dx 21 | b += dy 22 | B[a, b] += 1 23 | continue 24 | 25 | a, c = min([a, c]), max([a, c]) 26 | b, d = min([b, d]), max([b, d]) 27 | A[a : c + 1, b : d + 1] += 1 28 | B[a : c + 1, b : d + 1] += 1 29 | 30 | print(len(np.where(A >= 2)[0])) 31 | print(len(np.where(B >= 2)[0])) 32 | 33 | 34 | teststr = """""" 35 | DIR = pathlib.Path(__file__).parent.absolute() 36 | lmap = lambda *a: list(map(*a)) 37 | t = read() 38 | if __name__ == "__main__": 39 | hard() 40 | -------------------------------------------------------------------------------- /2016/01/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | s = (f.read() if teststr == "" else teststr).split(", ") 11 | return lmap(lambda r: (r[0], int(r[1:])), s) 12 | 13 | 14 | def left(p): 15 | return (-p[1], p[0]) 16 | 17 | 18 | def right(p): 19 | return (p[1], -p[0]) 20 | 21 | 22 | def easy(): 23 | p, d = (0, 0), (-1, 0) 24 | for turn, move in t: 25 | d = {"L": left, "R": right}[turn](d) 26 | p = (p[0] + move * d[0], p[1] + move * d[1]) 27 | print(sum(map(abs, p))) 28 | 29 | 30 | def hard(): 31 | p, d, seen = (0, 0), (-1, 0), {(0, 0)} 32 | for turn, move in t: 33 | d = {"L": left, "R": right}[turn](d) 34 | for _ in range(move): 35 | p = (p[0] + d[0], p[1] + d[1]) 36 | if p in seen: 37 | return print(sum(map(abs, p))) 38 | seen.add(p) 39 | 40 | 41 | teststr = """""" 42 | DIR = pathlib.Path(__file__).parent.absolute() 43 | t = read() 44 | if __name__ == "__main__": 45 | easy() 46 | hard() 47 | -------------------------------------------------------------------------------- /2025/03/solve.ts: -------------------------------------------------------------------------------- 1 | let input = await Bun.file("input").text(); 2 | const lines = input.trim().split("\n"); 3 | 4 | let answer = 0; 5 | 6 | for (const line of lines) { 7 | let maxFirst = Math.max(...line.slice(0, line.length - 1).split('').map(v => +v)); 8 | let firstIndex = line.length; 9 | for (let i = 0; i < firstIndex; i++) { 10 | if (+line[i] === maxFirst) firstIndex = i 11 | } 12 | let maxSecond = Math.max(...line.slice(firstIndex + 1).split('').map(v => +v)); 13 | answer += +`${maxFirst}${maxSecond}` 14 | } 15 | 16 | console.log(answer) 17 | answer = 0; 18 | 19 | for (const line of lines) { 20 | let lowerLimit = 0; 21 | let s = ''; 22 | for (let k = 1; k <= 12; k++) { 23 | let maxNum = Math.max(...line.slice(lowerLimit, line.length - (12 - k)).split('').map(v => +v)); 24 | let idx = line.length; 25 | for (let i = lowerLimit; i < idx; i++) { 26 | if (+line[i] === maxNum) idx = i 27 | } 28 | lowerLimit = idx + 1; 29 | s += `${maxNum}` 30 | } 31 | answer += +s; 32 | } 33 | 34 | console.log(answer) 35 | 36 | export { } -------------------------------------------------------------------------------- /2016/15/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from copy import deepcopy 3 | 4 | 5 | def lmap(*a): 6 | return list(map(*a)) 7 | 8 | 9 | def read(): 10 | with open(DIR / "input") as f: 11 | s = (f.read() if teststr == "" else teststr).replace(".", "").splitlines() 12 | return lmap(lambda r: lmap(int, map(lambda i: r.split(" ")[i], [3, 11])), s) 13 | 14 | 15 | def run(t): 16 | for i in range(len(t)): 17 | t[i][1] += i + 1 18 | t[i][1] %= t[i][0] 19 | 20 | N = 0 21 | for i in range(len(t)): 22 | m = (t[i][0] - t[i][1]) % t[i][0] 23 | X = 1 24 | for j in range(i): 25 | X *= t[j][0] 26 | while N % t[i][0] != m: 27 | N += X 28 | print(N) 29 | 30 | 31 | def easy(): 32 | run(deepcopy(t)) 33 | 34 | 35 | def hard(): 36 | run(t + [[11, 0]]) 37 | 38 | 39 | teststr = """Disc #1 has 5 positions; at time=0, it is at position 4. 40 | Disc #2 has 2 positions; at time=0, it is at position 1.""" 41 | teststr = "" 42 | DIR = pathlib.Path(__file__).parent.absolute() 43 | t = read() 44 | if __name__ == "__main__": 45 | easy() 46 | hard() 47 | -------------------------------------------------------------------------------- /2016/20/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | s = (f.read() if teststr == "" else teststr).splitlines() 11 | return lmap(lambda r: lmap(int, r.split("-")), s) 12 | 13 | 14 | def easy(): 15 | t.sort(key=lambda i: i[0]) 16 | i = min_allowed = 0 17 | while True: 18 | if t[i][0] > min_allowed: 19 | return print(min_allowed) 20 | min_allowed = max(min_allowed, t[i][1] + 1) 21 | i += 1 22 | 23 | 24 | def hard(): 25 | for i in range(len(t)): 26 | for j in range(i): 27 | if t[j][1] >= t[i][0]: 28 | if t[i][1] > t[j][1]: 29 | t[j][1] = t[i][1] 30 | t[i] = [-1, -1] 31 | break 32 | N = 4294967296 33 | for start, end in t: 34 | if start < 0: 35 | continue 36 | N -= end - start + 1 37 | print(N) 38 | 39 | 40 | teststr = """""" 41 | DIR = pathlib.Path(__file__).parent.absolute() 42 | t = read() 43 | if __name__ == "__main__": 44 | easy() 45 | hard() 46 | -------------------------------------------------------------------------------- /2017/15/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | s = f.read() if teststr == "" else teststr 11 | return lmap(lambda r: int(r.split(" ")[-1]), s.splitlines()) 12 | 13 | 14 | def easy(): 15 | c = 0 16 | a, b = t 17 | for _ in range(40000000): 18 | a *= A 19 | b *= B 20 | a %= M 21 | b %= M 22 | if a & N == b & N: 23 | c += 1 24 | print(c) 25 | 26 | 27 | def hard(): 28 | c = 0 29 | a, b = t 30 | for _ in range(5000000): 31 | while True: 32 | a *= A 33 | a %= M 34 | if not a & 3: 35 | break 36 | while True: 37 | b *= B 38 | b %= M 39 | if not b & 7: 40 | break 41 | if a & N == b & N: 42 | c += 1 43 | print(c) 44 | 45 | 46 | teststr = """""" 47 | DIR = pathlib.Path(__file__).parent.absolute() 48 | t = read() 49 | A, B, M, N = 16807, 48271, 2147483647, 2 ** 16 - 1 50 | if __name__ == "__main__": 51 | easy() 52 | hard() 53 | -------------------------------------------------------------------------------- /2016/05/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | return (f.read() if teststr == "" else teststr).splitlines()[0] 7 | 8 | 9 | def hash(num): 10 | from hashlib import md5 11 | 12 | return str(md5((t + str(num)).encode()).hexdigest()) 13 | 14 | 15 | def easy(): 16 | s, i = "", 0 17 | for _ in range(8): 18 | while True: 19 | i += 1 20 | h = hash(i) 21 | if h[:5] == "0" * 5: 22 | s += h[5] 23 | break 24 | print(s) 25 | 26 | 27 | def hard(): 28 | s, i, solved = ["_"] * 8, 0, set() 29 | while len(solved) != 8: 30 | while True: 31 | i += 1 32 | h = hash(i) 33 | if h[:5] == "0" * 5 and h[5] in map(str, range(8)) and h[5] not in solved: 34 | s[int(h[5])] = h[6] 35 | # print("".join(s)) 36 | solved.add(h[5]) 37 | break 38 | print("".join(s)) 39 | 40 | 41 | teststr = """""" 42 | DIR = pathlib.Path(__file__).parent.absolute() 43 | t = read() 44 | if __name__ == "__main__": 45 | easy() 46 | hard() 47 | -------------------------------------------------------------------------------- /2021/11/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | 4 | 5 | def read() -> any: 6 | with open(DIR / "input") as f: 7 | s = (f.read() if teststr == "" else teststr).splitlines() 8 | return np.array((lmap(lambda r: lmap(int, r), s))) 9 | 10 | 11 | def step(): 12 | global t, F 13 | t += 1 14 | while True: 15 | p = list(zip(*np.where(t >= 10))) 16 | if not p: 17 | t[t < 0] = 0 18 | return 19 | for x, y in p: 20 | F += 1 21 | xm = x - 1 if x > 0 else x 22 | ym = y - 1 if y > 0 else y 23 | t[xm : x + 2, ym : y + 2] += 1 24 | t[x, y] = -int(9e9) 25 | 26 | 27 | def easy(steps): 28 | for _ in range(steps): 29 | step() 30 | print(F) 31 | 32 | 33 | def hard(previous_steps): 34 | for i in range(int(9e9)): 35 | step() 36 | if t.max() == 0: 37 | return print(previous_steps + i + 1) 38 | 39 | 40 | teststr = """""" 41 | DIR = pathlib.Path(__file__).parent.absolute() 42 | lmap = lambda *a: list(map(*a)) 43 | t, F = read(), 0 44 | if __name__ == "__main__": 45 | easy(100) 46 | hard(100) 47 | -------------------------------------------------------------------------------- /2022/15/thinking.txt: -------------------------------------------------------------------------------- 1 | x 2 | x 3 | xx 4 | x x 5 | A x x 6 | x x B 7 | x x 8 | x x x 9 | x x X 10 | x x 11 | x x x 12 | x x x 13 | x x 14 | x 15 | x 16 | C 17 | D 18 | 19 | 20 | 21 | A: 22 | 23 | y = -x + mid_x_a + mid_y_a + (d_a + 1) 24 | 25 | B: 26 | 27 | y = x + mid_x_b - mid_y_b + (d_b + 1) 28 | 29 | 30 | 31 | Solve: 32 | 33 | -x + mid_x_a + mid_y_a + (d_a + 1) = x + mid_x_b - mid_y_b + (d_b + 1) 34 | -2x + mid_x_a + mid_y_a + (d_a + 1) = mid_x_b - mid_y_b + (d_b + 1) 35 | 2x = mid_x_a + mid_y_a + (d_a + 1) - mid_x_b + mid_y_b - (d_b + 1) 36 | x = (mid_x_a + mid_y_a + d_a - mid_x_b + mid_y_b - d_b) / 2 37 | 38 | 39 | 40 | | 41 | | 42 | | x 43 | | 44 | | 45 | |--------------------------- 46 | | 47 | | 48 | | 49 | v -------------------------------------------------------------------------------- /2018/25/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | class Cluster: 5 | def __init__(self, p): 6 | self.points = set([p]) 7 | 8 | 9 | class Pos: 10 | items = [] 11 | 12 | def dist(self, other): 13 | return sum(map(lambda i: abs(other.p[i] - self.p[i]), range(4))) 14 | 15 | def __init__(self, s): 16 | self.p = list(map(int, s.split(","))) 17 | self.cluster = Cluster(self) 18 | merge = [] 19 | for i in self.items: 20 | if i.dist(self) <= 3: 21 | merge.append(i) 22 | self.items.append(self) 23 | for i in merge: 24 | self.cluster.points |= i.cluster.points 25 | for p in i.cluster.points: 26 | p.cluster = self.cluster 27 | 28 | 29 | def read(): 30 | with open(DIR / "input") as f: 31 | t = f.read().splitlines() 32 | for r in t: 33 | Pos(r) 34 | 35 | 36 | def easy(): 37 | s = set() 38 | for i in Pos.items: 39 | s |= {i.cluster} 40 | print(len(s)) 41 | 42 | 43 | def hard(): 44 | return 45 | 46 | 47 | DIR = pathlib.Path(__file__).parent.absolute() 48 | read() 49 | if __name__ == "__main__": 50 | easy() 51 | hard() 52 | -------------------------------------------------------------------------------- /2017/25/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | 4 | 5 | def lmap(*a): 6 | return list(map(*a)) 7 | 8 | 9 | def read(): 10 | with open(DIR / "input") as f: 11 | s = (f.read() if teststr == "" else teststr).split("\n\n") 12 | S = [] 13 | for state in s[1:]: 14 | state = lmap(lambda i: i.split(" ")[-1][:-1], state.splitlines()) 15 | S.append( 16 | [ 17 | ( 18 | int(state[2 + i]), 19 | 2 * int(state[3 + i][0] == "r") - 1, 20 | ord(state[4 + i]) - 65, 21 | ) 22 | for i in [0, 4] 23 | ] 24 | ) 25 | return S, int(s[0].split(" ")[-2]) 26 | 27 | 28 | def easy(): 29 | s = 0 30 | i = N 31 | A = np.zeros(N * 2, np.ubyte) 32 | for _ in range(N): 33 | new_val, movement, new_state = t[s][A[i]] 34 | A[i] = new_val 35 | i += movement 36 | s = new_state 37 | print(A.sum()) 38 | 39 | 40 | def hard(): 41 | return 42 | 43 | 44 | teststr = """""" 45 | DIR = pathlib.Path(__file__).parent.absolute() 46 | t, N = read() 47 | if __name__ == "__main__": 48 | easy() 49 | hard() 50 | -------------------------------------------------------------------------------- /2020/13/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | DIR = pathlib.Path(__file__).parent.absolute() 4 | 5 | lookup = { 6 | ".": 0, 7 | "L": 1, 8 | "#": 2, 9 | } 10 | reverse_lookup = {} 11 | for k, v in lookup.items(): 12 | reverse_lookup[v] = k 13 | 14 | 15 | def read(): 16 | with open(DIR / "input") as f: 17 | t = f.read().replace("\r", "") 18 | t = t.split("\n") 19 | N = int(t[0]) 20 | t = t[1].split(",") 21 | 22 | t = ["x" if e == "x" else int(e) for e in t] 23 | 24 | return N, t 25 | 26 | 27 | N, t = read() 28 | 29 | 30 | def easy(): 31 | r = [] 32 | for i in t: 33 | if i == "x": 34 | continue 35 | r.append((i, i - (N % i))) 36 | r.sort(key=lambda e: e[1]) 37 | print(r[0][0] * r[0][1]) 38 | 39 | 40 | def hard(): 41 | constraints = [] 42 | for i, n in enumerate(t): 43 | if n == "x": 44 | continue 45 | constraints.append((n, n - i)) 46 | 47 | j = 0 48 | add = 1 49 | for div, rst in constraints: 50 | while j % div != rst % div: 51 | j += add 52 | add *= div 53 | print(j) 54 | 55 | 56 | if __name__ == "__main__": 57 | easy() 58 | hard() 59 | -------------------------------------------------------------------------------- /2025/02/solve.ts: -------------------------------------------------------------------------------- 1 | const input = await Bun.file("input").text(); 2 | const ranges = input.trim().split(","); 3 | 4 | let invalid = 0; 5 | for (const range of ranges) { 6 | const [lhs, rhs] = range.split("-").map(v => +v); 7 | for (let i = lhs; i <= rhs; i++) { 8 | const s = `${i}`; 9 | if (s.length % 2) continue; 10 | if (s.slice(0, s.length / 2) !== s.slice(s.length / 2)) continue; 11 | invalid += i 12 | } 13 | } 14 | 15 | console.log(invalid) 16 | 17 | invalid = 0; 18 | for (const range of ranges) { 19 | const [lhs, rhs] = range.split("-").map(v => +v); 20 | for (let i = lhs; i <= rhs; i++) { 21 | const s = `${i}`; 22 | for (let l = 1; l <= s.length / 2; l++) { 23 | if (s.length % l) continue; 24 | let foundWrong = false; 25 | for (let j = l; j < s.length; j += l) { 26 | if (s.slice(0, l) !== s.slice(j, j + l)) { 27 | foundWrong = true 28 | break 29 | } 30 | } 31 | if (foundWrong) continue; 32 | invalid += i 33 | break; 34 | } 35 | } 36 | } 37 | 38 | console.log(invalid) 39 | 40 | export { } -------------------------------------------------------------------------------- /2016/16/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | 4 | 5 | def lmap(*a): 6 | return list(map(*a)) 7 | 8 | 9 | def read(): 10 | with open(DIR / "input") as f: 11 | s = (f.read() if teststr == "" else teststr).splitlines()[0] 12 | return np.array(lmap(int, s), dtype=np.uint8) 13 | 14 | 15 | def iterate(data): 16 | a = data 17 | b = np.flip(data) 18 | b = 1 - b 19 | return np.hstack((a, [0], b)) 20 | 21 | 22 | def fill(length, data): 23 | if data.size < length: 24 | return fill(length, iterate(data)) 25 | return data[:length] 26 | 27 | 28 | def hash(data): 29 | h = np.zeros(data.size // 2, dtype=np.uint8) 30 | for i in range(data.size)[::2]: 31 | a, b = data[i : i + 2] 32 | if a == b: 33 | h[i // 2] = 1 34 | if h.size % 2: 35 | return h 36 | return hash(h) 37 | 38 | 39 | def hash_print(h): 40 | print("".join(map(str, h))) 41 | 42 | 43 | def easy(): 44 | hash_print(hash(fill(272, t))) 45 | 46 | 47 | def hard(): 48 | hash_print(hash(fill(35651584, t))) 49 | 50 | 51 | teststr = """""" 52 | DIR = pathlib.Path(__file__).parent.absolute() 53 | t = read() 54 | if __name__ == "__main__": 55 | easy() 56 | hard() 57 | -------------------------------------------------------------------------------- /2017/12/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | s = f.read() if teststr == "" else teststr 11 | return { 12 | k: v 13 | for k, v in map( 14 | lambda r: ( 15 | int(r.split(" <-> ")[0]), 16 | lmap(int, r.split(" <-> ")[1].split(", ")), 17 | ), 18 | s.splitlines(), 19 | ) 20 | } 21 | 22 | 23 | def visit(from_point): 24 | next_set = {from_point} 25 | visited = {from_point} 26 | while next_set: 27 | p = list(next_set)[0] 28 | next_set.discard(p) 29 | for o in t[p]: 30 | if o not in visited: 31 | next_set.add(o) 32 | visited.add(o) 33 | return visited 34 | 35 | 36 | def easy(): 37 | print(len(visit(0))) 38 | 39 | 40 | def hard(): 41 | pool = set(t.keys()) 42 | c = 0 43 | while pool: 44 | c += 1 45 | p = list(pool)[0] 46 | pool -= visit(p) 47 | print(c) 48 | 49 | 50 | teststr = """""" 51 | DIR = pathlib.Path(__file__).parent.absolute() 52 | t = read() 53 | if __name__ == "__main__": 54 | easy() 55 | hard() 56 | -------------------------------------------------------------------------------- /2018/11/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | serial = open(pathlib.Path(__file__).parent / "input").read().splitlines()[0] 4 | serial = int(serial) % 1000 5 | 6 | 7 | def main(): 8 | global serial 9 | 10 | arr = [[0 for _ in range(300)] for _ in range(300)] 11 | 12 | rack = 10 13 | for x in range(300): 14 | rack += 1 15 | level = 0 16 | for y in range(300): 17 | level += rack 18 | arr[x][y] = (rack * (level + serial)) // 100 % 10 - 5 19 | 20 | sums = {} 21 | for size in [3] + list(range(10, 21)): 22 | for x in range(300 - size + 1): 23 | for y in range(300 - size + 1): 24 | s = 0 25 | for col in arr[x : (x + size)]: 26 | for el in col[y : (y + size)]: 27 | s += el 28 | sums["%d,%d,%d" % (x + 1, y + 1, size)] = s 29 | max3 = max = max_ind = max_ind3 = 0 30 | for ind in sums: 31 | if sums[ind] > max: 32 | max = sums[ind] 33 | max_ind = ind 34 | if sums[ind] > max3 and ind[-2:] == ",3": 35 | max3 = sums[ind] 36 | max_ind3 = ind 37 | print(max_ind3[:-2]) 38 | print(max_ind) 39 | 40 | 41 | main() 42 | -------------------------------------------------------------------------------- /2018/05/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | input = open(pathlib.Path(__file__).parent / "input").read().replace("\n", "") 4 | 5 | 6 | from string import ascii_lowercase as letters 7 | 8 | 9 | def easy(): 10 | global input 11 | 12 | i = 0 13 | while i < len(input) - 1: 14 | c1 = input[i] 15 | c2 = input[i + 1] 16 | 17 | if c1.lower() == c2.lower() and c1 != c2: 18 | input = input[:i] + input[i + 2 :] 19 | if i > 0: 20 | i -= 1 21 | else: 22 | i += 1 23 | 24 | print(len(input)) 25 | 26 | 27 | easy() 28 | 29 | 30 | def hard(): 31 | global input 32 | 33 | lengths = [] 34 | for letter in letters: 35 | new_input = input.replace(letter, "").replace(letter.upper(), "") 36 | i = 0 37 | while i < len(new_input) - 1: 38 | c1 = new_input[i] 39 | c2 = new_input[i + 1] 40 | 41 | if c1.lower() == c2.lower() and c1 != c2: 42 | new_input = new_input[:i] + new_input[i + 2 :] 43 | if i > 0: 44 | i -= 1 45 | else: 46 | i += 1 47 | 48 | lengths.append(len(new_input)) 49 | 50 | print(min(lengths)) 51 | 52 | 53 | hard() 54 | -------------------------------------------------------------------------------- /2021/10/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | return (f.read() if teststr == "" else teststr).splitlines() 7 | 8 | 9 | S = { 10 | ")": 3, 11 | "]": 57, 12 | "}": 1197, 13 | ">": 25137, 14 | } 15 | B = "([{<)]}>" 16 | 17 | 18 | def easy(): 19 | E = 0 20 | for l in t: 21 | I.append(l) 22 | s = [] 23 | for c in l: 24 | i = B.index(c) 25 | if i < 4: 26 | s += [i] 27 | else: 28 | if s[-1] != i - 4: 29 | E += S[c] 30 | I.pop() 31 | break 32 | s.pop() 33 | print(E) 34 | 35 | 36 | def hard(): 37 | E = [] 38 | for l in I: 39 | s, S = [], 0 40 | for c in l: 41 | i = B.index(c) 42 | if i < 4: 43 | s += [i] 44 | else: 45 | s.pop() 46 | for c in reversed(s): 47 | S *= 5 48 | S += c + 1 49 | E.append(S) 50 | print(sorted(E)[len(E) // 2]) 51 | 52 | 53 | teststr = """""" 54 | DIR = pathlib.Path(__file__).parent.absolute() 55 | t, I = read(), [] 56 | if __name__ == "__main__": 57 | easy() 58 | hard() 59 | -------------------------------------------------------------------------------- /2022/04/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import re 3 | import pathlib 4 | import json 5 | from functools import reduce 6 | from string import ascii_lowercase 7 | from math import prod, gcd, sqrt 8 | from itertools import permutations, product 9 | from llist import dllist as llist 10 | from copy import deepcopy 11 | from hashlib import md5, sha256 12 | 13 | 14 | def read(): 15 | with open(DIR / "input") as f: 16 | s = (f.read() if teststr == "" else teststr).splitlines() 17 | return lmap(lambda r: lmap(lambda x: lmap(int, x.split("-")), r.split(",")), s) 18 | 19 | 20 | def easy(): 21 | s = 0 22 | for left, right in t: 23 | if left[0] >= right[0] and left[1] <= right[1]: 24 | s += 1 25 | elif right[0] >= left[0] and right[1] <= left[1]: 26 | s += 1 27 | print(s) 28 | 29 | 30 | def hard(): 31 | s = 0 32 | for left, right in t: 33 | if left[0] <= right[0] <= left[1]: 34 | s += 1 35 | elif right[0] <= left[0] <= right[1]: 36 | s += 1 37 | print(s) 38 | 39 | 40 | teststr = """""" 41 | DIR = pathlib.Path(__file__).parent.absolute() 42 | lmap = lambda *a: list(map(*a)) 43 | inf = float("inf") 44 | t = read() 45 | if __name__ == "__main__": 46 | easy() 47 | hard() 48 | -------------------------------------------------------------------------------- /2020/01/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | DIR = pathlib.Path(__file__).parent.absolute() 4 | 5 | 6 | def easy(): 7 | with open(DIR / "input") as f: 8 | t = f.read().replace("\r", "").splitlines() 9 | 10 | t = [int(i) for i in t] 11 | t.sort() 12 | 13 | for i in range(len(t)): 14 | for j in range(len(t)): 15 | j = len(t) - j - 1 16 | a = t[i] 17 | b = t[j] 18 | if a + b == 2020: 19 | print(a * b) 20 | return 21 | if a + b < 2020: 22 | break 23 | 24 | 25 | def hard(): 26 | with open(DIR / "input") as f: 27 | t = f.read().replace("\r", "").splitlines() 28 | 29 | t = [int(i) for i in t] 30 | t.sort() 31 | 32 | n = len(t) 33 | for i in range(n): 34 | for j in range(n): 35 | for k in range(n): 36 | j = n - j - 1 37 | k = n - k - 1 38 | a = t[i] 39 | b = t[j] 40 | c = t[k] 41 | if a + b + c == 2020: 42 | print(a * b * c) 43 | return 44 | if a + b + c < 2020: 45 | break 46 | 47 | 48 | if __name__ == "__main__": 49 | easy() 50 | hard() 51 | -------------------------------------------------------------------------------- /2015/23/main.py: -------------------------------------------------------------------------------- 1 | import re 2 | import pathlib 3 | 4 | 5 | def may_int(s): 6 | if s in "ab": 7 | return "ab".index(s) 8 | try: 9 | return int(s) 10 | except: 11 | return s 12 | 13 | 14 | def read(): 15 | with open(DIR / "input") as f: 16 | s = re.sub(r"[\+,]", "", f.read() if teststr == "" else teststr).splitlines() 17 | return lmap(lambda r: lmap(may_int, r.split(" ")), s) 18 | 19 | 20 | def do(i): 21 | ins = t[i] 22 | if ins[0] == "hlf": 23 | r[ins[1]] //= 2 24 | if ins[0] == "tpl": 25 | r[ins[1]] *= 3 26 | if ins[0] == "inc": 27 | r[ins[1]] += 1 28 | if ins[0] == "jmp": 29 | return ins[1] 30 | if ins[0] == "jie" and not (r[ins[1]] % 2): 31 | return ins[2] 32 | if ins[0] == "jio" and r[ins[1]] == 1: 33 | return ins[2] 34 | return 1 35 | 36 | 37 | def run(a): 38 | i, N, r[0], r[1] = 0, len(t), a, 0 39 | while i < N: 40 | i += do(i) 41 | print(r[1]) 42 | 43 | 44 | def easy(): 45 | run(0) 46 | 47 | 48 | def hard(): 49 | run(1) 50 | 51 | 52 | teststr = """""" 53 | DIR = pathlib.Path(__file__).parent.absolute() 54 | lmap = lambda *a: list(map(*a)) 55 | t, r = read(), [0, 0] 56 | if __name__ == "__main__": 57 | easy() 58 | hard() 59 | -------------------------------------------------------------------------------- /2017/03/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from math import sqrt 3 | 4 | 5 | def read(): 6 | with open(DIR / "input") as f: 7 | t = int(f.read().splitlines()[0]) 8 | return t 9 | 10 | 11 | def pos(n): 12 | c = int(sqrt(n - 1)) 13 | c -= (c + 1) % 2 14 | n -= c ** 2 15 | ps = [] 16 | 17 | p = (c // 2 + 1, c // 2 + 1) 18 | 19 | for m in [(0, -1), (-1, 0), (0, 1), (1, 0)]: 20 | for _ in range(c + 1): 21 | if n <= 0: 22 | break 23 | n -= 1 24 | p = (p[0] + m[0], p[1] + m[1]) 25 | ps.append(p) 26 | 27 | return ps 28 | 29 | 30 | def easy(): 31 | print(sum(map(abs, pos(t)[-1]))) 32 | 33 | 34 | def adj(p, v): 35 | s = 0 36 | for m in [(-1, 1), (0, 1), (1, 1), (-1, 0), (1, 0), (-1, -1), (0, -1), (1, -1)]: 37 | s += v.get((p[0] + m[0], p[1] + m[1]), 0) 38 | return s 39 | 40 | 41 | def hard(): 42 | v = {(0, 0): 1} 43 | for n in range(1, t): 44 | for p in pos((n * 2 + 1) ** 2): 45 | n = adj(p, v) 46 | if n > t: 47 | print(n) 48 | return 49 | v[p] = n 50 | 51 | 52 | DIR = pathlib.Path(__file__).parent.absolute() 53 | t = read() 54 | if __name__ == "__main__": 55 | easy() 56 | hard() 57 | -------------------------------------------------------------------------------- /2021/14/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | s = (f.read() if teststr == "" else teststr).splitlines() 7 | return s[0], {k: v for k, v in map(lambda r: r.split(" -> "), s[2:])} 8 | 9 | 10 | def easy(): 11 | s = S 12 | for _ in range(10): 13 | i = 0 14 | while i < len(s) - 1: 15 | s = s[: i + 1] + R[s[i : i + 2]] + s[i + 1 :] 16 | i += 2 17 | counts = [s.count(i) for i in R.values()] 18 | print(max(counts) - min(counts)) 19 | 20 | 21 | def hard(): 22 | r_ = r = {i: S.count(i) for i in R.keys()} 23 | n = {i: [] for i in R.keys()} 24 | for k, v in R.items(): 25 | n[k] += [k[0] + v, v + k[1]] 26 | for _ in range(40): 27 | r, r_ = r_, {i: 0 for i in R.keys()} 28 | for k, v in r.items(): 29 | for nk in n[k]: 30 | r_[nk] += v 31 | a = {v: 0 for _, v in R} 32 | for k, v in r_.items(): 33 | a[k[0]] += v / 2 34 | a[k[1]] += v / 2 35 | a[S[0]] += 0.5 36 | a[S[-1]] += 0.5 37 | print(int(max(a.values())) - int(min(a.values()))) 38 | 39 | 40 | teststr = """""" 41 | DIR = pathlib.Path(__file__).parent.absolute() 42 | S, R = read() 43 | if __name__ == "__main__": 44 | easy() 45 | hard() 46 | -------------------------------------------------------------------------------- /2015/21/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | from itertools import product 4 | 5 | 6 | def read(): 7 | with open(DIR / "input") as f: 8 | s = (f.read() if teststr == "" else teststr).splitlines() 9 | return np.array(lmap(lambda r: int(r.split(" ")[-1]), s)) 10 | 11 | 12 | def wins(_, dmg, amr): 13 | dmg = max(1, dmg - t[2]) 14 | enemy_d = max(1, t[1] - amr) 15 | turns = (t[0] - 1) // dmg + 1 16 | enemy_t = (100 - 1) // enemy_d + 1 17 | return enemy_t >= turns 18 | 19 | 20 | W = np.array([[8, 4, 0], [10, 5, 0], [25, 6, 0], [40, 7, 0], [74, 8, 0]]) 21 | A = np.array([[13, 0, 1], [31, 0, 2], [53, 0, 3], [75, 0, 4], [102, 0, 5]]) 22 | R = np.array([[25, 1, 0], [50, 2, 0], [100, 3, 0], [20, 0, 1], [40, 0, 2], [80, 0, 3]]) 23 | A, R, n = np.vstack([A, [[0, 0, 0]]]), np.vstack([R, [[0, 0, 0]]]), len(R) 24 | for i in range(n): 25 | for j in range(i + 1, n): 26 | R = np.vstack([R, R[i] + R[j]]) 27 | 28 | teststr = """""" 29 | DIR = pathlib.Path(__file__).parent.absolute() 30 | lmap = lambda *a: list(map(*a)) 31 | t = read() 32 | if __name__ == "__main__": 33 | win = [(wins(*(w + a + r)), (w + a + r)[0]) for w, a, r in product(W, A, R)] 34 | print(min([cost for wins, cost in win if wins])) 35 | print(max([cost for wins, cost in win if not wins])) 36 | -------------------------------------------------------------------------------- /2018/02/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | input = list( 4 | map(str, open(pathlib.Path(__file__).parent / "input").read().splitlines()) 5 | ) 6 | 7 | 8 | def main(): 9 | twos = 0 10 | threes = 0 11 | 12 | for i in input: 13 | d = dict() 14 | for letter in i: 15 | d[letter] = d.get(letter, 0) + 1 16 | was_two = False 17 | was_three = False 18 | for v in d.values(): 19 | if not was_two and v == 2: 20 | twos += 1 21 | was_two = True 22 | elif not was_three and v == 3: 23 | threes += 1 24 | was_three = True 25 | 26 | print(twos * threes) 27 | 28 | 29 | n = len(input[0]) 30 | for i in range(len(input)): 31 | for j_ in range(len(input) - i - 1): 32 | j = j_ + i + 1 33 | wrong = 0 34 | for k in range(n): 35 | if input[i][k] != input[j][k]: 36 | wrong += 1 37 | if wrong > 1: 38 | break 39 | if wrong == 1: 40 | for a, b in zip(input[i], input[j]): 41 | if a == b: 42 | print(a, end="") 43 | print() 44 | return 45 | 46 | 47 | main() 48 | -------------------------------------------------------------------------------- /2023/02/main.py: -------------------------------------------------------------------------------- 1 | with open("input") as f: 2 | text = f.read() 3 | 4 | maximums = { 5 | "red": 12, 6 | "green": 13, 7 | "blue": 14, 8 | } 9 | 10 | sum_of_ids = 0 11 | for line in text.splitlines(): 12 | game_id = line.split(":")[0].split(" ")[1] 13 | draws = line.split(": ")[1] 14 | is_possible = True 15 | for draw in draws.split("; "): 16 | for color in draw.split(", "): 17 | color_name = color.split(" ")[1] 18 | number = int(color.split(" ")[0]) 19 | 20 | if number > maximums[color_name]: 21 | is_possible = False 22 | if is_possible: 23 | sum_of_ids += int(game_id) 24 | 25 | print(sum_of_ids) 26 | 27 | sum_of_powers = 0 28 | for line in text.splitlines(): 29 | game_id = line.split(":")[0].split(" ")[1] 30 | draws = line.split(": ")[1] 31 | minimums = { 32 | "red": 0, 33 | "green": 0, 34 | "blue": 0, 35 | } 36 | for draw in draws.split("; "): 37 | for color in draw.split(", "): 38 | color_name = color.split(" ")[1] 39 | number = int(color.split(" ")[0]) 40 | 41 | minimums[color_name] = max(minimums[color_name], number) 42 | sum_of_powers += minimums["red"] * minimums["green"] * minimums["blue"] 43 | 44 | print(sum_of_powers) 45 | -------------------------------------------------------------------------------- /2015/13/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from itertools import permutations 3 | from copy import deepcopy 4 | 5 | 6 | def read(): 7 | with open(DIR / "input") as f: 8 | s = ( 9 | (f.read() if teststr == "" else teststr) 10 | .replace("lose ", "-") 11 | .replace("gain ", "") 12 | .replace(".", "") 13 | .splitlines() 14 | ) 15 | return {(r.split(" ")[0], r.split(" ")[-1]): int(r.split(" ")[2]) for r in s} 16 | 17 | 18 | def score(perm, n): 19 | s = 0 20 | for i in range(n): 21 | s += t.get((perm[i], perm[(i + 1) % n]), 0) 22 | return s 23 | 24 | 25 | def find(names): 26 | i, s, n = 0, {}, len(names) 27 | for perm in permutations(names): 28 | s[i] = score(perm, n) 29 | i += 1 30 | print(max(s.values())) 31 | 32 | 33 | def easy(): 34 | t_ = deepcopy(t) 35 | for index in t.keys(): 36 | l, r = index 37 | t[(l, r)] += t_[(r, l)] 38 | find([v[0] for v in list(sorted(t.keys()))[:: int(len(t) ** 0.5)]]) 39 | 40 | 41 | def hard(): 42 | find([v[0] for v in list(sorted(t.keys()))[:: int(len(t) ** 0.5)]] + [""]) 43 | 44 | 45 | teststr = """""" 46 | DIR = pathlib.Path(__file__).parent.absolute() 47 | t = read() 48 | if __name__ == "__main__": 49 | easy() 50 | hard() 51 | -------------------------------------------------------------------------------- /2017/20/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | 4 | 5 | def lmap(*a): 6 | return list(map(*a)) 7 | 8 | 9 | def read(): 10 | with open(DIR / "input") as f: 11 | s = f.read() if teststr == "" else teststr 12 | return lmap( 13 | lambda r: lmap( 14 | lambda i: np.array(lmap(int, i[3:-1].split(",")), int), r.split(", ") 15 | ), 16 | s.splitlines(), 17 | ) 18 | 19 | 20 | def easy(): 21 | m = (inf, inf) 22 | for i, r in enumerate(t): 23 | s_a = sum(map(abs, r[2] * 10000 + r[1])) 24 | if s_a < m[0]: 25 | m = (s_a, i) 26 | print(m[1]) 27 | 28 | 29 | def hard(): 30 | for _ in range(10 ** 3): 31 | p = {} 32 | for i, r in enumerate(t): 33 | r[1] += r[2] 34 | r[0] += r[1] 35 | tp = tuple(r[0]) 36 | p[tp] = p.get(tp, []) + [i] 37 | removed = [] 38 | for l in p.values(): 39 | if len(l) < 2: 40 | continue 41 | removed.extend(l) 42 | for i in reversed(sorted(removed)): 43 | del t[i] 44 | print(len(t)) 45 | 46 | 47 | teststr = """""" 48 | DIR = pathlib.Path(__file__).parent.absolute() 49 | inf = float("inf") 50 | t = read() 51 | if __name__ == "__main__": 52 | easy() 53 | hard() 54 | -------------------------------------------------------------------------------- /2020/02/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | DIR = pathlib.Path(__file__).parent.absolute() 4 | 5 | 6 | def easy(): 7 | with open(DIR / "input") as f: 8 | t = f.read().replace("\r", "").splitlines() 9 | 10 | t_ = [] 11 | for l in t: 12 | l = l.split("-") 13 | a = int(l[0]) 14 | l = l[1].split(" ") 15 | b = int(l[0]) 16 | c = l[1][0] 17 | d = l[-1] 18 | 19 | t_.append((a, b, c, d)) 20 | t = t_ 21 | 22 | correct = 0 23 | for i in t: 24 | a, b, c, d = i 25 | n = len(list(filter(lambda i: i == c, d))) 26 | if a <= n <= b: 27 | correct += 1 28 | 29 | print(correct) 30 | 31 | 32 | def hard(): 33 | with open(DIR / "input") as f: 34 | t = f.read().replace("\r", "").splitlines() 35 | 36 | t_ = [] 37 | for l in t: 38 | l = l.split("-") 39 | a = int(l[0]) 40 | l = l[1].split(" ") 41 | b = int(l[0]) 42 | c = l[1][0] 43 | d = l[-1] 44 | 45 | t_.append((a, b, c, d)) 46 | t = t_ 47 | 48 | correct = 0 49 | for i in t: 50 | a, b, c, d = i 51 | if (d[a - 1] == c) != (d[b - 1] == c): 52 | correct += 1 53 | 54 | print(correct) 55 | 56 | 57 | if __name__ == "__main__": 58 | easy() 59 | hard() 60 | -------------------------------------------------------------------------------- /2021/03/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | 4 | 5 | def read(): 6 | with open(DIR / "input") as f: 7 | s = (f.read() if teststr == "" else teststr).splitlines() 8 | return lmap(lambda r: lmap(int, r), s) 9 | 10 | 11 | def easy(): 12 | counts = [[0, 0] for _ in t[0]] 13 | for line in t: 14 | for i, c in enumerate(line): 15 | counts[i][c] += 1 16 | a = "" 17 | for i, c in enumerate(counts): 18 | m = max(c) 19 | a += "1" if m == c[1] else "0" 20 | b = [("1" if c == "0" else "0") for c in a] 21 | a = int(a, base=2) 22 | b = int("".join(b), base=2) 23 | print(a * b) 24 | 25 | 26 | def val(default): 27 | A = np.array(t) 28 | 29 | i = 0 30 | while True: 31 | n = len(A) 32 | if n == 1: 33 | return A[0] 34 | bits = A[:, i] 35 | s = bits.sum() 36 | a = 1 - default 37 | if s >= n / 2: 38 | a = default 39 | A = A[A[:, i] == a, :] 40 | i += 1 41 | 42 | 43 | teststr = """""" 44 | DIR = pathlib.Path(__file__).parent.absolute() 45 | lmap = lambda *a: list(map(*a)) 46 | t = read() 47 | if __name__ == "__main__": 48 | easy() 49 | print( 50 | int("".join(map(str, val(1))), base=2) * int("".join(map(str, val(0))), base=2) 51 | ) 52 | -------------------------------------------------------------------------------- /2017/10/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from functools import reduce 3 | 4 | 5 | def lmap(*a): 6 | return list(map(*a)) 7 | 8 | 9 | def read(hard=0): 10 | with open(DIR / "input") as f: 11 | s = f.read() if teststr == "" else teststr 12 | if hard: 13 | return lmap(ord, s.splitlines()[0]) 14 | return lmap(int, s.splitlines()[0].split(",")) 15 | 16 | 17 | def easy(): 18 | hash() 19 | print(T[0] * T[1]) 20 | 21 | 22 | def hash(i=0, s=0): 23 | global T 24 | for l in t: 25 | i %= N 26 | T = T + T 27 | j = i + l 28 | r = T[i:j] 29 | r.reverse() 30 | T = T[:i] + r + T[j:] 31 | T = T[N : N + i] + T[i:N] 32 | i += l + s 33 | s += 1 34 | return i, s 35 | 36 | 37 | def hard(): 38 | global T 39 | T = list(range(N)) 40 | t.extend([17, 31, 73, 47, 23]) 41 | i = s = 0 42 | for _ in range(64): 43 | i, s = hash(i, s) 44 | r = map(lambda i: reduce(lambda a, b: a ^ b, T[i * 16 : i * 16 + 16], 0), range(16)) 45 | print(("%02x" * 16) % tuple(r)) 46 | 47 | 48 | teststr = "" # "AoC 2017" # """3,4,1,5""" 49 | DIR = pathlib.Path(__file__).parent.absolute() 50 | t = read() 51 | N = 256 # 5 52 | T = list(range(N)) 53 | if __name__ == "__main__": 54 | easy() 55 | t = read(1) 56 | hard() 57 | -------------------------------------------------------------------------------- /2018/23/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | import z3 3 | 4 | 5 | def read(): 6 | with open(DIR / "input") as f: 7 | t = f.read().splitlines() 8 | t = list( 9 | map( 10 | lambda l: ( 11 | tuple(map(int, l.split("<")[1].split(">")[0].split(","))), 12 | int(l.split("=")[-1]), 13 | ), 14 | t, 15 | ) 16 | ) 17 | return t 18 | 19 | 20 | def dist(a, b): 21 | return sum([abs(a[0] - b[0]), abs(a[1] - b[1]), abs(a[2] - b[2])]) 22 | 23 | 24 | def count(m): 25 | c = 0 26 | for l in t: 27 | if dist(m[0], l[0]) <= m[1]: 28 | c += 1 29 | return c 30 | 31 | 32 | def easy(): 33 | t.sort(key=lambda i: i[1]) 34 | m = t[-1] 35 | 36 | print(count(m)) 37 | 38 | 39 | def hard(): 40 | o = z3.Optimize() 41 | x, y, z = z3.Ints("x y z") 42 | 43 | for p, d in t: 44 | o.add_soft( 45 | z3.If(x > p[0], x - p[0], p[0] - x) 46 | + z3.If(y > p[1], y - p[1], p[1] - y) 47 | + z3.If(z > p[2], z - p[2], p[2] - z) 48 | <= d 49 | ) 50 | o.check() 51 | m = o.model() 52 | print(m.eval(x + y + z)) 53 | 54 | 55 | DIR = pathlib.Path(__file__).parent.absolute() 56 | t = read() 57 | if __name__ == "__main__": 58 | easy() 59 | hard() 60 | -------------------------------------------------------------------------------- /2015/11/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | z = ord("z") 4 | a = ord("a") 5 | 6 | 7 | def count_up(pw, digit=0): 8 | c = ord(pw[-1 - digit]) + (2 if pw[-1 - digit] in "hnk" else 1) 9 | if c > z: 10 | c = a 11 | pw[-1 - digit] = chr(c) 12 | if c == a: 13 | count_up(pw, digit + 1) 14 | return pw 15 | 16 | 17 | def read(): 18 | with open(DIR / "input") as f: 19 | return (f.read() if teststr == "" else teststr).splitlines()[0] 20 | 21 | 22 | def meets(pw): 23 | if "i" in pw or "o" in pw or "l" in pw: 24 | return False 25 | last = count_abc = aa = abc = skip_last = 0 26 | for c in pw: 27 | c, skip_last = ord(c), skip_last - 1 28 | if last == c and skip_last != 0: 29 | aa, skip_last = aa + 1, 1 30 | if c == last + 1: 31 | count_abc += 1 32 | if count_abc == 2: 33 | abc = 1 34 | else: 35 | count_abc = 0 36 | last = c 37 | return aa >= 2 and abc 38 | 39 | 40 | teststr = """""" 41 | DIR = pathlib.Path(__file__).parent.absolute() 42 | t = read() 43 | if __name__ == "__main__": 44 | pw = list(t) 45 | while not meets(pw): 46 | count_up(pw) 47 | print("".join(pw)) 48 | count_up(pw) 49 | while not meets(pw): 50 | count_up(pw) 51 | print("".join(pw)) 52 | -------------------------------------------------------------------------------- /2018/03/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | input = list( 4 | map(str, open(pathlib.Path(__file__).parent / "input").read().splitlines()) 5 | ) 6 | 7 | arr = [[0 for _ in range(1000)] for _ in range(1000)] 8 | 9 | 10 | for i in input: 11 | i = i.split(" ") 12 | p = i[2].split(",") 13 | p[1] = p[1][:-1] 14 | s = i[-1].split("x") 15 | p = [int(p[0]), int(p[1])] 16 | s = [int(s[0]), int(s[1])] 17 | 18 | for x in range(p[0], p[0] + s[0]): 19 | for y in range(p[1], p[1] + s[1]): 20 | arr[x][y] += 1 21 | 22 | 23 | count = 0 24 | for a in arr: 25 | for i in a: 26 | if i > 1: 27 | count += 1 28 | print(count) 29 | 30 | 31 | arr = [[0 for _ in range(1000)] for _ in range(1000)] 32 | 33 | claim = {i: True for i in range(len(input))} 34 | 35 | for k in range(len(input)): 36 | i = input[k] 37 | i = i.split(" ") 38 | p = i[2].split(",") 39 | p[1] = p[1][:-1] 40 | s = i[-1].split("x") 41 | p = [int(p[0]), int(p[1])] 42 | s = [int(s[0]), int(s[1])] 43 | 44 | for x in range(p[0], p[0] + s[0]): 45 | for y in range(p[1], p[1] + s[1]): 46 | if arr[x][y] != 0: 47 | claim[k] = False 48 | claim[arr[x][y] - 1] = False 49 | arr[x][y] = k + 1 50 | 51 | for c in claim: 52 | if claim[c]: 53 | print(c + 1) -------------------------------------------------------------------------------- /2016/02/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | s = (f.read() if teststr == "" else teststr).splitlines() 11 | return lmap(list, s) 12 | 13 | 14 | def numpad(vector, S=None): 15 | y, x = vector 16 | if S: 17 | return S.splitlines()[1:][y][x] 18 | return y * 3 + x + 1 19 | 20 | 21 | def easy(): 22 | p, s = (1, 1), "" 23 | for r in t: 24 | for m in r: 25 | m = {"U": (-1, 0), "D": (1, 0), "L": (0, -1), "R": (0, 1)}[m] 26 | p = tuple(map(lambda i: min(2, max(0, i)), (p[0] + m[0], p[1] + m[1]))) 27 | s += str(numpad(p)) 28 | print(s) 29 | 30 | 31 | def hard(): 32 | p, s = (2, 0), "" 33 | for r in t: 34 | for m in r: 35 | m = {"U": (-1, 0), "D": (1, 0), "L": (0, -1), "R": (0, 1)}[m] 36 | p_ = tuple(map(lambda i: min(4, max(0, i)), (p[0] + m[0], p[1] + m[1]))) 37 | if sum(map(lambda i: abs(i - 2), p_)) <= 2: 38 | p = p_ 39 | s += str(numpad(p, P)) 40 | print(s) 41 | 42 | 43 | teststr = """""" 44 | DIR = pathlib.Path(__file__).parent.absolute() 45 | t = read() 46 | P = """ 47 | 1 48 | 234 49 | 56789 50 | ABC 51 | D 52 | """ 53 | if __name__ == "__main__": 54 | easy() 55 | hard() 56 | -------------------------------------------------------------------------------- /2021/17/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | s = (f.read() if teststr == "" else teststr).splitlines()[0] 7 | return lmap(int, s.split("x=")[1].replace(", y=", "..").split("..")) 8 | 9 | 10 | def step(x, y, vx, vy): 11 | x += vx 12 | y += vy 13 | vx -= 1 if vx > 0 else 0 14 | vy -= 1 15 | return x, y, vx, vy 16 | 17 | 18 | def run(vx, vy): 19 | x = y = 0 20 | while x <= xmax and y >= ymin and (x < xmin or y > ymax): 21 | x, y, vx, vy = step(x, y, vx, vy) 22 | return x <= xmax and y >= ymin 23 | 24 | 25 | def easy(): 26 | for i in range(-ymin): 27 | startval = i = -ymin - i 28 | y = 0 29 | while y > ymax: 30 | y -= i 31 | i += 1 32 | if y < ymin: 33 | continue 34 | return print(sumto(startval - 1)) 35 | 36 | 37 | def hard(): 38 | pairs = [] 39 | for vx in range(xmax + 1): 40 | for vy in range(ymin, -ymin): 41 | if run(vx, vy): 42 | pairs.append((vx, vy)) 43 | print(len(pairs)) 44 | 45 | 46 | teststr = """""" 47 | DIR = pathlib.Path(__file__).parent.absolute() 48 | lmap = lambda *a: list(map(*a)) 49 | sumto = lambda x: (x + 1) * x // 2 50 | xmin, xmax, ymin, ymax = read() 51 | if __name__ == "__main__": 52 | easy() 53 | hard() 54 | -------------------------------------------------------------------------------- /2015/16/main.py: -------------------------------------------------------------------------------- 1 | import re 2 | import pathlib 3 | 4 | 5 | def read(): 6 | with open(DIR / "input") as f: 7 | s = re.sub( 8 | r"Sue \d+: ", "", (f.read() if teststr == "" else teststr) 9 | ).splitlines() 10 | return lmap(lambda r: lmap(str, r.split(", ")), s) 11 | 12 | 13 | def easy(): 14 | print([i + 1 for i, s in enumerate(t) if len(set(s) & set(card)) == 3][0]) 15 | 16 | 17 | def hard(): 18 | c = {l.split(": ")[0]: int(l.split(": ")[1]) for l in card} 19 | for i, a in enumerate(t): 20 | s = 0 21 | for l in a: 22 | name, val = l.split(": ")[0], int(l.split(": ")[1]) 23 | if name in ["cats", "trees"]: 24 | s += 1 if val > c[name] else 0 25 | elif name in ["pomeranians", "goldfish"]: 26 | s += 1 if val < c[name] else 0 27 | else: 28 | s += 1 if val == c[name] else 0 29 | print(i + 1 if s == 3 else "", end="\n" if s == 3 else "") 30 | 31 | 32 | card = """children: 3 33 | cats: 7 34 | samoyeds: 2 35 | pomeranians: 3 36 | akitas: 0 37 | vizslas: 0 38 | goldfish: 5 39 | trees: 3 40 | cars: 2 41 | perfumes: 1""".splitlines() 42 | teststr = """""" 43 | DIR = pathlib.Path(__file__).parent.absolute() 44 | lmap = lambda *a: list(map(*a)) 45 | t = read() 46 | if __name__ == "__main__": 47 | easy() 48 | hard() 49 | -------------------------------------------------------------------------------- /2022/03/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import re 3 | import pathlib 4 | import json 5 | from functools import reduce 6 | from string import ascii_lowercase 7 | from math import prod, gcd, sqrt 8 | from itertools import permutations, product 9 | from llist import dllist as llist 10 | from copy import deepcopy 11 | from hashlib import md5, sha256 12 | 13 | 14 | def read(): 15 | with open(DIR / "input") as f: 16 | s = (f.read() if teststr == "" else teststr).splitlines() 17 | return lmap(lambda r: lmap(str, r), s) 18 | 19 | 20 | def prio(c): 21 | return chars.find(c) + 1 22 | 23 | 24 | def easy(): 25 | s = 0 26 | for line in t: 27 | first = set(line[: len(line) // 2]) 28 | second = set(line[len(line) // 2 :]) 29 | overlap = list(first & second)[0] 30 | s += prio(overlap) 31 | print(s) 32 | 33 | 34 | def hard(): 35 | s = 0 36 | for i in range(len(t))[::3]: 37 | o = reduce(lambda x, y: x & y, map(set, t[i : i + 3]), set(chars)) 38 | o = list(o)[0] 39 | s += prio(o) 40 | print(s) 41 | 42 | 43 | teststr = """""" 44 | DIR = pathlib.Path(__file__).parent.absolute() 45 | lmap = lambda *a: list(map(*a)) 46 | smap = lambda *a: set(map(*a)) 47 | inf = float("inf") 48 | chars = ascii_lowercase + ascii_lowercase.upper() 49 | t = read() 50 | if __name__ == "__main__": 51 | easy() 52 | hard() 53 | -------------------------------------------------------------------------------- /2021/20/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import re 3 | import pathlib 4 | import json 5 | from functools import reduce 6 | from string import ascii_lowercase 7 | from math import prod, gcd, sqrt 8 | from itertools import permutations, product 9 | from llist import dllist as llist 10 | from copy import deepcopy 11 | from hashlib import md5, sha256 12 | 13 | 14 | def read(): 15 | with open(DIR / "input") as f: 16 | s = (f.read() if teststr == "" else teststr).splitlines() 17 | return lmap(".#".index, s[0]), np.array(lmap(lambda r: lmap(".#".index, r), s[2:])) 18 | 19 | 20 | def step(array): 21 | array = np.pad(array, ((3, 3), (3, 3)), "edge") 22 | new = np.zeros_like(array) 23 | for i in range(array.shape[0] - 2): 24 | for j in range(array.shape[1] - 2): 25 | n = int("".join(lmap(str, array[i : i + 3, j : j + 3].flatten())), 2) 26 | new[i + 1, j + 1] = band[n] 27 | return new[1:-1, 1:-1] 28 | 29 | 30 | def easy(): 31 | print(step(step(np.pad(t, ((1, 1), (1, 1))))).sum()) 32 | 33 | 34 | def hard(): 35 | a = reduce(lambda old, _: step(old), range(50), np.pad(t, ((1, 1), (1, 1)))) 36 | print(a.sum()) 37 | 38 | 39 | teststr = "" 40 | DIR = pathlib.Path(__file__).parent.absolute() 41 | lmap = lambda *a: list(map(*a)) 42 | inf = float("inf") 43 | band, t = read() 44 | if __name__ == "__main__": 45 | easy() 46 | hard() 47 | -------------------------------------------------------------------------------- /2023/01/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import re 3 | import pathlib 4 | import json 5 | from functools import reduce 6 | from string import ascii_lowercase 7 | from math import prod, gcd, sqrt 8 | from itertools import permutations, product 9 | from llist import dllist as llist 10 | from copy import deepcopy 11 | from hashlib import md5, sha256 12 | from os import environ 13 | 14 | numbers = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] 15 | 16 | 17 | def replace_one(r): 18 | return re.sub("[^0-9]", "", r) 19 | 20 | 21 | def replace_two(r): 22 | for number in numbers: 23 | r = r.replace(number, number[0] + str(numbers.index(number) + 1) + number[-1]) 24 | return re.sub("[^0-9]", "", r) 25 | 26 | 27 | def read(replace): 28 | with open(DIR / "input") as f: 29 | s = (f.read() if teststr == "" else teststr).splitlines() 30 | return lmap(lambda r: lmap(int, replace(r)), s) 31 | 32 | 33 | def run(): 34 | s = 0 35 | for line in t: 36 | s += int(str(line[0]) + str(line[-1])) 37 | print(s) 38 | 39 | 40 | teststr = """""" 41 | if environ.get("AOC_SOLVE", "") == "1": 42 | teststr = "" 43 | DIR = pathlib.Path(__file__).parent.absolute() 44 | lmap = lambda *a: list(map(*a)) 45 | inf = float("inf") 46 | if __name__ == "__main__": 47 | t = read(replace_one) 48 | run() 49 | t = read(replace_two) 50 | run() 51 | -------------------------------------------------------------------------------- /2020/17/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | from itertools import product 4 | 5 | DIR = pathlib.Path(__file__).parent.absolute() 6 | 7 | N = 20 8 | 9 | 10 | def read(): 11 | with open(DIR / "input") as f: 12 | t = f.read().replace("\r", "").splitlines() 13 | return np.array([[1 if i == "#" else 0 for i in l] for l in t], dtype=np.int32) 14 | 15 | 16 | t = read() 17 | 18 | 19 | def step(A): 20 | A_ = np.zeros_like(A, dtype=np.int32) 21 | ranges = [range(1, N - 1) for _ in range(len(A.shape))] 22 | for coords in product(*ranges): 23 | middle = A[coords] 24 | cube = tuple([slice(i - 1, i + 2, None) for i in list(coords)]) 25 | cube = A[cube] 26 | count = cube.sum() 27 | if middle == 1: 28 | state = count == 3 or count == 4 29 | else: 30 | state = count == 3 31 | A_[coords] = 1 if state else 0 32 | return A_ 33 | 34 | 35 | def do_stuff(dim): 36 | A = np.zeros((N,) * dim, dtype=np.int32) 37 | index = [N // 2] * dim 38 | for i in [0, 1]: 39 | index[i] = slice(N // 2 - 4, N // 2 + 4, None) 40 | A[tuple(index)] = t 41 | 42 | for _ in range(6): 43 | A = step(A) 44 | print(A.sum()) 45 | 46 | 47 | def easy(): 48 | do_stuff(3) 49 | 50 | 51 | def hard(): 52 | do_stuff(4) 53 | 54 | 55 | if __name__ == "__main__": 56 | easy() 57 | hard() 58 | -------------------------------------------------------------------------------- /2023/17/test.py: -------------------------------------------------------------------------------- 1 | from main import same_dir 2 | 3 | import unittest 4 | 5 | 6 | class TestSameDir(unittest.TestCase): 7 | def test_straight_line_max_length(self): 8 | origin = {(0, 1): (0, 0), (0, 2): (0, 1), (0, 3): (0, 2)} 9 | self.assertTrue(same_dir((0, 3), (0, 4), origin)) 10 | 11 | def test_straight_line_not_max_length(self): 12 | origin = {(0, 1): (0, 0)} 13 | self.assertFalse(same_dir((0, 0), (0, 1), origin)) 14 | 15 | def test_change_direction_before_max(self): 16 | origin = {(0, 1): (0, 0), (1, 1): (0, 1)} 17 | self.assertFalse(same_dir((0, 1), (1, 1), origin)) 18 | 19 | def test_no_previous_position(self): 20 | origin = {} 21 | self.assertFalse(same_dir((0, 0), (0, 1), origin)) 22 | 23 | def test_different_direction_each_step(self): 24 | origin = {(0, 1): (0, 0), (1, 1): (0, 1), (1, 2): (1, 1)} 25 | self.assertFalse(same_dir((1, 1), (1, 2), origin)) 26 | 27 | def test_looping_path(self): 28 | origin = {(0, 1): (0, 0), (0, 0): (0, 1)} 29 | self.assertFalse(same_dir((0, 0), (0, 1), origin)) 30 | 31 | def test_path_with_max_length_greater_than_3(self): 32 | origin = {(0, 1): (0, 0), (0, 2): (0, 1), (0, 3): (0, 2), (0, 4): (0, 3)} 33 | self.assertTrue(same_dir((0, 4), (0, 5), origin, max_length=4)) 34 | 35 | 36 | if __name__ == "__main__": 37 | unittest.main() 38 | -------------------------------------------------------------------------------- /2016/12/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | s = (f.read() if teststr == "" else teststr).splitlines() 11 | return lmap(lambda i: i.split(" "), s) 12 | 13 | 14 | def register_for(letter): 15 | return ord(letter) - 97 16 | 17 | 18 | def step(_, instr, mem): 19 | delta = 1 20 | if instr[0] == "cpy": 21 | try: 22 | val = int(instr[1]) 23 | except: 24 | val = mem[register_for(instr[1])] 25 | mem[register_for(instr[2])] = val 26 | if instr[0] == "jnz": 27 | try: 28 | val = int(instr[1]) 29 | except: 30 | val = mem[register_for(instr[1])] 31 | if val != 0: 32 | delta = int(instr[2]) 33 | if instr[0] == "inc": 34 | mem[register_for(instr[1])] += 1 35 | if instr[0] == "dec": 36 | mem[register_for(instr[1])] -= 1 37 | return delta 38 | 39 | 40 | def run(init=0): 41 | i = 0 42 | N = len(t) 43 | m = [0] * 4 44 | m[2] = init 45 | while i < N: 46 | i += step(i, t[i], m) 47 | print(m[0]) 48 | 49 | 50 | def easy(): 51 | run() 52 | 53 | 54 | def hard(): 55 | run(1) 56 | 57 | 58 | teststr = "" 59 | DIR = pathlib.Path(__file__).parent.absolute() 60 | t = read() 61 | if __name__ == "__main__": 62 | easy() 63 | hard() 64 | -------------------------------------------------------------------------------- /2015/06/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | 4 | 5 | def lmap(*a): 6 | return list(map(*a)) 7 | 8 | 9 | def read(): 10 | with open(DIR / "input") as f: 11 | s = map( 12 | lambda r: r.split(","), 13 | (f.read() if teststr == "" else teststr) 14 | .replace("turn ", "") 15 | .replace(" ", ",") 16 | .splitlines(), 17 | ) 18 | return lmap(lambda r: (r[0], int(r[1]), int(r[2]), int(r[4]), int(r[5])), s) 19 | 20 | 21 | def easy(): 22 | A = np.zeros((1000, 1000)) 23 | for instr, x1, y1, x2, y2 in t: 24 | if instr == "on": 25 | A[x1 : x2 + 1, y1 : y2 + 1] = 1 26 | elif instr == "off": 27 | A[x1 : x2 + 1, y1 : y2 + 1] = 0 28 | else: 29 | A[x1 : x2 + 1, y1 : y2 + 1] = 1 - A[x1 : x2 + 1, y1 : y2 + 1] 30 | print(int(A.sum())) 31 | 32 | 33 | def hard(): 34 | A = np.zeros((1000, 1000)) 35 | for instr, x1, y1, x2, y2 in t: 36 | if instr == "on": 37 | A[x1 : x2 + 1, y1 : y2 + 1] += 1 38 | elif instr == "off": 39 | A[x1 : x2 + 1, y1 : y2 + 1] -= 1 * (A[x1 : x2 + 1, y1 : y2 + 1] > 0) 40 | else: 41 | A[x1 : x2 + 1, y1 : y2 + 1] += 2 42 | print(int(A.sum())) 43 | 44 | 45 | teststr = """""" 46 | DIR = pathlib.Path(__file__).parent.absolute() 47 | t = read() 48 | if __name__ == "__main__": 49 | easy() 50 | hard() 51 | -------------------------------------------------------------------------------- /2016/09/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | return (f.read() if teststr == "" else teststr).splitlines()[0] 7 | 8 | 9 | def easy(): 10 | front, back = "", t 11 | while back: 12 | if back[0] != "(": 13 | front, back = front + back[0], back[1:] 14 | else: 15 | bracket, back = back[1:].split(")", 1) 16 | x, y = map(int, bracket.split("x")) 17 | bracket, back = back[:x], back[x:] 18 | # back = y * bracket + back 19 | front += y * bracket 20 | print(len(front)) 21 | 22 | 23 | def hard(): 24 | is_group = False 25 | values = [] 26 | i = 0 27 | for c in t: 28 | if c == "(": 29 | is_group = True 30 | values.append(0 if is_group else 1) 31 | if c == ")": 32 | is_group = False 33 | while i < len(t): 34 | c = t[i] 35 | i += 1 36 | if c != "(": 37 | continue 38 | bracket = t[i:].split(")")[0] 39 | i += len(bracket) + 1 40 | x, y = map(int, bracket.split("x")) 41 | for j in range(i, i + x): 42 | values[j] *= y 43 | print(sum(values)) 44 | 45 | 46 | teststr = "" # """(25x3)(3x3)ABC(2x3)XY(5x2)PQRSTX(18x9)(3x2)TWO(5x7)SEVEN""" 47 | DIR = pathlib.Path(__file__).parent.absolute() 48 | t = read() 49 | if __name__ == "__main__": 50 | easy() 51 | hard() 52 | -------------------------------------------------------------------------------- /2017/09/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | class Group: 5 | items = [] 6 | garbage = [0] 7 | 8 | def __init__(self, s, start=0, score=1): 9 | self.items.append(self) 10 | i = start + 1 11 | self.children = [] 12 | self.score = score 13 | garbage = False 14 | while i < len(s): 15 | if s[i] == "!" and garbage: 16 | i += 1 17 | elif s[i] == ">" and garbage: 18 | garbage = False 19 | elif s[i] == "<" and not garbage: 20 | garbage = True 21 | elif s[i] == "{" and not garbage: 22 | child = Group(s, i, score + 1) 23 | i = child.end 24 | self.children.append(child) 25 | elif s[i] == "}" and not garbage: 26 | break 27 | elif garbage: 28 | self.garbage[0] += 1 29 | 30 | i += 1 31 | self.end = i 32 | 33 | 34 | def read(): 35 | with open(DIR / "input") as f: 36 | s = f.read() if teststr == "" else teststr 37 | Group(s.splitlines()[0]) 38 | 39 | 40 | def easy(): 41 | print(sum([i.score for i in Group.items])) 42 | 43 | 44 | def hard(): 45 | print(Group.garbage[0]) 46 | 47 | 48 | teststr = "" #'{<{o"i!a,<{i}' # """{{{},{},{{}}}}""" 49 | DIR = pathlib.Path(__file__).parent.absolute() 50 | read() 51 | if __name__ == "__main__": 52 | easy() 53 | hard() 54 | -------------------------------------------------------------------------------- /2016/04/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | s = (f.read() if teststr == "" else teststr).splitlines() 7 | r = [] 8 | for l in s: 9 | c = l.split("-")[-1] 10 | l = l[: -len(c) - 1] 11 | r.append((l, int(c.split("[")[0]), c.split("[")[1][:-1])) 12 | return r 13 | 14 | 15 | def decrypt(line, off): 16 | s = "" 17 | for c in line: 18 | if c == "-": 19 | s += " " 20 | continue 21 | c = ord(c) 22 | c -= 97 23 | c += off 24 | c %= 26 25 | c += 97 26 | s += chr(c) 27 | return s 28 | 29 | 30 | def easy(): 31 | count = pole = 0 32 | for line, number, check in t: 33 | chars = {} 34 | for c in line.replace("-", ""): 35 | chars[c] = chars.get(c, 0) + 1 36 | chars = list(chars.items()) 37 | chars.sort(key=lambda i: i[0]) 38 | chars.sort(key=lambda i: -i[1]) 39 | chars = "".join([i[0] for i in chars[:5]]) 40 | if chars == check: 41 | count += number 42 | if decrypt(line, number) == "northpole object storage": 43 | pole = number 44 | print(count, pole, sep="\n") 45 | 46 | 47 | def hard(): 48 | return 49 | 50 | 51 | teststr = """""" 52 | DIR = pathlib.Path(__file__).parent.absolute() 53 | t = read() 54 | if __name__ == "__main__": 55 | easy() 56 | hard() 57 | -------------------------------------------------------------------------------- /2017/22/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | 4 | 5 | def lmap(*a): 6 | return list(map(*a)) 7 | 8 | 9 | def read(): 10 | with open(DIR / "input") as f: 11 | s = (f.read() if teststr == "" else teststr).splitlines() 12 | return np.array(lmap(lambda r: lmap(ord, r), s), int) 13 | 14 | 15 | def right(p): 16 | return (p[1], -p[0]) 17 | 18 | 19 | def left(p): 20 | return (-p[1], p[0]) 21 | 22 | 23 | def straight(p): 24 | return p 25 | 26 | 27 | def back(p): 28 | return (-p[0], -p[1]) 29 | 30 | 31 | def run(iterations, moves, changes): 32 | t = read() 33 | t[t == ord(".")] = 0 34 | t[t == ord("#")] = 1 35 | d, p, c, n = (-1, 0), (t.shape[0] // 2, t.shape[1] // 2), 0, 1 36 | for _ in range(iterations): 37 | if not (0 < p[0] < t.shape[0] - 1 and 0 < p[1] < t.shape[1] - 1): 38 | t = np.pad(t, ((n, n), (n, n))) 39 | p = (p[0] + n, p[1] + n) 40 | n *= 2 41 | d = moves[t[p]](d) 42 | t[p] = changes[t[p]] 43 | c += 1 if t[p] == 1 else 0 44 | p = (p[0] + d[0], p[1] + d[1]) 45 | print(c) 46 | 47 | 48 | def easy(): 49 | run(10000, {0: left, 1: right}, {0: 1, 1: 0}) 50 | 51 | 52 | def hard(): 53 | run(10 ** 7, [left, right, straight, back], [2, 3, 1, 0]) 54 | 55 | 56 | teststr = "" # "..#\n#..\n..." 57 | DIR = pathlib.Path(__file__).parent.absolute() 58 | if __name__ == "__main__": 59 | easy() 60 | hard() 61 | -------------------------------------------------------------------------------- /2015/24/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from math import prod 3 | from itertools import combinations 4 | 5 | 6 | def read(): 7 | with open(DIR / "input") as f: 8 | s = (f.read() if teststr == "" else teststr).splitlines() 9 | return lmap(int, s) 10 | 11 | 12 | def subsetSum(li, comb, sums): 13 | for i in range(len(li) + 1): 14 | for subset in combinations(li, i): 15 | comb.append(list(subset)) 16 | sums.append(sum(subset)) 17 | 18 | 19 | def calcSubsets(n, arr, x): 20 | arr1, arr2 = arr[: n // 2], arr[n // 2 :] 21 | comb1, sums1 = [], [] 22 | subsetSum(arr1, comb1, sums1) 23 | comb2, sums2 = [], [] 24 | subsetSum(arr2, comb2, sums2) 25 | for i in range(len(sums1)): 26 | for j in range(len(sums2)): 27 | if sums1[i] + sums2[j] == x: 28 | yield comb1[i] + comb2[j] 29 | 30 | 31 | def balance(k): 32 | sets = calcSubsets(len(t), t, sum(t) // k) 33 | m, shortest = 9e9, [] 34 | for s in sets: 35 | l = len(s) 36 | if l == m: 37 | shortest.append(s) 38 | if l < m: 39 | shortest, m = [s], l 40 | print(min([prod(s) for s in shortest])) 41 | 42 | 43 | def easy(): 44 | balance(3) 45 | 46 | 47 | def hard(): 48 | balance(4) 49 | 50 | 51 | teststr = """""" 52 | DIR = pathlib.Path(__file__).parent.absolute() 53 | lmap = lambda *a: list(map(*a)) 54 | t = read() 55 | if __name__ == "__main__": 56 | easy() 57 | hard() 58 | -------------------------------------------------------------------------------- /2025/12/solve.ts: -------------------------------------------------------------------------------- 1 | import { readFile } from "fs/promises"; 2 | 3 | async function main() { 4 | let input = await readFile("input", "utf-8"); 5 | if (0) 6 | input = `0: 7 | ### 8 | ##. 9 | ##. 10 | 11 | 1: 12 | ### 13 | ##. 14 | .## 15 | 16 | 2: 17 | .## 18 | ### 19 | ##. 20 | 21 | 3: 22 | ##. 23 | ### 24 | ##. 25 | 26 | 4: 27 | ### 28 | #.. 29 | ### 30 | 31 | 5: 32 | ### 33 | .#. 34 | ### 35 | 36 | 3x3: 0 0 0 0 1 0 37 | 4x4: 0 0 0 0 2 0 38 | 4x4: 0 0 0 0 3 0 39 | 12x5: 1 0 1 0 2 2 40 | 12x5: 1 0 1 0 3 2`; 41 | /* 42 | 43 | */ 44 | const chunks = input.trim().split("\n\n"); 45 | 46 | const grids = chunks.pop()!; 47 | 48 | const blockCounts: number[] = []; 49 | for (const piece of chunks) { 50 | blockCounts.push(0); 51 | for (const c of piece.replace(/\n/g, "").split(":")[1]) { 52 | if (c === "#") blockCounts[blockCounts.length - 1]++; 53 | } 54 | } 55 | 56 | let a = 0; 57 | for (const gridString of grids.trim().split("\n")) { 58 | const dimsString = gridString.split(":")[0]; 59 | const counts = gridString 60 | .split(" ") 61 | .slice(1) 62 | .map((v) => +v); 63 | const dims = dimsString.split("x").map((v) => +v) as [number, number]; 64 | 65 | const gridSize = dims[0] * dims[1]; 66 | const blockTotal = counts 67 | .map((c, i) => c * blockCounts[i]) 68 | .reduce((a, b) => a + b); 69 | a += blockTotal <= gridSize ? 1 : 0; 70 | } 71 | console.log(a); 72 | } 73 | 74 | main().catch(console.error); 75 | -------------------------------------------------------------------------------- /2017/21/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | 4 | 5 | def lmap(*a): 6 | return list(map(*a)) 7 | 8 | 9 | def rule(left, right): 10 | left, right = parse(left), parse(right) 11 | for i in range(8): 12 | if i % 2: 13 | left = np.rot90(left) 14 | left = np.flip(left, 1) 15 | t[tuple(left.flatten())] = right 16 | 17 | 18 | def parse(a): 19 | a = np.array(lmap(lambda i: lmap(ord, i), a.replace("/", "\n").splitlines()), int) 20 | a[a == ord(".")] = 0 21 | a[a == ord("#")] = 1 22 | return a 23 | 24 | 25 | def read(): 26 | with open(DIR / "input") as f: 27 | s = f.read() if teststr == "" else teststr 28 | lmap(lambda r: rule(*r.split(" => ")), s.splitlines()) 29 | 30 | 31 | def iterations(n): 32 | A = parse(".#./..#/###") 33 | for _ in range(n): 34 | S = 2 + (A.shape[0] % 2) 35 | rows = [] 36 | for x in range(A.shape[0])[::S]: 37 | row = [] 38 | for y in range(A.shape[0])[::S]: 39 | row.append(t[tuple(A[x : x + S, y : y + S].flatten())]) 40 | row = np.hstack(row) 41 | rows.append(row) 42 | A = np.vstack(rows) 43 | print(A.sum()) 44 | 45 | 46 | def easy(): 47 | iterations(5) 48 | 49 | 50 | def hard(): 51 | iterations(18) 52 | 53 | 54 | teststr = """""" 55 | DIR = pathlib.Path(__file__).parent.absolute() 56 | t = {} 57 | read() 58 | if __name__ == "__main__": 59 | easy() 60 | hard() 61 | -------------------------------------------------------------------------------- /2018/08/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | input = list( 4 | map( 5 | int, 6 | open(pathlib.Path(__file__).parent / "input") 7 | .read() 8 | .replace(" ", "\n") 9 | .splitlines(), 10 | ) 11 | ) 12 | total = 0 13 | 14 | 15 | def child_len(i): 16 | global input, total 17 | 18 | childs = input[i] 19 | nums = input[i + 1] 20 | length = nums + 2 21 | i += 2 22 | for _ in range(childs): 23 | c = child_len(i) 24 | length += c 25 | i += c 26 | total += sum(input[i : i + nums]) 27 | 28 | return length 29 | 30 | 31 | def easy(): 32 | global input, total 33 | 34 | child_len(0) 35 | print(total) 36 | 37 | 38 | easy() 39 | total = 0 40 | 41 | 42 | def hard_child_len(i): 43 | global input, total 44 | 45 | childs = input[i] 46 | nums = input[i + 1] 47 | length = nums + 2 48 | value = 0 49 | i += 2 50 | values = [] 51 | for _ in range(childs): 52 | c = hard_child_len(i) 53 | length += c[0] 54 | i += c[0] 55 | values.append(c[1]) 56 | if childs == 0: 57 | value = sum(input[i : i + nums]) 58 | else: 59 | for meta in input[i : i + nums]: 60 | if meta >= 1 and meta <= childs: 61 | value += values[meta - 1] 62 | 63 | return (length, value) 64 | 65 | 66 | def hard(): 67 | global input, total 68 | 69 | hard_child_len(0) 70 | print(hard_child_len(0)[1]) 71 | 72 | 73 | hard() 74 | -------------------------------------------------------------------------------- /2015/14/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | s = (f.read() if teststr == "" else teststr).splitlines() 7 | return lmap(lambda r: lmap(lambda i: int(r.split(" ")[i]), [3, 6, -2]), s) 8 | 9 | 10 | def easy(): 11 | N, m = 2503, 0 12 | for spd, dur, rst in t: 13 | dist = spd * dur * (N // (dur + rst)) 14 | left = N % (dur + rst) 15 | dist += spd * dur if left > dur else spd * left 16 | m = max(m, dist) 17 | print(m) 18 | 19 | 20 | def hard(): 21 | r = [[0, 0, 0, dur + 1, [spd, 0], [dur, rst]] for (spd, dur, rst) in t] 22 | for _ in range(2503): 23 | m = [0, []] 24 | for j in range(len(r)): 25 | r[j][3] -= 1 26 | if r[j][3] == 0: 27 | r[j][1] = 1 - r[j][1] 28 | r[j][3] = r[j][5][r[j][1]] 29 | r[j][2] += r[j][4][r[j][1]] 30 | if m[0] == r[j][2]: 31 | m[1] += [j] 32 | if m[0] < r[j][2]: 33 | m = [r[j][2], [j]] 34 | for x in m[1]: 35 | r[x][0] += 1 36 | print(max([i[0] for i in r])) 37 | 38 | 39 | teststr = """Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds. 40 | Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds.""" 41 | teststr = "" 42 | DIR = pathlib.Path(__file__).parent.absolute() 43 | lmap = lambda *a: list(map(*a)) 44 | t = read() 45 | if __name__ == "__main__": 46 | easy() 47 | hard() 48 | -------------------------------------------------------------------------------- /2017/11/11.md: -------------------------------------------------------------------------------- 1 | --- Day 11: Hex Ed --- 2 | ---------------------- 3 | 4 | Crossing the bridge, you've barely reached the other side of the stream 5 | when a program comes up to you, clearly in distress. "It's my child 6 | process," she says, "he's gotten lost in an infinite grid!" 7 | 8 | Fortunately for her, you have plenty of experience with infinite grids. 9 | 10 | Unfortunately for you, it's a [hex grid]. 11 | 12 | The hexagons ("hexes") in this grid are aligned such that adjacent hexes 13 | can be found to the north, northeast, southeast, south, southwest, and 14 | northwest: 15 | 16 | \ n / 17 | nw +--+ ne 18 | / \ 19 | -+ +- 20 | \ / 21 | sw +--+ se 22 | / s \ 23 | 24 | You have the path the child process took. Starting where he started, you 25 | need to determine the fewest number of steps required to reach him. (A 26 | "step" means to move from the hex you are in to any adjacent hex.) 27 | 28 | For example: 29 | 30 | - `ne,ne,ne` is `3` steps away. 31 | - `ne,ne,sw,sw` is `0` steps away (back where you started). 32 | - `ne,ne,s,s` is `2` steps away (`se,se`). 33 | - `se,sw,se,sw,sw` is `3` steps away (`s,s,sw`). 34 | 35 | Your puzzle answer was `705`. 36 | 37 | --- Part Two --- 38 | ---------------- 39 | 40 | *How many steps away* is the *furthest* he ever got from his starting 41 | position? 42 | 43 | Your puzzle answer was `1469`. 44 | 45 | Both parts of this puzzle are complete! They provide two gold stars: 46 | \*\* 47 | 48 | [hex grid]: https://en.wikipedia.org/wiki/Hexagonal_tiling 49 | -------------------------------------------------------------------------------- /2015/07/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def read(): 5 | with open(DIR / "input") as f: 6 | s = (f.read() if teststr == "" else teststr).splitlines() 7 | list(map(lambda r: Wire(r.split(" -> ")[0].split(" "), r.split(" -> ")[1]), s)) 8 | 9 | 10 | class Wire: 11 | items = {} 12 | 13 | def __init__(self, inp, out): 14 | self.output = out 15 | self.inp = inp + ["", ""] 16 | self.__class__.items[out] = self 17 | self.val = None 18 | 19 | def calc(self): 20 | if self.val is not None: 21 | return self.val 22 | elif self.inp[1] == "AND": 23 | self.val = v(self.inp[0]) & v(self.inp[2]) 24 | elif self.inp[1] == "OR": 25 | self.val = v(self.inp[0]) | v(self.inp[2]) 26 | elif self.inp[1] == "LSHIFT": 27 | self.val = v(self.inp[0]) << v(self.inp[2]) 28 | elif self.inp[1] == "RSHIFT": 29 | self.val = v(self.inp[0]) >> v(self.inp[2]) 30 | elif self.inp[0] == "NOT": 31 | self.val = ~v(self.inp[1]) 32 | else: 33 | self.val = v(self.inp[0]) 34 | return self.val 35 | 36 | 37 | def v(key): 38 | try: 39 | return int(key) 40 | except: 41 | return Wire.items[key].calc() 42 | 43 | 44 | teststr = """""" 45 | DIR = pathlib.Path(__file__).parent.absolute() 46 | if __name__ == "__main__": 47 | read() 48 | x = v("a") 49 | for wire in Wire.items.values(): 50 | wire.val = x if wire.output == "b" else None 51 | print(x, v("a"), sep="\n") 52 | -------------------------------------------------------------------------------- /2017/19/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | 4 | 5 | def lmap(*a): 6 | return list(map(*a)) 7 | 8 | 9 | def read(): 10 | with open(DIR / "input") as f: 11 | s = f.read() if teststr == "" else teststr 12 | return np.array(lmap(lambda r: lmap(ord, r), s.splitlines()), int) 13 | 14 | 15 | def right(p): 16 | return (p[1], -p[0]) 17 | 18 | 19 | def left(p): 20 | return right(right(right(p))) 21 | 22 | 23 | def easy(): 24 | t[t == 32] = 0 25 | for c in "-|+": 26 | t[t == ord(c)] = 1 27 | p, d, s, n = (1, np.where(t[0] > 0)[0][0]), DOWN, "", 2 28 | 29 | while True: 30 | forward = (p[0] + d[0], p[1] + d[1]) 31 | if t[forward] == 0: 32 | r = right(d) 33 | l = left(d) 34 | f_r = (p[0] + r[0], p[1] + r[1]) 35 | f_l = (p[0] + l[0], p[1] + l[1]) 36 | if t[f_r] != 0: 37 | d = r 38 | elif t[f_l] != 0: 39 | d = l 40 | else: 41 | return print(s, n, sep="\n") 42 | else: 43 | p, n = forward, n + 1 44 | if t[p] > 1: 45 | s += chr(t[p]) 46 | 47 | 48 | def hard(): 49 | return 50 | 51 | 52 | teststr = """ | 53 | | +--+ 54 | A | C 55 | F---|----E|--+ 56 | | | | D 57 | +B-+ +--+ 58 | """ 59 | teststr = "" 60 | DIR = pathlib.Path(__file__).parent.absolute() 61 | t = read() 62 | DOWN = (1, 0) 63 | if __name__ == "__main__": 64 | easy() 65 | hard() 66 | -------------------------------------------------------------------------------- /2015/15/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | from itertools import product 4 | 5 | 6 | def read(): 7 | with open(DIR / "input") as f: 8 | s = (f.read() if teststr == "" else teststr).replace(",", "").splitlines() 9 | return lmap( 10 | lambda r: lmap(lambda i: int(r.split(" ")[i]), [2, 4, 6, 8, 10]), 11 | s, 12 | ) 13 | 14 | 15 | def easy(): 16 | weights = np.array(t)[:, :-1] 17 | s = 0 18 | 19 | for l in product(*([range(100)] * (len(weights) - 1))): 20 | if sum(l) > 100: 21 | continue 22 | l = list(l) + [100 - sum(l)] 23 | r = weights.T @ np.array(l) 24 | if (r <= 0).any(): 25 | continue 26 | s = max(s, np.prod(r)) 27 | print(s) 28 | 29 | 30 | def hard(): 31 | weights = np.array(t) 32 | s = 0 33 | 34 | for l in product(*([range(100)] * (len(weights) - 1))): 35 | if sum(l) > 100: 36 | continue 37 | l = list(l) + [100 - sum(l)] 38 | r = weights.T @ np.array(l) 39 | if r[-1] != 500: 40 | continue 41 | if (r[:-1] <= 0).any(): 42 | continue 43 | s = max(s, np.prod(r[:-1])) 44 | print(s) 45 | 46 | 47 | teststr = """Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8 48 | Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3""" 49 | teststr = "" 50 | DIR = pathlib.Path(__file__).parent.absolute() 51 | lmap = lambda *a: list(map(*a)) 52 | t = read() 53 | if __name__ == "__main__": 54 | easy() 55 | hard() 56 | -------------------------------------------------------------------------------- /2015/17/17.md: -------------------------------------------------------------------------------- 1 | --- Day 17: No Such Thing as Too Much --- 2 | ----------------------------------------- 3 | 4 | The elves bought too much eggnog again - `150` liters this time. To fit 5 | it all into your refrigerator, you'll need to move it into smaller 6 | containers. You take an inventory of the capacities of the available 7 | containers. 8 | 9 | For example, suppose you have containers of size `20`, `15`, `10`, `5`, 10 | and `5` liters. If you need to store `25` liters, there are four ways to 11 | do it: 12 | 13 | - `15` and `10` 14 | - `20` and `5` (the first `5`) 15 | - `20` and `5` (the second `5`) 16 | - `15`, `5`, and `5` 17 | 18 | Filling all containers entirely, how many different *combinations of 19 | containers* can exactly fit all `150` liters of eggnog? 20 | 21 | Your puzzle answer was `1304`. 22 | 23 | --- Part Two --- 24 | ---------------- 25 | 26 | While playing with all the containers in the kitchen, another load of 27 | eggnog 28 | 29 | arrives! The shipping and receiving department is requesting as many 30 | containers as you can spare. 31 | 32 | Find the minimum number of containers that can exactly fit all `150` 33 | liters of eggnog. *How many different ways* can you fill that number of 34 | containers and still hold exactly `150` litres? 35 | 36 | In the example above, the minimum number of containers was two. There 37 | were three ways to use that many containers, and so the answer there 38 | would be `3`. 39 | 40 | Your puzzle answer was `18`. 41 | 42 | Both parts of this puzzle are complete! They provide two gold stars: 43 | \*\* 44 | -------------------------------------------------------------------------------- /2019/08/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | from math import prod 4 | from itertools import product 5 | 6 | DIR = pathlib.Path(__file__).parent.absolute() 7 | inf = float("inf") 8 | 9 | 10 | def read(): 11 | with open(DIR / "input") as f: 12 | t = f.read().split("\n") 13 | if t[-1] == "": 14 | t.pop() 15 | return np.array([int(i) for i in t[0]], dtype=np.int32).reshape(-1, 6, 25) 16 | 17 | 18 | t = read() 19 | 20 | 21 | def easy(): 22 | m = (inf, 0) 23 | for i in range(100): 24 | c = len(np.where(t[i, :, :] == 0)[0]) 25 | if c < m[0]: 26 | m = (c, i) 27 | print(prod([len(np.where(t[m[1], :, :] == k)[0]) for k in range(1, 3)])) 28 | 29 | 30 | OCR = { 31 | 422148690: "A", 32 | 959335004: "B", 33 | 422068812: "C", 34 | 1024344606: "E", 35 | 1024344592: "F", 36 | 422074958: "G", 37 | 623856210: "H", 38 | 203491916: "J", 39 | 625758866: "K", 40 | 554189342: "L", 41 | 959017488: "P", 42 | 959017618: "R", 43 | 623462988: "U", 44 | 588583044: "Y", 45 | 1008869918: "Z", 46 | } 47 | 48 | 49 | def ocr(t): 50 | c = OCR[int("".join([str(i) for i in t[:, :5].reshape(-1)]), 2)] 51 | if t.shape[1] > 5: 52 | c += ocr(t[:, 5:]) 53 | return c 54 | 55 | 56 | def hard(): 57 | for l, y, x in product(*[range(n) for n in t.shape]): 58 | if l > 0: 59 | t[l, y, x] = t[l, y, x] if t[l - 1, y, x] == 2 else t[l - 1, y, x] 60 | print(ocr(t[-1])) 61 | 62 | 63 | if __name__ == "__main__": 64 | easy() 65 | hard() -------------------------------------------------------------------------------- /2025/06/solve.ts: -------------------------------------------------------------------------------- 1 | let input = await Bun.file("input").text(); 2 | if (0) input = `123 328 51 64 3 | 45 64 387 23 4 | 6 98 215 314 5 | * + * + 6 | ` 7 | let lines = input.trim().split("\n").map(line => line.replace(/\s+/g, ' ').trim().split(' ')); 8 | 9 | let c = 0 10 | let idx = 0 11 | for (const operator of lines[lines.length - 1]) { 12 | let s = operator == '*' ? 1 : 0 13 | for (const line of lines.slice(0, lines.length - 1)) { 14 | if (operator == '*') { 15 | s *= +line[idx] 16 | } else { 17 | s += +line[idx] 18 | } 19 | } 20 | idx++; 21 | c += s 22 | } 23 | console.log(c) 24 | 25 | lines = input.trimEnd().split("\n").map(line => line.split('')); 26 | let transposed = new Array(lines[0].length).fill(0).map(_ => new Array(lines.length).fill(' ')) 27 | for (let i = 0; i < lines.length; i++) 28 | for (let j = 0; j < lines[0].length; j++) { 29 | transposed[j][i] = lines[i][j] || ' ' 30 | } 31 | 32 | let op = '' 33 | let s = 0 34 | let n = 0 35 | for (const line of transposed) { 36 | if (line[line.length - 1] == '*') { 37 | s += n 38 | op = '*' 39 | n = 1 40 | } 41 | if (line[line.length - 1] == '+') { 42 | s += n 43 | op = '+' 44 | n = 0 45 | } 46 | let digits = line.slice(0, line.length - 1).join('').replace(/ /g, '') 47 | if (!digits) continue; 48 | let num = +digits 49 | if (op == '*') { 50 | n *= num 51 | } else { 52 | n += num 53 | } 54 | } 55 | 56 | console.log(s + n) 57 | 58 | export { } -------------------------------------------------------------------------------- /2017/16/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from string import ascii_lowercase 3 | 4 | 5 | def lmap(*a): 6 | return list(map(*a)) 7 | 8 | 9 | def read(): 10 | with open(DIR / "input") as f: 11 | s = f.read() if teststr == "" else teststr 12 | t = [] 13 | for r in s.splitlines()[0].split(","): 14 | if r[0] == "s": 15 | t.append(("s", int(r[1:]))) 16 | if r[0] == "x": 17 | t.append(("x", *lmap(int, r[1:].split("/")))) 18 | if r[0] == "p": 19 | t.append(("p", *lmap(str, r[1:].split("/")))) 20 | return t 21 | 22 | 23 | def op_s(T, a, _=None): 24 | return T[-a:] + T[:-a] 25 | 26 | 27 | def op_x(T, a, b): 28 | T[a], T[b] = T[b], T[a] 29 | return T 30 | 31 | 32 | def op_p(T, a, b): 33 | return op_x(T, T.index(a), T.index(b)) 34 | 35 | 36 | def loop(T=None): 37 | T = list(ascii_lowercase[:16]) if T is None else T 38 | for r in t: 39 | T = {"s": op_s, "x": op_x, "p": op_p}[r[0]](T, *r[1:]) 40 | return T 41 | 42 | 43 | def easy(): 44 | print("".join(loop())) 45 | 46 | 47 | def hard(): 48 | T, s, n = None, set(["".join(ascii_lowercase[:16])]), 0 49 | while True: 50 | n += 1 51 | T = loop(T) 52 | c = "".join(T) 53 | if c in s: 54 | break 55 | s.add(c) 56 | T = None 57 | for _ in range(1000000000 % n): 58 | T = loop(T) 59 | print("".join(T)) 60 | 61 | 62 | teststr = """""" 63 | DIR = pathlib.Path(__file__).parent.absolute() 64 | t = read() 65 | if __name__ == "__main__": 66 | easy() 67 | hard() 68 | -------------------------------------------------------------------------------- /2023/06/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import re 3 | import pathlib 4 | import json 5 | from functools import reduce 6 | from string import ascii_lowercase 7 | from math import prod, gcd, sqrt 8 | from itertools import permutations, product 9 | from llist import dllist as llist 10 | from copy import deepcopy 11 | from hashlib import md5, sha256 12 | from os import environ 13 | 14 | 15 | def read(): 16 | with open(DIR / "input") as f: 17 | s = re.sub(r" +", " ", (f.read() if teststr == "" else teststr)).splitlines() 18 | return list(zip(*lmap(lambda row: lmap(int, row.split(" ")[1:]), s))) 19 | 20 | 21 | def maybeint(line): 22 | try: 23 | return int(line) 24 | except: 25 | return line 26 | 27 | 28 | def easy(): 29 | result = 1 30 | for time, distance in t: 31 | wins = 0 32 | for press_t in range(1, time): 33 | if (time - press_t) * press_t > distance: 34 | wins += 1 35 | result *= wins 36 | print(result) 37 | 38 | 39 | def hard(): 40 | time = int("".join(map(str, [i[0] for i in t]))) 41 | distance = int("".join(map(str, [i[1] for i in t]))) 42 | 43 | wins = 0 44 | for press_t in range(1, time): 45 | if (time - press_t) * press_t > distance: 46 | wins += 1 47 | print(wins) 48 | 49 | 50 | teststr = """""" 51 | if environ.get("AOC_SOLVE", "") == "1": 52 | teststr = "" 53 | DIR = pathlib.Path(__file__).parent.absolute() 54 | lmap = lambda *a: list(map(*a)) 55 | inf = float("inf") 56 | t = read() 57 | if __name__ == "__main__": 58 | easy() 59 | hard() 60 | -------------------------------------------------------------------------------- /2015/04/4.md: -------------------------------------------------------------------------------- 1 | --- Day 4: The Ideal Stocking Stuffer --- 2 | ----------------------------------------- 3 | 4 | Santa needs help [mining] some 5 | 6 | AdventCoins (very similar to [bitcoins]) to use as gifts for all the 7 | economically forward-thinking little girls and boys. 8 | 9 | To do this, he needs to find [MD5] hashes which, in [hexadecimal], 10 | start with at least *five zeroes*. The input to the MD5 hash is some 11 | secret key (your puzzle input, given below) followed by a number in 12 | decimal. To mine AdventCoins, you must find Santa the lowest positive 13 | number (no leading zeroes: `1`, `2`, `3`, ...) that produces such a 14 | hash. 15 | 16 | For example: 17 | 18 | - If your secret key is `abcdef`, the answer is `609043`, because the 19 | MD5 hash of `abcdef609043` starts with five zeroes 20 | (`000001dbbfa...`), and it is the lowest such number to do so. 21 | - If your secret key is `pqrstuv`, the lowest number it combines with 22 | to make an MD5 hash starting with five zeroes is `1048970`; that is, 23 | the MD5 hash of `pqrstuv1048970` looks like `000006136ef...`. 24 | 25 | Your puzzle answer was `346386`. 26 | 27 | --- Part Two --- 28 | ---------------- 29 | 30 | Now find one that starts with *six zeroes*. 31 | 32 | Your puzzle answer was `9958218`. 33 | 34 | Both parts of this puzzle are complete! They provide two gold stars: 35 | \*\* 36 | 37 | [mining]: https://en.wikipedia.org/wiki/Bitcoin#Mining 38 | [bitcoins]: https://en.wikipedia.org/wiki/Bitcoin 39 | [MD5]: https://en.wikipedia.org/wiki/MD5 40 | [hexadecimal]: https://en.wikipedia.org/wiki/Hexadecimal 41 | -------------------------------------------------------------------------------- /2016/07/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | 4 | def lmap(*a): 5 | return list(map(*a)) 6 | 7 | 8 | def read(): 9 | with open(DIR / "input") as f: 10 | s = (f.read() if teststr == "" else teststr).splitlines() 11 | return lmap(lambda r: r.replace("]", "[").split("["), s) 12 | 13 | 14 | def is_abba(s): 15 | for i in range(len(s) - 3): 16 | if s[i] != s[i + 1] and s[i + 1] == s[i + 2] and s[i] == s[i + 3]: 17 | return True 18 | return False 19 | 20 | 21 | def get_aba(s): 22 | aba = set() 23 | for i in range(len(s) - 2): 24 | if s[i] != s[i + 1] and s[i] == s[i + 2]: 25 | aba.add(s[i + 1] + s[i] + s[i + 1]) 26 | return aba 27 | 28 | 29 | def easy(): 30 | count = 0 31 | for row in t: 32 | flip = False 33 | has_abba = 0 34 | for bit in row: 35 | abba = is_abba(bit) 36 | if flip and abba: 37 | has_abba = 0 38 | break 39 | if abba and not flip: 40 | has_abba = 1 41 | flip = not flip 42 | count = count + 1 if has_abba else count 43 | print(count) 44 | 45 | 46 | def hard(): 47 | count = 0 48 | for row in t: 49 | pos = "+".join(row[::2]) 50 | neg = "-".join(row[1::2]) 51 | for bab in get_aba(pos): 52 | if bab in neg: 53 | count += 1 54 | break 55 | print(count) 56 | 57 | 58 | teststr = """""" 59 | DIR = pathlib.Path(__file__).parent.absolute() 60 | t = read() 61 | if __name__ == "__main__": 62 | easy() 63 | hard() 64 | -------------------------------------------------------------------------------- /2022/02/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import re 3 | import pathlib 4 | import json 5 | from functools import reduce 6 | from string import ascii_lowercase 7 | from math import prod, gcd, sqrt 8 | from itertools import permutations, product 9 | from llist import dllist as llist 10 | from copy import deepcopy 11 | from hashlib import md5, sha256 12 | 13 | 14 | def read(): 15 | with open(DIR / "input") as f: 16 | s = (f.read() if teststr == "" else teststr).splitlines() 17 | return lmap(lambda r: lmap(str, r.split(" ")), s) 18 | 19 | 20 | move_to_score = { 21 | "X": 1, 22 | "Y": 2, 23 | "Z": 3, 24 | } 25 | turn_to_win = { 26 | "AX": 3, 27 | "AY": 6, 28 | "AZ": 0, 29 | "BX": 0, 30 | "BY": 3, 31 | "BZ": 6, 32 | "CX": 6, 33 | "CY": 0, 34 | "CZ": 3, 35 | } 36 | outcome_to_turn = { 37 | "AX": "Z", 38 | "AY": "X", 39 | "AZ": "Y", 40 | "BX": "X", 41 | "BY": "Y", 42 | "BZ": "Z", 43 | "CX": "Y", 44 | "CY": "Z", 45 | "CZ": "X", 46 | } 47 | 48 | 49 | def easy(): 50 | s = 0 51 | for theirs, mine in t: 52 | s += move_to_score[mine] 53 | s += turn_to_win[theirs + mine] 54 | print(s) 55 | 56 | 57 | def hard(): 58 | s = 0 59 | for theirs, outcome in t: 60 | mine = outcome_to_turn[theirs + outcome] 61 | s += move_to_score[mine] 62 | s += turn_to_win[theirs + mine] 63 | print(s) 64 | 65 | 66 | teststr = """""" 67 | DIR = pathlib.Path(__file__).parent.absolute() 68 | lmap = lambda *a: list(map(*a)) 69 | inf = float("inf") 70 | t = read() 71 | if __name__ == "__main__": 72 | easy() 73 | hard() 74 | -------------------------------------------------------------------------------- /2020/22/main.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from functools import reduce 3 | 4 | DIR = pathlib.Path(__file__).parent.absolute() 5 | 6 | 7 | def read(): 8 | with open(DIR / "input") as f: 9 | t = f.read().replace("\r", "").split("\n\n") 10 | t = [l.splitlines()[1:] for l in t] 11 | return [[int(i) for i in l] for l in t] 12 | 13 | 14 | t = read() 15 | 16 | 17 | def round(): 18 | p1 = t[0].pop(0) 19 | p2 = t[1].pop(0) 20 | if p1 > p2: 21 | t[0].extend([p1, p2]) 22 | else: 23 | t[1].extend([p2, p1]) 24 | 25 | 26 | def recround(a, b, return_list=False): 27 | seen = set() 28 | while True: 29 | if not (a and b): 30 | if return_list: 31 | return a if a else b 32 | return 0 if a else 1 33 | h = hash(tuple(a + [-1] + b)) 34 | if h in seen: 35 | return a if return_list else 0 36 | seen.add(h) 37 | 38 | p1 = a.pop(0) 39 | p2 = b.pop(0) 40 | if p1 <= len(a) and p2 <= len(b): 41 | win = recround(list(a[:p1]), list(b[:p2])) 42 | else: 43 | win = 0 if p1 > p2 else 1 44 | if win == 0: 45 | a.extend([p1, p2]) 46 | else: 47 | b.extend([p2, p1]) 48 | 49 | 50 | def score(A): 51 | return reduce(lambda a, b: (a[1] * b + a[0], a[1] + 1), reversed(A), (0, 1))[0] 52 | 53 | 54 | def easy(): 55 | while len(t[0]) and len(t[1]): 56 | round() 57 | print(score(t[0] + t[1])) 58 | 59 | 60 | def hard(): 61 | print(score(recround(*read(), return_list=True))) 62 | 63 | 64 | if __name__ == "__main__": 65 | easy() 66 | hard() 67 | -------------------------------------------------------------------------------- /2016/18/main.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pathlib 3 | from itertools import product 4 | 5 | 6 | def read(): 7 | with open(DIR / "input") as f: 8 | s = (f.read() if teststr == "" else teststr).splitlines()[0] 9 | return np.array([1 if i == "^" else 0 for i in s], dtype=np.uint8) 10 | 11 | 12 | allowed = {} 13 | for t in product(*([[0, 1]] * 3)): 14 | allowed[t] = t in [(1, 1, 0), (0, 1, 1), (1, 0, 0), (0, 0, 1)] 15 | 16 | 17 | def next(row): 18 | new = np.zeros_like(row) 19 | row = np.hstack(([0], row, [0])) 20 | for i in range(1, row.size - 1): 21 | elem = row[i - 1 : i + 2] 22 | if allowed[tuple(elem)]: 23 | new[i - 1] = 1 24 | return new 25 | 26 | 27 | def run(steps): 28 | a = t 29 | N = int(a.size) 30 | s = N - int(a.sum()) 31 | seen = {tuple(a): 0} 32 | scores = [s] 33 | i = 1 34 | while i < steps: 35 | a = next(a) 36 | tup = tuple(a) 37 | s += N - int(a.sum()) 38 | scores.append(s) 39 | if tup in seen: 40 | prev_index = seen[tup] 41 | diff = i - prev_index 42 | score_diff = s - scores[prev_index] 43 | j = (steps - 1 - i) // diff 44 | s += score_diff * j 45 | i += diff * j 46 | seen = {} 47 | else: 48 | seen[tup] = i 49 | i += 1 50 | print(s) 51 | 52 | 53 | def easy(): 54 | run(40) 55 | 56 | 57 | def hard(): 58 | run(400000) 59 | 60 | 61 | teststr = "" # """.^^.^.^^^^""" 62 | DIR = pathlib.Path(__file__).parent.absolute() 63 | t = read() 64 | if __name__ == "__main__": 65 | easy() 66 | hard() 67 | -------------------------------------------------------------------------------- /2016/03/3.md: -------------------------------------------------------------------------------- 1 | --- Day 3: Squares With Three Sides --- 2 | --------------------------------------- 3 | 4 | Now that you can think clearly, you move deeper into the labyrinth of 5 | hallways and office furniture that makes up this part of Easter Bunny 6 | HQ. This must be a graphic design department; the walls are covered in 7 | specifications for triangles. 8 | 9 | Or are they? 10 | 11 | The design document gives the side lengths of each triangle it 12 | describes, but... `5 10 25`? Some of these aren't triangles. You can't 13 | help but mark the impossible ones. 14 | 15 | In a valid triangle, the sum of any two sides must be larger than the 16 | remaining side. For example, the "triangle" given above is impossible, 17 | because `5 + 10` is not larger than `25`. 18 | 19 | In your puzzle input, *how many* of the listed triangles are *possible*? 20 | 21 | Your puzzle answer was `993`. 22 | 23 | --- Part Two --- 24 | ---------------- 25 | 26 | Now that you've helpfully marked up their design documents, it occurs to 27 | you that triangles are specified in groups of three *vertically*. Each 28 | set of three numbers in a column specifies a triangle. Rows are 29 | unrelated. 30 | 31 | For example, given the following specification, numbers with the same 32 | hundreds digit would be part of the same triangle: 33 | 34 | 101 301 501 35 | 102 302 502 36 | 103 303 503 37 | 201 401 601 38 | 202 402 602 39 | 203 403 603 40 | 41 | In your puzzle input, and instead reading by columns, *how many* of the 42 | listed triangles are *possible*? 43 | 44 | Your puzzle answer was `1849`. 45 | 46 | Both parts of this puzzle are complete! They provide two gold stars: 47 | \*\* 48 | --------------------------------------------------------------------------------