Advent of Code 2024 was a great opportunity to learn something new: instead of focusing on completing the tasks, I chose to use Rust, a highly performant language which is recently getting a lot of praise.
Eventually, I couldn't make it past day 6, but I learned a lot in the process.
This was my attempt at day 5 part 2, which showed me how bad O(n*n!) is.
fn bogosort(mut arr: &mut Vec<i32>, rules:HashMap<i32, HashSet<i32>>){
let mut vec = arr.clone();
let mut arrcpy = arr.clone();
while(!is_ordered(vec.clone(), rules.clone())){
vec.clear();
arrcpy = arr.clone();
while !arrcpy.is_empty(){
let rand = rand::random_range(0..arrcpy.len());
let num = arrcpy[rand];
vec.push(num);
arrcpy.remove(rand);
}
arr.append(&mut vec);
println!("SUCCESS");
}