Count unique shapes
Description:
You played Tetris, didn't you?
Synopsis
You are given a 2d area which looks like this:
To solve the Kata you need to calculate 2 numbers:
- number of pieces on the area
- number of unique shapes on the area
Rules
2 shaped pieces that touch each other horizontally or vertically are considered a single piece. For instance:
2 shaped pieces that touch each other diagonally are considered 2 distinct pieces. For instance:
2 pieces are considered to be of the same shape if one piece can be derived from the other by applying rotation, horizontal flipping or linear scaling
Example
Let's calculate pieces and shapes on the example area above: There are exactly 11 shaped pieces but only 5 unique shapes:
Note that 2 following pieces have the same shape but different scale.
|
|
And the following pieces also have the same shape but differently rotated / flipped.
|
|
I/O
Input - 2d array with 1s and 0s (ie binary). 1 is a part of a piece, 0 is an empty space.
Output - Tuple (Count_of_pieces, Count_of_unique_shapes).
see test examples for more details
Similar Kata:
Stats:
Created | Feb 5, 2023 |
Published | Feb 5, 2023 |
Warriors Trained | 66 |
Total Skips | 22 |
Total Code Submissions | 107 |
Total Times Completed | 5 |
C# Completions | 5 |
Total Stars | 4 |
% of votes with a positive feedback rating | 83% of 3 |
Total "Very Satisfied" Votes | 2 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 2 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 5 kyu |