This commit is contained in:
2018-12-03 23:44:18 +00:00
parent 026be18835
commit 4bebe8110e
2 changed files with 81 additions and 0 deletions

33
02/part2.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::collections::HashMap;
use std::error::Error;
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
fn main() -> std::io::Result<()> {
let mut f = File::open("input")?;
let mut data = String::new();
f.read_to_string(&mut data)?;
for lineA in data.lines() {
for lineB in data.lines() {
let mut a = lineA.chars();
let mut b = lineB.chars();
let mut diffCount = 0;
let mut pairs = a.zip(b);
for (aChar, bChar) in pairs {
if aChar != bChar {
diffCount += 1;
}
}
if diffCount == 1 {
println!("lineA: {} lineB: {}", lineA, lineB);
}
}
}
Ok(())
}