12
Given a string, return a table where the first column has the unique letters of the string in order of occurrence and subsequent columns list the indices of that letter in the string, using zero or one-based indexing. Horizontal whitespace does not matter, as long as the left-most column is vertically aligned. Indices must be in ascending order from left to right.
Examples
Using zero-based indexing and given "abracadabra", return
a 0 3 5 7 10
b 1 8
r 2 9
c 4
d 6
Using one-based indexing and given "3141592653589793238462643383279503", return:
3 1 10 16 18 25 26 28 34
1 2 4
4 3 20 24
5 5 9 11 32
9 6 13 15 31
2 7 17 22 29
6 8 21 23
8 12 19 27
7 14 30
0 33
Can I have leading spaces in the output? – Erik the Outgolfer – 2017-06-20T13:20:50.337
Must the output format be strict? – Leaky Nun – 2017-06-20T13:21:38.930
@EriktheOutgolfer Yes. Added. – Adám – 2017-06-20T13:22:17.067
@LeakyNun No. Added. – Adám – 2017-06-20T13:22:22.740
Can the rows be unordered? – Erik the Outgolfer – 2017-06-20T13:25:06.600
@Adám I meant if instead of
abrcd
I outputabcdr
for example, with the indices still corresponding to the correct letters. – Erik the Outgolfer – 2017-06-20T13:26:54.147@EriktheOutgolfer OP: in order of occurrence – Adám – 2017-06-20T13:27:17.667
2Does this need to work for characters that aren't printable ascii? Are there any characters we can assume won't be in the string (particularly whitespace)? – FryAmTheEggman – 2017-06-20T16:18:53.233