[Rust Programming] Advent of Code 2024 - Day 11 - Plutonian Pebbles

preview_player
Показать описание
My Rust solution for Day 11 of Advent of Code 2024.

#aoc #adventofcode #adventofcode2024 #rust #rustlang #aoc2024
Рекомендации по теме
Комментарии
Автор

Fyi, you can get the length of a number with logs. Here's my day 11 split function.

fn split(stone: u64) -> Vec<u64> {
if stone == 0 {
return vec![1];
}
let len = stone.ilog10() + 1;
if len % 2 == 0 {
let split = 10_u64.pow(len / 2);
vec![stone / split, stone % split]
} else {
vec![stone * 2024]
}
}

This is also helpful when contacting numbers:
a * 10_u64.pow(a.ilog10() + 1) + b

mrrobotman
welcome to shbcf.ru