Skip to content

Commit

Permalink
Year 2019 Day 13 fix different sized game play area
Browse files Browse the repository at this point in the history
  • Loading branch information
maneatingape committed Dec 28, 2024
1 parent 1483baa commit 667b6c5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/year2019/day13.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn parse(input: &str) -> Vec<i64> {

pub fn part1(input: &[i64]) -> usize {
let mut computer = Computer::new(input);
let mut tiles = [0; 44 * 20];
let mut tiles = [0; 44 * 22];

loop {
let State::Output(x) = computer.run() else {
Expand All @@ -39,7 +39,7 @@ pub fn part2(input: &[i64]) -> i64 {
modified[0] = 2;

let mut computer = Computer::new(&modified);
let mut tiles = [0; 44 * 20];
let mut tiles = [0; 44 * 22];
let mut score = 0;
let mut blocks = score;
let mut ball: i64 = 0;
Expand Down Expand Up @@ -97,14 +97,14 @@ fn draw(tiles: &[i64], score: i64, blocks: i64) {
use std::time::Duration;

// Wait until the initial screen is complete
if tiles[879] != 1 {
if tiles[879] != 1 && tiles[960] != 1 {
return;
}

let s = &mut String::new();
let _ = writeln!(s, "{WHITE}{BOLD}Blocks: {blocks}\tScore: {score} {RESET}");

for y in 0..20 {
for y in 0..22 {
for x in 0..44 {
let _unused = match tiles[44 * y + x] {
0 => write!(s, " "),
Expand Down

0 comments on commit 667b6c5

Please sign in to comment.