Client/src/main.rs

67 lines
1.8 KiB
Rust
Raw Normal View History

use crate::diff::diff;
2023-05-28 21:43:20 -04:00
mod matrix;
2023-05-31 22:31:49 -04:00
mod lcs;
mod diff;
2023-05-28 21:43:20 -04:00
2023-05-31 22:31:49 -04:00
fn main() {
let a = "abcabba\nlkajsdfasdf\nasdfasdfasdf\nlasjkdf";
let b = "abcabba\ncbabasdfasdf\nlasjkdf";
2023-05-28 21:43:20 -04:00
diff(a, b);
// lcs(a, b);
2023-05-27 11:27:49 -04:00
}
2023-05-31 22:31:49 -04:00
// fn lcs(a: &str, b: &str) {
// let n = a.len() as i32;
// let m = b.len() as i32;
// let max = n + m;
// let mut endpoints = vec![0i32; max as usize * 2];
//
// for script_length in 0..max {
// let mut k = -script_length;
// while k <= script_length * 2 {
// let index = (k + max) as usize + 1;
// let previous_endpoint = endpoints[index - 1];
// let next_endpoint = endpoints[index + 1];
//
// let mut x = if k == -script_length || k != script_length && previous_endpoint < next_endpoint {
// next_endpoint
// } else {
// previous_endpoint + 1
// };
//
// let mut y = if k < x {
// x - k
// } else {
// 0
// };
//
// // Increase x and y as long as we are in a common sequence between a and b
// while x < n && y < m {
// let ac = a.chars().nth(x as usize).unwrap();
// let bc = b.chars().nth(y as usize).unwrap();
//
// if ac != bc {
// break;
// }
//
// x += 1;
// y += 1;
// }
//
// endpoints[index] = x;
//
// // We have traveled through both strings, the length of the shortest edit script (SES) has been found.
// if x >= n && y >= m {
// println!("Length of a SES is D ({d})");
// return;
// }
//
// k += 2;
// }
// }
//
// println!("Length of a SES is greater than MAX ({max})");
// }