Skip to content

tornbygge

bradendubois edited this page Nov 24, 2021 · 8 revisions

Tower Construction

ID: tornbygge

Difficulty: 1.7

CPU Time: 1 second

Memory: 1024 MB

Solution

For this, keep a tally of towers, and a "current" and "previous" for bricks read in. Read the brick into "current", and if current > previous, increment the number of towers. Update previous to current and repeat. If previous is unset when starting, start t to 1 and always check if previous is some sentinel value (like -1), or set towers to 0 and skip checking if previous is unset.

Clone this wiki locally