Day 6 complete!

This commit is contained in:
2019-12-16 20:51:35 -08:00
parent 83a3acbc05
commit 46f4275376
2 changed files with 126 additions and 19 deletions

View File

@@ -8,6 +8,7 @@ mod wiremap;
use crate::args::Command;
use crate::endchannel::channel;
use crate::fuel::calculate_fuel;
use crate::orbits::Object;
use crate::wiremap::WireMap;
use std::cmp::{max,min};
@@ -105,8 +106,26 @@ fn main() {
}
Command::Orbits(uom) => {
println!("Got orbits.");
println!("Got orbits:");
uom.show();
println!("Base map has {} orbits.", uom.num_orbits());
match uom.find_path(&Object::new("YOU"), &Object::new("SAN")) {
None =>
println!("There is no path from you to Santa. :("),
Some(path) => {
print!("The path from you to Santa is: ");
let mut path_iter = path.iter().peekable();
while let Some(x) = path_iter.next() {
print!("{}", x);
if path_iter.peek().is_some() {
print!(" => ");
}
}
println!("");
println!(" ... so the number of transfers needed is {}", path.len() - 3);
}
}
}
}
}