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2,1,4,3,1,3,1,2,4,1,2,4,3,2,3,5,5,3,3,1,2,3,4,5,2,4,5,1,1,1,4,5,3,5,3,5,1,1,5,1,5,3,1,2,3,4,1,1,4,1,2,4,1,5,4,1,5,4,2,1,5,2,1,3,5,5,4,5,5,1,1,4,1,2,3,5,3,3,1,1,1,4,3,1,1,4,1,5,3,5,1,4,2,5,1,1,4,4,4,2,5,1,2,5,2,1,3,1,5,1,2,1,1,5,2,4,2,1,3,5,5,4,1,1,1,5,5,2,1,1
|
||||||
@@ -1,3 +1,40 @@
|
|||||||
|
use std::{fs::read_to_string};
|
||||||
|
|
||||||
|
const ITERATIONS: u32 = 256;
|
||||||
|
const NEW_FISH_LIFETIME: u8 = 8;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
let input_char_vec = read_to_string("./input.txt").expect("ERROR reading file");
|
||||||
|
let split_input = input_char_vec.split(",").collect::<Vec<&str>>();
|
||||||
|
let mut fish: Vec<u8> = split_input.iter().map(
|
||||||
|
|x| x.parse::<u8>().unwrap()
|
||||||
|
).collect();
|
||||||
|
|
||||||
|
print_fish(&fish, -1);
|
||||||
|
|
||||||
|
for _i in 1..ITERATIONS + 1 {
|
||||||
|
for fi in 0..fish.len() {
|
||||||
|
let current_timer = fish[fi];
|
||||||
|
if current_timer == 0 {
|
||||||
|
fish[fi] = 6;
|
||||||
|
fish.push(NEW_FISH_LIFETIME);
|
||||||
|
} else {
|
||||||
|
fish[fi] = current_timer - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("Interation {} of {}, {}", _i, ITERATIONS, fish.len());
|
||||||
|
//print_fish(&fish, _i as i32);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
println!("Final Number of Fish: {}", fish.len());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print_fish(fish: &Vec<u8>, iteration: i32){
|
||||||
|
let fish_copy = fish.to_owned();
|
||||||
|
print!("Iteration: {}, Fish: ", iteration);
|
||||||
|
for f in fish_copy {
|
||||||
|
print!("{}, ", f);
|
||||||
|
}
|
||||||
|
print!("\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user