WAiting for approval of this function.
This commit is contained in:
parent
c90d69fdb9
commit
0d7097dbf8
@ -74,3 +74,19 @@ pub fn round_score(play: char, counter_play: char) -> i32 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn solve_part1(file_path: &str) -> i32 {
|
||||||
|
let contents =
|
||||||
|
std::fs::read_to_string(file_path).expect("Please provide a text file as an argument.");
|
||||||
|
let lines: Vec<&str> = contents.split('\n').collect();
|
||||||
|
lines
|
||||||
|
.iter()
|
||||||
|
.map(|line| {
|
||||||
|
let first: char = line.chars().nth(0).unwrap_or('R');
|
||||||
|
let last: char = line.chars().nth(2).unwrap_or('R');
|
||||||
|
round_score(first, last)
|
||||||
|
})
|
||||||
|
.collect::<Vec<i32>>()
|
||||||
|
.iter()
|
||||||
|
.sum()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user