parsing input

This commit is contained in:
talksik
2023-06-30 20:03:43 -07:00
commit d6dd6dbfcb
5 changed files with 146 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
// reads the input and puts into a matrix.
// each inner vector is a row of the matrix
fn read_input() -> Vec<Vec<u32>> {
let input = std::fs::read_to_string("./input.txt").unwrap();
let mut trees = vec![];
for line in input.lines() {
let mut row = vec![];
for tree in line.chars() {
// parse char to u32
let tree_height = tree.to_digit(10).unwrap();
row.push(tree_height);
}
trees.push(row);
}
trees
}
fn main() {
println!("Hello, world!");
let input = read_input();
}
#[cfg(test)]
mod tests {
#[test]
fn part_one() {}
}