cargo fmt
This commit is contained in:
parent
e0e68e5b6a
commit
94b3b3fd3b
4 changed files with 25 additions and 29 deletions
|
@ -1,8 +1,8 @@
|
|||
fn main() {
|
||||
|
||||
|
||||
let mut list1: Vec<i32> = serde_json::from_reader(std::fs::File::open("l1.json").unwrap()).unwrap();
|
||||
let mut list2: Vec<i32> = serde_json::from_reader(std::fs::File::open("l2.json").unwrap()).unwrap();
|
||||
let mut list1: Vec<i32> =
|
||||
serde_json::from_reader(std::fs::File::open("l1.json").unwrap()).unwrap();
|
||||
let mut list2: Vec<i32> =
|
||||
serde_json::from_reader(std::fs::File::open("l2.json").unwrap()).unwrap();
|
||||
|
||||
list1.sort();
|
||||
list2.sort();
|
||||
|
@ -17,8 +17,7 @@ fn main() {
|
|||
let int2 = list2[i];
|
||||
if int1 > int2 {
|
||||
totaldiff += (int1 - int2) as i64;
|
||||
}
|
||||
else if int1 < int2 {
|
||||
} else if int1 < int2 {
|
||||
totaldiff += (int2 - int1) as i64;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
fn main() {
|
||||
let mut list1: Vec<i32> = serde_json::from_reader(std::fs::File::open("l1.json").unwrap()).unwrap();
|
||||
let mut list2: Vec<i32> = serde_json::from_reader(std::fs::File::open("l2.json").unwrap()).unwrap();
|
||||
let mut list1: Vec<i32> =
|
||||
serde_json::from_reader(std::fs::File::open("l1.json").unwrap()).unwrap();
|
||||
let mut list2: Vec<i32> =
|
||||
serde_json::from_reader(std::fs::File::open("l2.json").unwrap()).unwrap();
|
||||
|
||||
let mut simScoreTotal: i64 = 0;
|
||||
|
||||
|
|
|
@ -3,12 +3,15 @@ use std::thread::current;
|
|||
|
||||
fn main() {
|
||||
// read file input
|
||||
let lines: Vec<String> = read_to_string("input.txt").unwrap().lines().map(String::from).collect();
|
||||
let lines: Vec<String> = read_to_string("input.txt")
|
||||
.unwrap()
|
||||
.lines()
|
||||
.map(String::from)
|
||||
.collect();
|
||||
// current safe total count
|
||||
let mut safecount = 0;
|
||||
// for each line
|
||||
for i in lines {
|
||||
|
||||
println!("{i}");
|
||||
// for each line, split into a Vec<String> of the values
|
||||
let mut frfrstr: Vec<String> = i.split_whitespace().map(|s| s.parse().unwrap()).collect();
|
||||
|
@ -28,19 +31,16 @@ fn main() {
|
|||
let mut sort2 = sort1.clone();
|
||||
sort2.reverse();
|
||||
if frfr == sort1 || frfr == sort2 {
|
||||
|
||||
let mut mode = 0;
|
||||
let tempval0 = frfr[*&0];
|
||||
let tempval1 = frfr[*&1];
|
||||
if tempval0 < tempval1 {
|
||||
println!("increasing mode");
|
||||
mode = 1;
|
||||
}
|
||||
else if tempval0 > tempval1 {
|
||||
} else if tempval0 > tempval1 {
|
||||
println!("decreasing mode");
|
||||
mode = -1;
|
||||
}
|
||||
else if tempval0 == tempval1 {
|
||||
} else if tempval0 == tempval1 {
|
||||
println!("its equal and so its discarded");
|
||||
continue;
|
||||
}
|
||||
|
@ -56,8 +56,7 @@ fn main() {
|
|||
currentcheckstate = false;
|
||||
println!("abs diff averted");
|
||||
}
|
||||
}
|
||||
else if mode == -1 {
|
||||
} else if mode == -1 {
|
||||
if realdiff > 3 || realdiff < 1 {
|
||||
println!("realdiff {realdiff} minus");
|
||||
currentcheckstate = false;
|
||||
|
@ -69,15 +68,11 @@ fn main() {
|
|||
safemini = true;
|
||||
println!("allowed")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if safemini {
|
||||
safecount += 1
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
println!("{safecount}")
|
||||
}
|
||||
|
|
|
@ -3,12 +3,15 @@ use std::thread::current;
|
|||
|
||||
fn main() {
|
||||
// read file input
|
||||
let lines: Vec<String> = read_to_string("input.txt").unwrap().lines().map(String::from).collect();
|
||||
let lines: Vec<String> = read_to_string("input.txt")
|
||||
.unwrap()
|
||||
.lines()
|
||||
.map(String::from)
|
||||
.collect();
|
||||
// current safe total count
|
||||
let mut safecount = 0;
|
||||
// for each line
|
||||
for i in lines {
|
||||
|
||||
println!("{i}");
|
||||
// for each line, split into a Vec<String> of the values
|
||||
let mut frfrstr: Vec<String> = i.split_whitespace().map(|s| s.parse().unwrap()).collect();
|
||||
|
@ -27,7 +30,6 @@ fn main() {
|
|||
frfr.remove(i);
|
||||
}
|
||||
|
||||
|
||||
// sorted regular and reverse to check condition 1
|
||||
let mut sort1 = frfr.clone();
|
||||
sort1.sort();
|
||||
|
@ -77,8 +79,6 @@ fn main() {
|
|||
if safemini {
|
||||
safecount += 1
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
println!("{safecount}")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue