Ctrl K

Cells of a Spreadsheet Block

Easy
In a spreadsheet a cell is written as a column letter followed by a row number: B7 is column B, row 7. Columns are the Latin letters A to Z, rows are the digits 1 to 9. A rectangular block is given as a string block of the form "<top-left corner>:<bottom-right corner>", for example "C2:D4". Return a list of every cell in the block, ordered column by column from left to right and, within a column, row by row from top to bottom.
Example 1
block="C2:D4" → ['C2', 'C3', 'C4', 'D2', 'D3', 'D4']

First every row of column C (C2, C3, C4), then the same for column D.

Example 2
block="M7:M7" → ['M7']

Both corners are the same, so the block is a single cell.

Example 3
block="X5:Z5" → ['X5', 'Y5', 'Z5']
Constraints
  • len(block) == 5 and block[2] == ':'
  • 'A' ≤ block[0] ≤ block[3] ≤ 'Z'
  • '1' ≤ block[1] ≤ block[4] ≤ '9'
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsValue of a Roman Numeral EasyShared Start of Words EasyBracket Balance EasyWhere the Fragment Starts EasyLength of the Final Word Easy
loading Python…
Input
block="C2:D4"
Expected
['C2', 'C3', 'C4', 'D2', 'D3', 'D4']

Run checks the first 3 tests in your browser. Submit checks all 96 tests on the server, hidden ones included.