This question evaluates combinatorial optimization, state-space reasoning, and algorithmic design for constrained token movements on a linear board, and falls under the Coding & Algorithms domain.
You are given a one-dimensional board with n positions represented by a string s of length n:
.
= empty cell
T
= token
C
= coin
You may move tokens any number of times under these rules:
i
to
i+3
).
i+3
is outside the board.
T
).
C
), that coin is collected (removed) and cannot be collected again.
Your task is to compute the maximum number of coins that can be collected by choosing an optimal sequence of moves.
Input: s (string of length n, consisting only of ., T, C)
Output: An integer = maximum coins collectible.
Notes / clarifications: