Function advent_of_code_2021::day_13::display_dots[−][src]

fn display_dots(dots: &HashSet<(usize, usize)>) -> String
Expand description

This calculates the maximum x and y in the set to determine the grid bounds, then loops through each row and column outputting a ▮ or based on if the current coordinate is in the set.

Example from puzzle specification

let dots = HashSet::from([
    (6usize, 10usize),
    (0usize, 14usize),
    (9usize, 10usize),
    (0usize, 3usize),
    (10usize, 4usize),
    (4usize, 11usize),
    (6usize, 0usize),
    (6usize, 12usize),
    (4usize, 1usize),
    (0usize, 13usize),
    (10usize, 12usize),
    (3usize, 4usize),
    (3usize, 0usize),
    (8usize, 4usize),
    (1usize, 10usize),
    (2usize, 14usize),
    (8usize, 10usize),
    (9usize, 0usize),
]);

let folds = vec![(Y, 7usize), (X, 5usize)];

let expected = "▮▮▮▮▮\n\
                ▮   ▮\n\
                ▮   ▮\n\
                ▮   ▮\n\
                ▮▮▮▮▮\n\
                ".to_string();

assert_eq!(display_dots(&apply_folds(&dots, &folds)), expected);