~cdv/aoc-2018-rs

0402e3610ca1e3702692cec38685f1a68c21e3d6 — Christopher Vittal 2 years ago 6b5ed57
Optimize, minor tweaks
1 files changed, 4 insertions(+), 3 deletions(-)

M src/bin/day10.rs
M src/bin/day10.rs => src/bin/day10.rs +4 -3
@@ 19,10 19,11 @@ fn main() {
        .map(|v| (Point(v[0], v[1]), Point(v[2], v[3])))
        .collect::<Vec<_>>();

    let mut by_pos = FxHashMap::default();
    for i in 1.. {
        by_pos.clear();
        let mut xp = (1000000i32, -1000000i32);
        let mut yp = (1000000i32, -1000000i32);
        let mut by_pos = FxHashMap::default();

        for &mut (ref mut pos, ref vel) in &mut input {
            *pos += *vel;


@@ 40,6 41,7 @@ fn main() {

        println!("  1:");
        for y in yp.0..=yp.1 {
            print!("\t");
            for x in xp.0..=xp.1 {
                if let Some(_) = by_pos.remove(&Point(x, y)) {
                    print!("#");


@@ 47,8 49,7 @@ fn main() {
                    print!(" ");
                }
            }

            println!("");
            println!();
        }

        println!("  2: {}", i);