summaryrefslogtreecommitdiff
path: root/2024/11
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2026-03-18 21:48:13 +0000
committermhsn <mail@mhsn.net>2026-03-18 21:48:13 +0000
commit86bac31392a76da84817eec020d2b84d099b3cc1 (patch)
treee2ee52db59b86b914d5b4bcceb19c9b5d899fff4 /2024/11
parent62fe361fc42dea75deaf7ac31c0ba6ba80e26a9c (diff)
downloadpuzzles-master.tar.gz
puzzles-master.zip
add other challenges supportHEADmaster
Diffstat (limited to '2024/11')
-rwxr-xr-x2024/11/python.py30
-rw-r--r--2024/11/rust/Cargo.lock7
-rw-r--r--2024/11/rust/Cargo.toml6
-rw-r--r--2024/11/rust/src/main.rs43
4 files changed, 0 insertions, 86 deletions
diff --git a/2024/11/python.py b/2024/11/python.py
deleted file mode 100755
index 37f658e..0000000
--- a/2024/11/python.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python3
-
-from fileinput import input
-from functools import cache
-from math import floor, log
-
-stones = [int(x) for x in input().readline().split()]
-
-
-@cache
-def blink(s, n):
- if n == 0:
- return 1
-
- if s == 0:
- return blink(1, n - 1)
-
- digits = floor(log(s, 10) + 1e-6) + 1
- if digits % 2 == 0:
- left, right = divmod(s, 10 ** (digits // 2))
- return blink(left, n - 1) + blink(right, n - 1)
-
- return blink(s * 2024, n - 1)
-
-
-silver = sum(blink(s, 25) for s in stones)
-gold = sum(blink(s, 75) for s in stones)
-
-print("silver:", silver)
-print("gold:", gold)
diff --git a/2024/11/rust/Cargo.lock b/2024/11/rust/Cargo.lock
deleted file mode 100644
index 22c9989..0000000
--- a/2024/11/rust/Cargo.lock
+++ /dev/null
@@ -1,7 +0,0 @@
-# This file is automatically @generated by Cargo.
-# It is not intended for manual editing.
-version = 4
-
-[[package]]
-name = "aoc_2024-11"
-version = "0.1.0"
diff --git a/2024/11/rust/Cargo.toml b/2024/11/rust/Cargo.toml
deleted file mode 100644
index 67185f7..0000000
--- a/2024/11/rust/Cargo.toml
+++ /dev/null
@@ -1,6 +0,0 @@
-[package]
-name = "aoc_2024-11"
-version = "0.1.0"
-edition = "2021"
-
-[dependencies]
diff --git a/2024/11/rust/src/main.rs b/2024/11/rust/src/main.rs
deleted file mode 100644
index e352ec4..0000000
--- a/2024/11/rust/src/main.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-use std::{collections::HashMap, io};
-
-fn blink(k @ (s, n): (u64, u64), cache: &mut HashMap<(u64, u64), u64>) -> u64 {
- if n == 0 {
- return 1;
- }
- if let Some(v) = cache.get(&k) {
- return *v;
- }
-
- // cache this
- let v = {
- if s == 0 {
- return blink((1, n - 1), cache);
- }
- let digits = s.ilog10() + 1;
- let mid = 10u64.pow(digits / 2);
- if digits % 2 == 0 {
- blink((s / mid, n - 1), cache) + blink((s % mid, n - 1), cache)
- } else {
- blink((s * 2024, n - 1), cache)
- }
- };
-
- *cache.entry(k).or_insert(v)
-}
-
-fn main() -> io::Result<()> {
- let line = io::stdin().lines().flatten().next().unwrap();
- let stones = line
- .split_whitespace()
- .map(|s| s.parse::<u64>().unwrap())
- .collect::<Vec<_>>();
-
- let mut cache = HashMap::new();
- let silver: u64 = stones.iter().map(|s| blink((*s, 25), &mut cache)).sum();
- let gold: u64 = stones.iter().map(|s| blink((*s, 75), &mut cache)).sum();
-
- println!("silver: {silver}");
- println!("gold: {gold}");
-
- return Ok(());
-}