Adjusted to match C++ and Java double invert

This commit is contained in:
2020-07-25 16:08:55 -04:00
parent baab41f5c0
commit 6820764919
2 changed files with 17 additions and 8 deletions

View File

@@ -73,17 +73,19 @@ impl PartialEq for Location{
pub fn solve() -> Answer{ pub fn solve() -> Answer{
let NUM_ROWS = 15; let NUM_ROWS = 15;
//Start the timer
let mut timer = myClasses::Stopwatch::Stopwatch::new();
timer.start();
//Setup the list you are trying to find a path through //Setup the list you are trying to find a path through
//Reserve space for the list
let mut list = Vec::<Vec::<i32>>::new(); let mut list = Vec::<Vec::<i32>>::new();
for _ in 0..NUM_ROWS{ for _ in 0..NUM_ROWS{
list.push(Vec::<i32>::new()); list.push(Vec::<i32>::new());
} }
//Setup the list
setupList(&mut list); setupList(&mut list);
//Start the timer
let mut timer = myClasses::Stopwatch::Stopwatch::new();
timer.start();
//Invert the list //Invert the list
invert(&mut list); invert(&mut list);
@@ -128,6 +130,9 @@ pub fn solve() -> Answer{
} }
} }
//Invert the list again so you get the correct list
invert(&mut list);
//Stop the timer //Stop the timer
timer.stop(); timer.stop();

View File

@@ -158,17 +158,18 @@ impl PartialEq for Location{
pub fn solve() -> Answer{ pub fn solve() -> Answer{
let NUM_ROWS = 100; let NUM_ROWS = 100;
//Start the timer
let mut timer = myClasses::Stopwatch::Stopwatch::new();
timer.start();
//Setup the list you are trying to find a path through //Setup the list you are trying to find a path through
//Reserve space for the list
let mut list = Vec::<Vec::<i32>>::new(); let mut list = Vec::<Vec::<i32>>::new();
for _ in 0..NUM_ROWS{ for _ in 0..NUM_ROWS{
list.push(Vec::<i32>::new()); list.push(Vec::<i32>::new());
} }
setupList(&mut list); setupList(&mut list);
//Start the timer
let mut timer = myClasses::Stopwatch::Stopwatch::new();
timer.start();
//Invert the list //Invert the list
invert(&mut list); invert(&mut list);
@@ -213,6 +214,9 @@ pub fn solve() -> Answer{
} }
} }
//Invert the list again so you get the correct list
invert(&mut list);
//Stop the timer //Stop the timer
timer.stop(); timer.stop();