Title misspelled on purpose. Read more to find out why.
Your task: given a delimited string or list including the characters A,B,C,D
, output the indexes of all the adjacent equal characters. Output can be multiple strings/integers on multiple lines, a list/array, or a delimited string.
All output should be in a list or string, or multiple printed lines. Each printed line, if there are multiple, should only contain 1 string or number. Trailing whatevers are okay.
Standard methods of input/output. Standard loopholes apply.
For example, the input 'ABCDDCBA'
should output 3,4
or 4,5
, depending on whether it is 0- to 1- indexed, because those numbers are the indexes of D
and the D
next to it.
Test cases:
Test cases have input given as a single string, and output as a ,
-delimited string. Outputs are 0-indexed, add 1 to every outputted item to get it to be 1-indexed.
Input: 'ABCDCABCD'
Output: ''
Input: 'AABBCCDD'
Output: '0,1,2,3,4,5,6,7'
Input: 'ABCDDDCBA'
Output: '3,4,5'
Input: 'ABBCDD'
Output: '1,2,4,5'
This is code-golf, so shortest code wins!
3,4,4,5
valid as well? \$\endgroup\$ – Luke Apr 11 '17 at 18:18AABBCD
->
1,2,3,4
\$\endgroup\$ – Riley Apr 11 '17 at 18:25