From 921879a6589ad457b19cd18eac1ffbb38470fa972b96ba31838da1d6dc13fd58 Mon Sep 17 00:00:00 2001 From: Nicholas Johnson Date: Sat, 20 Apr 2024 00:00:00 +0000 Subject: Make first line init logic easier to read --- src/hitomezashi.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hitomezashi.rs b/src/hitomezashi.rs index 02baff7..2b1e9ea 100644 --- a/src/hitomezashi.rs +++ b/src/hitomezashi.rs @@ -63,16 +63,16 @@ pub fn hitomezashi(width: usize, height: usize, skew: Option) { let mut above_bits: Vec = Vec::with_capacity(width); above_bits.push(init_bit); - print_square(above_bits[0]); - for col in 1..width { + for col in 0..(width - 1) { /* each square in the first row is derived from the square to its left. the column bits * represent whether there's a stitch between the two squares. if there's a stitch, the squares * are different, otherwise they are the same. */ - above_bits.push(above_bits[col - 1] ^ col_bits[col - 1]); print_square(above_bits[col]); + above_bits.push(above_bits[col] ^ col_bits[col]); } + print_square(above_bits[width - 1]); println!(); // height-1 because the first row has already been printed -- cgit v1.2.3