Skip to content

anotherbrick

bradendubois edited this page Nov 8, 2021 · 7 revisions

Another Brick in the Wall

ID: anotherbrick

Difficulty: 2.1

CPU Time: 1 second

Memory: 1024 MB

Solution

Keep two tallies, one for the number of layers complete, and one for the horizontal distance of the current layer completed. Iterating through the bricks, add the width of the brick to the horizontal distance; if the distance == w, reset distance to 0, and increment the number of layers complete. If the number of layers complete is equal to h, then output "YES". Otherwise, output "NO".

Clone this wiki locally