While we're on a triangular grids kick, I'd like to point out that there is an equivalent to polyominoes on a triangular grid. They are called polyiamonds, and they are shapes formed by gluing equilateral triangles together along their edges. In this challenge you are going to be deciding which subsets of a triangular grid are polyiamonds, and whether they have holes in them. Because it only takes 9 triangles to make a polyiamond with a hole in it, your code needs to be as short as possible.
The grid
We'll use Martin's triangular grid layout for the input:
Pay attention to the fact that the centers of the triangles form a roughly rectangular grid and that the top left triangle "points" upward. We can describe a subset of this grid, then, by giving a rectangular "star map" indicating which triangles are included and which are not included. For instance, this map:
** **
*****
corresponds to the smallest polyiamond which contains a hole:
Holes
A polyiamond which contains a hole like the example above (a region not a part of the polyiamond, which is surrounded on all sides by regions which are) is not, topologically speaking, simply connected.
The Challenge
Write a function or program which takes as input a "star map" as described above and output a truthy if and only if the indicated subset of the triangular grid is a simply connected polyiamond.
More Examples
*** ***
*******
corresponds to the polyiamond
which is simply connected.
* *
** **
***
corresponds to the polyiamond
which is simply connected.
** **
*** **
****
corresponds to the non-polyiamond
which would not be simply connected even if it were a polyiamond.
Input Spec
- The input will consist only of asterisks, spaces, and line feeds.
- The first character of input will always be a space or asterisk (corresponding to the upward pointing triangle in the top left corner of the grid).
- There will always be at least one asterisk on the first and last lines.
- There is NO guarantee that lines after the first line won't be empty. Two linefeeds in a row may appear in a legitimate input.
- Line lengths need not all be the same.
Winning Condition
This is code-golf, so shortest answer in bytes wins.
Test Cases
Truthy maps:
1) *
2) *
*
3) **
4) *** ***
*******
5) * *
** **
***
6) *
**
*
7) **
***
****
8) ****
** *
*****
9) ***********
** ** **
**** ** **
**
************
Falsy maps:
1) *
*
*
2) * *
3) *
*
4) **
**
5) ***
***
6) ** **
*****
7) ** **
*** **
****
8) *
*
9) *****
** *
*****
AV VA\nVAVAV
instead of** **\n*****
as it makes it easier for a human to visualize. I already made an edit to one of Martin's ASCII diagrams. \$\endgroup\$