QBIC , 95 바이트
dim X(126)[_l;||i=asc(_sA,a,1|)┘X(i)=X(i)+@ `+!a$][_lA||_SA,b,1|i=asc(C)~X(i)<>D|?C,X(i)┘X(i)=@
설명
이것은 이 도전에 대한 내 대답 의 상당 부분을 복사합니다 .
dim x(126) Create an array of 126 elements (one for each ASCII element)
[_l;|| Read cmd line input, loop over its length
i=asc(_sA,a,1|) Read the next char's ascii value
┘ (Syntactic linebreak)
X(i)= Set the value for this ascii-codepoint to
X(i) everything we've put in before
+@ ` and a literal space
+!a$ and the current (1-based) index cast as string
] close the FOR loop
[_lA|| Loop over the original string again (to preserve order of appearance)
_SA,b,1| Read 1 char, assign to C$ (note the capital S in the function call,
this auto-creates C$ abd assigns it the value of the substring-call)
i=asc(C) Get the index in our storage array from C$'s ascii value
~X(i)<>D IF the storage array holds data for i (<> D$, which we'll set to "" in a second),
|?C,X(i) THEN PRINT the character, followed by the indices saved for this char
┘ (Syntactic linebreak)
X(i)=@ Clear out the data stored for C$
@ declares a string lit, ` would close it and that gets auto-added at EOF,
creating the literal @`, which gets assigned to D$
샘플 실행 :
Command line: abracadabra
a 1 4 6 8 11
b 2 9
r 3 10
c 5
d 7