Started work on Dec 5
This commit is contained in:
@@ -1,3 +1,26 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader};
|
||||
use std::io::prelude::*;
|
||||
use std::vec;
|
||||
|
||||
fn main(){
|
||||
let file = File::open("./example.txt").expect("Read failed");
|
||||
let reader = BufReader::new(file);
|
||||
|
||||
let mut lines: Vec<((u32, u32),(u32, u32))> = Vec::new();
|
||||
|
||||
for line in reader.lines(){
|
||||
let line_as_string = line.unwrap();
|
||||
let split_string = line_as_string.split(" -> ").collect::<Vec<&str>>();
|
||||
let origin = split_string[0].split(",").collect::<Vec<&str>>();
|
||||
let dest = split_string[1].split(",").collect::<Vec<&str>>();
|
||||
let x1 = origin[0].parse::<u32>().unwrap();
|
||||
let y1 = origin[1].parse::<u32>().unwrap();
|
||||
let x2 = dest[0].parse::<u32>().unwrap();
|
||||
let y2 = dest[1].parse::<u32>().unwrap();
|
||||
|
||||
if x1 == x2 || y1 == y2 {
|
||||
lines.push(((x1,y1),(x2,y2)))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user