AoC 2025 Day 2
https://adventofcode.com/2025/day/2
fn is_repeated_twice(id: u128) -> bool {
let id_string = id.to_string();
let id_len = id_string.len();
// if each half of the id-string are equal then the ID is repeated
let (ids1, ids2) = id_string.split_at((id_len) / 2);
ids1 == ids2
}
fn is_repeated(id: u128) -> bool {
let id_string = id.to_string();
let id_len = id_string.len();
// try all possible pattern lengths
for block_len in 1..=(id_len / 2) {
// if the block-len is not
// divisible by id-len then
// it's not a repeated id
if id_len % block_len != 0 {
continue;
}
// the first block is what we will compare the other blocks to
let first_block = &id_string[..block_len];
let mut ok = true;
for i in (block_len..id_len).step_by(block_len) {
// if any block does not equal the first one then this is not
// a repeating pattern
if &id_string[i..i + block_len] != first_block {
ok = false;
break;
}
}
if ok {
return true;
}
}
false
}
fn main() {
let ranges = include_str!("./input2.txt").trim().split(",").map(|range| {
let (first, second) = range.split_once("-").unwrap();
let first = first.parse::<u128>().unwrap();
let second = second.parse::<u128>().unwrap();
first..=second
});
let p1: u128 = ranges
.clone()
.map(|x| x.filter(|&n| is_repeated_twice(n)).sum::<u128>())
.sum();
let p2: u128 = ranges
.map(|x| x.filter(|&n| is_repeated(n)).sum::<u128>())
.sum();
println!("solution: {p1}");
println!("solution: {p2}");
}https://adventofcode.com/2025/day/2
https://youtu.be/QcQYEAr0Yos
I can only aspire to be this much of a nerd
I can only aspire to be this much of a nerd
YouTube
Building a CPU in Factorio: From D-Flip-Flops to an Operating System
This is an English translation of a talk I gave at the 39th Chaos Communication Congress in Hamburg. If you understand German, please check out the original recording of the talk:
German 39c3 talk: https://www.youtube.com/watch?v=FLUeSurkMOI&t=14s
I explain…
German 39c3 talk: https://www.youtube.com/watch?v=FLUeSurkMOI&t=14s
I explain…
😱1🙏1