zigzagLeftUpDown method
Color with an zig-zag pattern with direction left up down 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 zigzagLeftUpDown(List<int> colors, [int? n]) {
int? param = n;
final int column = move.column;
final int row = move.row;
param ??= column + 1;
if (row != 3) {
return false;
}
if (colors.isEmpty) {
return false;
}
final List<int> newColors = buildOffset(colors, param);
if (param.isOdd && n == null) {
move.toPosition(2, 5);
return zigzagLeftDownUp(newColors, 6);
}
if (n == null) {
move.toPosition(3, 5);
return zigzagLeftUpDown(newColors, 6);
}
if (param < 3) {
return false;
}
return _zigzagHelper(
param,
colors,
move.diagonalUpLeft,
move.diagonalDownLeft,
);
}