my solutions to advent of code
aoc advent-of-code

rustfmt

aylac.top 1c36b88f 71d4c03c

verified
Changed files
+26 -13
2015
18
rust
src
2
rust
src
4
rust
src
2025
1
rust
src
2
rust
src
3
rust
src
+6 -1
2015/18/rust/src/main.rs
···
use std::mem::swap;
-
fn generations(times: u32, mut world: Vec<u8>, size: usize, stuck: bool) -> Vec<u8> {
+
fn generations(
+
times: u32,
+
mut world: Vec<u8>,
+
size: usize,
+
stuck: bool,
+
) -> Vec<u8> {
let pos = |x, y| y * (size + 2) + x;
let sizep = size + 1;
+2 -1
2015/2/rust/src/main.rs
···
use itertools::Itertools;
fn main() {
-
let input = std::fs::read_to_string("../input.txt").expect("invalid input!!");
+
let input =
+
std::fs::read_to_string("../input.txt").expect("invalid input!!");
let input = input
.trim()
.split("\n")
+2 -1
2015/4/rust/src/main.rs
···
}
fn main() {
-
let input = std::fs::read_to_string("../input.txt").expect("invalid input!!");
+
let input =
+
std::fs::read_to_string("../input.txt").expect("invalid input!!");
let input = input.trim();
let res = find(input, 5);
+3 -1
2025/1/rust/src/main.rs
···
turn,
// if it is below zero before being moduloed and the original number itself wasn't zero it means that it did touch zero but the division thing wouldn't count it, so we give this extra support.
// of course, there is no need to deal with a negative to positive situation because the acc.turn will never be negative!!!
-
zeroes: acc.zeroes + raw_zeroes + (acc.turn != 0 && raw_turn <= 0) as i32,
+
zeroes: acc.zeroes
+
+ raw_zeroes
+
+ (acc.turn != 0 && raw_turn <= 0) as i32,
}
},
);
+6 -4
2025/2/rust/src/main.rs
···
})
.collect();
-
let powers_of_ten: Vec<u64> = (0..=MAX_LENGTH as u32).map(|i| 10_u64.pow(i)).collect();
+
let powers_of_ten: Vec<u64> =
+
(0..=MAX_LENGTH as u32).map(|i| 10_u64.pow(i)).collect();
let [invalid_part_1, invalid_part_2] = {
let mut part_1: HashSet<u64> = HashSet::new();
···
for len in 1..=MAX_LENGTH / 2 {
// 1-9, 10-99, 100-999, 100000-999999
-
for combination in
-
*powers_of_ten.get(len - 1).unwrap_or(&1)..*powers_of_ten.get(len).unwrap()
+
for combination in *powers_of_ten.get(len - 1).unwrap_or(&1)
+
..*powers_of_ten.get(len).unwrap()
{
let mut number = 0;
// 0 is just the number (9), 1 is one repetition (99)
for repeat in 0..MAX_LENGTH / len {
-
number += combination * powers_of_ten.get((len * repeat) as usize).unwrap();
+
number += combination
+
* powers_of_ten.get((len * repeat) as usize).unwrap();
if repeat > 0 {
part_2.insert(number);
}
+5 -5
2025/3/rust/src/main.rs
···
input.iter().fold(0, |acc, bank| {
let bank_len = bank.len();
let (n, _) = (0..digits).rfold((0, 0), |(number, bank_index), i| {
-
let (loc, max) = bank[bank_index..bank_len - i].iter().enumerate().fold(
-
(0_usize, &0_u64),
-
|(maxi, max), (i, n)| {
+
let (loc, max) = bank[bank_index..bank_len - i]
+
.iter()
+
.enumerate()
+
.fold((0_usize, &0_u64), |(maxi, max), (i, n)| {
if n > max { (i, n) } else { (maxi, max) }
-
},
-
);
+
});
((number * 10) + max, bank_index + loc + 1)
});
+2
rustfmt.toml
···
+
edition = "2024"
+
max_width = 80