zigzagRightDownUp method
Color with an zig-zag pattern with direction right down up from a starting position
Requires a list of colors
and a number n
of cells to color.
If no number n
of cells is passed all the cells
that fits in the patter are colored.
Return true on success.
Implementation
bool zigzagRightDownUp(List<int> colors, [int? n]) {
int? param = n;
final int column = move.column;
final int row = move.row;
param ??= 6 - column;
if (row != 2) {
return false;
}
if (colors.isEmpty) {
return false;
}
final List<int> newColors = buildOffset(colors, param);
if (param.isOdd && n == null) {
move.toPosition(3, 0);
return zigzagRightUpDown(newColors, 6);
}
if (n == null) {
move.toPosition(2, 0);
return zigzagRightDownUp(newColors, 6);
}
if (param < 3) {
return false;
}
return _zigzagHelper(
param,
colors,
move.diagonalDownRight,
move.diagonalUpRight,
);
}