امن برياني
93 subscribers
372 photos
56 videos
12 files
110 links
What I cannot create, I do not understand.
I share what I make here, alongside some silly memes and other stuff
Download Telegram
Channel created
h-3938a.pdf
21.1 MB
Race Condition Symphony: From Tiny Idea to Pwnie
Forwarded from Micro Space
جميع المصادر المذكورة بالفديو:
AoC 2025 day 1
fn main() {
// initial vals
let mut pos = 50; // dial starts on 50
let mut p1 = 0; // part 1
let mut p2 = 0; // part 2
let steps = include_str!("./input.txt").lines().map(|rot| {
// left rotations decrease the dial by 1 so it's negative
let negative = rot.starts_with('L');
// parse the value
let clicks = rot[1..].parse::<i32>().unwrap();
(negative, clicks)
});
for (negative, clicks) in steps {
if negative {
// count for overflowing rotations
p2 += clicks / 100;
// if the rotation passes by zero add one to part2
p2 += (pos != 0 && clicks % 100 >= pos) as i32;
pos = (pos - clicks).rem_euclid(100);
} else {
pos += clicks;
p2 += pos / 100;
pos = pos.rem_euclid(100);
}
// for each time that pos equals zero at
// the end of a rotation, add one to part1
p1 += (pos == 0) as i32;
}
println!("solution: {p1}");
println!("solution: {p2}");
}

https://adventofcode.com/2025/day/1
AoC 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
happy new year everyone
❤4
الالمانيين ياخي
💋1
Forwarded from Btetah for "سچ" (btetah)
عاش هاي الصحفية طشرت معلوماتنا
شكد حلو من ينشرون رقمك واسمك وانت لابيها ولا عليها
🤣4
❤1💋1