TristripeBacteria
TCCC07 Sponsor 3 · 2007-07-30 · by Mike Mirzayanov
Problem Statement
You are given a
You are studying a special kind of bacteria called tristripe bacteria. They have a special property: a tristripe bacterium can be formed by exactly three stripes (horizontal or vertical) that possibly intersect and/or overlap. All four bacteria in the picture below are tristripe:
{"........................***...",
"......*........*.........***..",
"...******..................***",
"......*.............*.........",
".....**.........******........",
".............................."}
Return the number of tristripes in the photo.
Constraints
- photo will contain between 1 and 50 elements, inclusive.
- Each element of photo will contain between 1 and 50 characters, inclusive.
- Each element of photo will contain the same number of characters.
- Each element of photo will contain only the characters '.' and '*'.
{"........................***...",
"......*........*.........***..",
"...******..................***",
"......*.............*.........",
".....**.........******........",
".............................."}
Returns: 4
This example is from the statement.
{".....................*********",
"......*..............*********",
"...******............*********",
"......*.........*...*.........",
".....**.........******........",
"....**........................"}
Returns: 2
The leftmost bacterium is not a tristripe.
{"."}
Returns: 0
{"*****************"}
Returns: 1
{"*","*","*","*","*","*","*"}
Returns: 1
Submissions are judged against all 266 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TristripeBacteria with a public method int howMany(vector<string> photo) · 266 test cases · 2 s / 256 MB per case