‹ back to the board

today · Thursday, November 12

Adeptalgorithms & data structures

The Sigil-Tablet of Ferrowind Caldera

On the floor of Ferrowind Caldera, a row of basalt columns stands shoulder to shoulder, running west to east. Each column is exactly one stride wide, and no gap separates neighbours. The Wardwrights' Guild has posted a commission. They will carve one rectangular warding sigil across the faces of a contiguous run of columns. The sigil's base rests on the caldera floor, and its top may not rise above the shortest column in that run. The Guild pays by area, so they want the largest sigil the row can hold.

Write largestSigil(heights).

  • heights is a list of non-negative integers. The value at each position is the height of that column, in strides, in west-to-east order. The list may be empty, and a height may be 0.
  • For a non-empty contiguous run from index i to index j inclusive, the area of the sigil is (j - i + 1) * min(heights[i..j]).
  • Return the largest such area over all non-empty contiguous runs, as an integer.
  • If heights is empty, return 0.
  • stacks and queues
  • Adept
  • efficiency bonus

examples

  1. case 1heights of [2, 1, 5, 6, 2, 3]10 - the columns of height 5 and 6 carry a sigil 2 strides wide and 5 tall
  2. case 2heights of [2, 1, 2]3 - the short middle column lets a sigil 1 tall span all three columns, beating either tall column alone
  3. case 3heights of [] (no columns at all)0
reward
360 XP
signature
largestSigil
not yet run

TypeScript, run as ES2022 — types are stripped, not checked. If a JS engine would run it, so will we.

loading the editor…
  • guild_sample
  • empty_row
  • single_column
  • all_zero
  • two_columns
  • equal_heights
  • rising_row
  • falling_row
  • mixed_row
  • zero_splits_row
  • short_middle_spans
  • long_low_ridge_with_spire
The Sigil-Tablet of Ferrowind Caldera · bitwick