A higher resolution is required to access the IDE
- 10
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Goal
There is a saying that no two snowflakes are alike, but you are skeptical of this claim. On a snowy day, you take a photo of the sky to test this claim. The goal is to find out how many total snowflakes are in the photo and how many of them are unique shapes.Photo:
A photo is a 2D grid representing a snapshot of the sky. Each cell contains either: an asterisk (
Snowflakes:
Snowflakes are formed from one or more connected asterisks (
Two snowflakes are considered to have the same shape if one can be transformed into the other by any combination of rotation (any multiple of 90°) and/or mirror reflection.
Example of the same snowflake shape in different orientations:
**. *** ..* ... .** *** *.. ...
*.. ..* ..* *.. ..* *.. *.. ..*
*.. ... .** *** ..* ... **. ***
Input
Line 1: Space separated integers representing the hight and width of the photo, in the form: h w
Next h Lines: String of length w representing a row of the photo.
Next h Lines: String of length w representing a row of the photo.
Output
Line 1: Integer of the total number of snowflakes.
Line 2: Integer of the number of distinct snowflakes shapes.
Line 2: Integer of the number of distinct snowflakes shapes.
Constraints
1 ≤ h, w ≤ 50
Example
Input
3 3 .*. *** .*.
Output
1 1
A higher resolution is required to access the IDE