You are given a 1D board of length N. Each cell is in one of three states:
-
Empty
-
Piece
(a movable token)
-
Coin
(collectible)
In one move, you may choose any one piece and move it exactly 3 cells to the right (from index i to i+3). The move rules are:
-
If the destination cell is
empty
, the piece moves there.
-
If the destination cell contains a
coin
, the piece moves there and you
collect
that coin (the coin is removed).
-
Pieces
cannot overlap
: a move is
not allowed
if the destination cell already contains another piece.
-
The piece may “jump over” intervening cells; only the destination cell matters.
-
A move is not allowed if
i+3
is outside the board.
You may perform moves in any order, for as many turns as you like, until no piece can legally move.
Return the maximum number of coins you can collect.
Input
-
A representation of the board (e.g., a string/array of length
N
) containing exactly one of
{empty, piece, coin}
per cell.
Output
-
An integer: the maximum number of coins collectible.
Notes / Clarifications
-
Multiple pieces may exist.
-
Coins are collected at most once (they disappear after collection).
-
The result depends on the order in which you choose moves.