diff --git a/set1/fixed_xor/src/main.rs b/set1/fixed_xor/src/main.rs index fa4156f..500b9c1 100644 --- a/set1/fixed_xor/src/main.rs +++ b/set1/fixed_xor/src/main.rs @@ -4,7 +4,6 @@ extern crate env_logger; extern crate rustc_serialize; use rustc_serialize::hex::{FromHex, ToHex}; -use std::cmp::min; use std::io::{BufRead, stdin}; struct Pairwise(T); @@ -27,13 +26,7 @@ fn main() { for (line1, line2) in Pairwise(stdin.lock().lines().filter_map(|x| x.ok())) { match (line1.from_hex(), line2.from_hex()) { - (Ok(v1), Ok(v2)) => { - let mut out = Vec::with_capacity(min(v1.len(), v2.len())); - for (lhs, rhs) in v1.iter().zip(v2) { - out.push(lhs ^ rhs) - } - println!("{}", out.to_hex()) - }, + (Ok(v1), Ok(v2)) => println!("{}", v1.iter().zip(v2).map(|(a, b)| a ^ b).collect::>().to_hex()), (Err(e), _) => error!("{}", e), (_, Err(e)) => error!("{}", e) }