Worksheet range sum
Your task
A finance team exports a worksheet as a rectangular grid of whole numbers, where sheet[r][c] holds the value in row r and column c counting from zero. Ranges arrive as text in worksheet notation, for example B2:C3. A reference is one uppercase letter from A to Z naming the column, where A is column 0, followed by a row number counting from 1, so B2 means sheet[1][1]. The two references name opposite corners of a rectangle, but they can arrive in either order and either corner can come first, so C3:A1 and A3:C1 cover the same block as A1:C3. Return the sum of every value inside that rectangle, both corners included. Every reference lands inside the sheet.
Examples
sheet_range_total(sheet: list[list[int]], cell_range: str) -> intExample 1
Input
sheet_range_total([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]], "B2:C3")Output
34Example 2
Input
sheet_range_total([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]], "C3:A1")Output
54Example 3
Input
sheet_range_total([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]], "D1:D1")Output
4