zigzagDownLeftRight method
Color with an zig-zag pattern with direction down left right 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 zigzagDownLeftRight(List<int> colors, [int? n]) {
int? param = n;
final int column = move.column;
final int row = move.row;
param ??= 6 - row;
if (column != 3) {
return false;
}
if (colors.isEmpty) {
return false;
}
final int i = param % colors.length;
final List<int> newColors = colors.sublist(i)..addAll(colors.sublist(0, i));
if (param.isOdd && n == null) {
move.toPosition(0, 2);
return zigzagDownRightLeft(newColors, 6);
}
if (n == null) {
move.toPosition(0, 3);
return zigzagDownLeftRight(newColors, 6);
}
if (param < 3) {
return false;
}
return _zigzagHelper(
param,
colors,
move.diagonalDownLeft,
move.diagonalDownRight,
);
}