Given an input of a string consisting entirely of q
s representing quarter
notes and e
s representing eighth notes, output the indices of the quarter
notes that are syncopated.
Syncopation is complex, but for the purposes of this challenge, our definition of "syncopated" will be very simple: a quarter note that starts on the "off-beat"—that is, the beats counted as "and" in n/4 time.
This may alternatively be defined as any quarter note that is preceded by an
odd number of eighth notes. For example, the notes marked with *
below are considered syncopated, and their indices are also shown:
eqqeqqeqqe
** **
12 78
Output: 1 2 7 8
The input will always consist of a whole number of measures in 4/4 time (a quarter note is a quarter of a measure, and an eighth note is an eighth of a measure). (The input will also never be empty.) Output can either be a single string with elements separated by any delimiter that does not contain numbers or an array/list/etc. The output may be 1-based (i.e. the first index is 1 instead of 0) if you wish, and it may also be in any numeric base (unary, decimal, etc.).
Since this is code-golf, the shortest code in bytes wins.
Test cases:
In Out
-----------------------------------------------
eqqqe 1 2 3
qeqeq 2
qqqeqqeeeeqeqeqeqqeqqeqq 4 5 10 14 19 20
eeeeeqeeqeeqqqqeqeqeeqe 5 8 11 12 13 14 18 21
qqqq <none>
eeeeeeee <none>
'eqqqe'
instead ofeqqqe
\$\endgroup\$