From f1e3b888bd3e9ab554762ec3382e6de155871b3e Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Wed, 28 Nov 2018 17:07:14 +0100 Subject: [PATCH] change example code --- school/intro-crypto/uebung/05/p/src/main.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/school/intro-crypto/uebung/05/p/src/main.rs b/school/intro-crypto/uebung/05/p/src/main.rs index ed4a4ec..26c510b 100644 --- a/school/intro-crypto/uebung/05/p/src/main.rs +++ b/school/intro-crypto/uebung/05/p/src/main.rs @@ -13,16 +13,16 @@ fn p(i: [T; 32]) -> [T; 32] { fn main() { let i: [u8; 32] = [ - 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, - 0, 0, + 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, + 0, 1, ]; p(i).iter().for_each(|i| print!("{}", i)); println!(); let p = &[ - true, false, false, false, false, false, true, false, false, true, false, true, true, - false, false, true, true, true, false, true, false, true, true, true, false, false, true, - true, true, false, true, true, + true, false, false, false, false, false, true, false, false, true, true, true, true, false, + false, true, true, true, false, true, false, true, true, true, true, false, true, true, + true, false, true, true, ]; let l0 = &[ true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, @@ -36,4 +36,14 @@ fn main() { .map(|x| if x { '1' } else { '0' }) .for_each(|x| print!("{}", x)); println!(); + + let lo = b"11111111111111111111111111111101"; + let ln = b"11111111111111111111111111111111"; + let cl = lo.iter().zip(ln.iter()).filter(|(a, b)| a != b).count(); + println!("cl = {}", cl); + + let ro = b"01111101101001100010100011000100"; + let rn = b"01111101100001100010100001000100"; + let cr = ro.iter().zip(rn.iter()).filter(|(a, b)| a != b).count(); + println!("cr = {}", cr); }