Compute board-game score from regions
Company: Airbnb
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Onsite
You are given a 2D board for a board game. Each cell is encoded like `G1` or `W0`:
- The first character is the **terrain/area type** (e.g., `G`, `W`, `S`).
- The digit is the number of **crowns** in that cell (0–9).
Two cells belong to the same **area/region** if they have the same terrain type and are connected by 4-directional adjacency (up/down/left/right).
For each region:
\[
\text{regionScore} = (\#\text{cells in region}) \times (\text{sum of crowns in region})
\]
Return the **total score** across all regions.
### Example
Board (rows):
1. `G1, G2, W0, W1, S1`
2. `G2, G3, W0, W1, S1`
3. `S2, S3, S1, G1, S1`
4. `G1, G2, W0, W1, S1`
5. `G1, G2, W0, W1, S1`
Compute the total score for this board.
### Additional requirement
Write a small set of self-contained test cases that cover edge cases (e.g., all same terrain, all crowns 0, single-cell regions, multiple disjoint regions of same terrain type).
Quick Answer: This question evaluates grid traversal and connected-component identification skills along with region-based aggregation (counting cells and summing crowns) in the Coding & Algorithms category.