day 6 to u8 conversion
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
blackbeard420 2021-12-09 20:46:42 -05:00
parent 5212957a18
commit a613072c49

View File

@ -7,18 +7,18 @@ fn remove_whitespace(s: &str) -> String {
return s.split_whitespace().collect();
}
fn load_file() -> Result<Vec<i64>, std::io::Error> {
fn load_file() -> Result<Vec<u8>, std::io::Error> {
let file = fs::File::open(PATH)?;
let reader = std::io::BufReader::new(file);
let res: Vec<i64> = reader.split(b',').map(|p| {
let res: Vec<u8> = reader.split(b',').map(|p| {
let p = p.unwrap();
let v = String::from_utf8_lossy(&p);
return remove_whitespace(&v).parse::<i64>().unwrap();
return remove_whitespace(&v).parse::<u8>().unwrap();
}).collect();
return Ok(res);
}
fn run_day(v: &mut Vec<i64>) {
fn run_day(v: &mut Vec<u8>) {
let len = v.len();
for i in 0..len {
@ -44,8 +44,9 @@ fn part1() {
fn part2() {
let mut x = load_file().unwrap();
for _ in 0..256 {
for i in 0..256 {
run_day(&mut x);
println!("day: {} fish: {}", i+1, x.len());
}
println!("total: {}", x.len());