Compress is working, I guess. Need to fix decompress to validate.

This commit is contained in:
2016-05-29 12:13:49 +02:00
parent 213b6c2291
commit 81ae7e09f2

View File

@@ -1,13 +1,22 @@
use std::env;
use std::fs;
use std::io::BufReader;
use std::io::prelude::*;
use std::i32;
fn main() {
let buf = "Hello world!";
let output_filename = env::args().nth(1).unwrap();
let mut output_file = fs::File::create(output_filename).unwrap();
let input_filename = env::args().nth(2).unwrap();
let input_file = fs::File::open(input_filename).unwrap();
let input_buf = BufReader::new(input_file);
let mut i : i32 = 0;
for b in buf.chars() {
println!("{:?}", b);
for b in input_buf.bytes() {
let b = b.unwrap();
for n in 0..i32::MAX {
if b == get_byte(n) {
@@ -16,11 +25,11 @@ fn main() {
}
}
println!("{}", i);
output_file.write(&[i as u8]).unwrap();
}
}
fn get_byte(id: i32) -> char {
fn get_byte(id: i32) -> u8 {
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();
@@ -33,7 +42,7 @@ fn get_byte(id: i32) -> char {
let second : u8 = y as u8;
((first << 4) | second) as char
(first << 4) | second
}
fn series(m: i32, id: i32) -> f64 {