aoc2023/src/lib.rs

29 lines
477 B
Rust
Raw Normal View History

2023-11-30 21:46:12 +01:00
#![feature(pattern)]
pub mod parsers;
2023-11-29 22:00:59 +01:00
pub mod template;
2023-12-08 08:01:05 +01:00
2023-12-09 13:39:15 +01:00
use std::mem::swap;
2023-12-08 08:01:05 +01:00
pub fn lcm(first: usize, second: usize) -> usize {
first * second / gcd(first, second)
}
pub fn gcd(first: usize, second: usize) -> usize {
let mut max = first;
let mut min = second;
if min > max {
swap(&mut min, &mut max)
}
loop {
let res = max % min;
if res == 0 {
return min;
}
max = min;
min = res;
}
}