diff --git a/src/main.rs b/src/main.rs index 6f48b8c..4cf2a8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,26 @@ +use std::i32; + + fn main() { - println!("{:?}", get_byte(2)); + let buf = "Hello world!"; + + let mut i : i32 = 0; + + for b in buf.chars() { + println!("{:?}", b); + + for n in 0..i32::MAX { + if b == get_byte(n) { + i = n; + break; + } + } + + println!("{}", i); + } } -fn get_byte(id: i32) -> u8 { +fn get_byte(id: i32) -> char { let pid : f64 = 4.0 * series(1, id) - 2.0 * series(4, id) - series(5, id) - series(6, id); let mut y : f64 = (pid - (pid as i32) as f64 + 1.0).abs(); @@ -15,7 +33,7 @@ fn get_byte(id: i32) -> u8 { let second : u8 = y as u8; - (first << 4) | second + ((first << 4) | second) as char } fn series(m: i32, id: i32) -> f64 {