Output the first position in your program for each input character

44

1

Challenge

Write a non-empty program/function p that, given a non-empty input string s, outputs the position of the first occurrence of each character of s in the source code of p.

For example, if your program is

main() { cout << magic << cin }
^0   ^5   ^10  ^15  ^20  ^25

and it receives an input abcd{, the output should be

[1, x, 9, x, 7] (0-based)        [2, x, 10, x, 8] (1-based)

Here, x represents any output that is not a valid output for a character position (e.g., a negative number, 0 if you use 1-based indexing, NaN, Inf, the string potato, a number greater than your program's length, etc).

Restrictions

Reading the source code is not allowed (like in a proper quine). The use of comments is allowed, but does count towards your score.

Input and output can be done in a reasonable format, but must be unambiguous (only additional delimiters, no rand stream and claiming that the answer is somewhere in there), consistent (e.g., the x from above should always be the same value) and human-readable; for example, a string or a character array. You can assume that the input is a string (or array) of printable ASCII characters; no need to handle the entire Unicode set.


Custom code-page or non-printable ascii in your code?

If your language uses a custom code-page (Jelly, APL, etc), you must take that into account (so a program €æÆ must output [1, x, 2] for an input €%æ). Using only non-ASCII characters to output -1 always (since the input is ASCII-only) is not a valid solution. You may assume that your program natively accepts your custom codepage, i.e., if your program has a method of converting a character A to an integer 65 (ASCII encoding), you may assume that it now converts the 65th character in your codepage to 65.


Inspired on the following challenge: Positional Awareness

Sanchises

Posted 2016-12-22T09:39:21.343

Reputation: 8 530

Does capitalisation matter? – user41805 – 2016-12-22T10:41:21.917

@KritixiLithos by default, yes.

– Martin Ender – 2016-12-22T10:41:55.040

@KritixiLithos It does indeed. – Sanchises – 2016-12-22T10:54:49.220

If my program only uses indices 0 to 9, do I need a separator or could I output, e.g., 01030708070? – Dennis – 2016-12-22T16:40:40.667

@Dennis No, you do not. It's unambiguous, consistent and human-readable. Requiring a separator would not add anything interesting to the challenge, so by all means abuse your low byte count. ;) – Sanchises – 2016-12-22T16:43:12.103

Why do I use 05AB1E for quine challenges? I know it's not meant for it... – Magic Octopus Urn – 2018-04-02T17:12:48.077

Answers

25

Python2, 55 Bytes

a=" )dfi(+m,nprut.';";print map(('a="'+a).find,input())

Starts with a string that contains all the characters used in the code, and then search the indexes

Rod

Posted 2016-12-22T09:39:21.343

Reputation: 17 588

5I don't see how this is the boring answer. I think using the standard quine is a lot less interesting than this. :) – Martin Ender – 2016-12-22T11:06:21.063

Since this is Python 2, wouldn't this break on most inputs?. If it does break, you'd have to use raw_input. – TidB – 2016-12-22T11:49:27.243

@TidB hmm, I guess no? what input do you have in mind? – Rod – 2016-12-22T11:56:17.433

@Rod Nevermind, I was just being a little dumb. It'll always work when you input an iterable. Silly me. – TidB – 2016-12-22T12:02:47.877

12

Lenguage, 56,623 bytes

Below is a hexdump of the first 256 bytes. The remaining bytes can be chosen arbitrarily.

0000000: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f  ................
0000010: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f  ................
0000020: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f   !"#$%&'()*+,-./
0000030: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f  0123456789:;<=>?
0000040: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f  @ABCDEFGHIJKLMNO
0000050: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f  PQRSTUVWXYZ[\]^_
0000060: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f  `abcdefghijklmno
0000070: 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f  pqrstuvwxyz{|}~.
0000080: 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f  ................
0000090: 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f  ................
00000a0: a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af  ................
00000b0: b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf  ................
00000c0: c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf  ................
00000d0: d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df  ................
00000e0: e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef  ................
00000f0: f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ff  ................

Output is in bytes, as customary for brainfuck et al.

How it works

This is a simple cat program, specifically ,[.,].

The source code contains all 256 byte values in order, so each byte's index in it matches its value.

Dennis

Posted 2016-12-22T09:39:21.343

Reputation: 196 637

4Hmmm I think Lenguage is the only language where people are outgolfed by three orders of magnitude... – Sanchises – 2016-12-23T09:03:56.417

2Lenguage is also the only language that constantly finds ways to cheat that wouldn't even be remotely competitive in other languages. :P – Dennis – 2016-12-23T19:02:13.070

Wouldn't +[,.] make for a much better score? – Sanchises – 2016-12-28T20:38:58.273

@Sanchises That would save roughly 12,000 bytes, but it would also print an extra null byte at the end. – Dennis – 2016-12-28T22:19:46.210

2Well, I suppose the null byte is in the input (even though it's function is to terminate the string), and would be at the 0th position in your program... ;) – Sanchises – 2016-12-29T08:07:08.137

11

Lenguage, 1.22e7 bytes

Consists of 12263215 NUL bytes, (Hex 0x00).

Outputs a NUL for every character that doesn't appear in the source.

The ruse is that the input will never contain a NUL, so we always output the amount of NULs that there are characters in the input.

This translates to the following Brainfuck program

,[[-].,]

And with a breakdown...

,[[-].,]
,[    ,]    #Basic Input loop.
  [-]       #Zero out the cell.
     .      #Print it (A NUL).

This just shows the sheer power of Lenguage as a golfing language. Fear it.

ATaco

Posted 2016-12-22T09:39:21.343

Reputation: 7 898

2Such a clever ruse, you almost won... Did you try the reverse too, I.e 0x00 bytes and 1-indexing? – Sanchises – 2016-12-22T22:49:59.663

I would have loved to, but Brainfuck/Lenguage (Or atleast, the interpreter I'm using) cannot differentiate between EOF and 0x00, So I would be unable to actually answer the challenge. – ATaco – 2016-12-22T22:58:32.730

Brainfuck et al. are usually allowed to print integers as bytes, i.e., you'd print SOH for 1, NUL for 0. – Dennis – 2016-12-22T23:02:28.943

@Sanchises Could you confirm that is the case here? – Dennis – 2016-12-22T23:16:56.743

It's not about output in this case, Input is the issue. – ATaco – 2016-12-22T23:18:14.437

But the challenge says the input will contain only printable ASCII characters. – Dennis – 2016-12-23T00:20:41.633

Then I can abuse this much more. Give me a moment to write a new script. – ATaco – 2016-12-23T00:47:44.780

Hmmm. I suppose I overlooked the fact that some esolangs can use non-printable ascii, as you've shown here - I thought that most languages that used the full 0-255 range would have a custom code page. Your entry then confirms to the letter of the rules, but is definitely against the spirit of the rules, specifically, "...in other words, using only non-ASCII characters to output -1 always (since the input is ASCII-only) is not a valid solution." – Sanchises – 2016-12-23T08:47:55.867

As for the output, languages are defined by their implementation. If there's an interpreter that renders 0x00 and 0x01 as distinct characters, it's human-readable and thus allowed. – Sanchises – 2016-12-23T08:53:13.953

Actually, it does not depend on an interpreter as to what encoding is outputted, only the bytestream that is outputted. It is up to whatever views that bytestream to determine what that encoding is. – ATaco – 2016-12-23T08:54:36.243

I updated the rules to rule out this answer, seeing as you showed that you could do without. I would include both the old version and this version marked as non-competing and causing the OP a headache. – Sanchises – 2016-12-23T08:58:54.493

Outputting raw bytes is fine though, I have decided after much contemplation – Sanchises – 2016-12-23T09:02:45.653

1Wouldn't ,[>.,] be shorter? – Jo King – 2018-02-20T02:58:32.780

8

Jelly, 10 9 bytes

“ṾiЀƓv”v

Try it online!

How it works

“ṾiЀƓv”v  Main link. No arguments.

“ṾiЀƓv”   Set the left argument and the return value to s := 'ṾiЀƓv'.
        v  Execute the string s as a monadic Jelly program with argument s.

 Ṿ         Uneval; yield a string representation of s, i.e., r := '“ṾiЀƓv”'.
     Ɠ     Read one line from STDIN and evaluate it like Python would.
  iЀ      Find the index of each character in the input in r.
      v    Eval the list of indices as a monadic Jelly program with argument s.
           Why?
             This is the shortest way to add the character 'v' to the string s,
             meaning that we can use r without having to append anything.
           What?
             The v atom vectorizes at depth 1 for its left argument, meaning that
             it acts on arrays of numbers and/or characters. When fed an array of
             integers, it first converts them to strings, then concatenates the
             strings and evaluates them as a Jelly program. For example, the array
             [1, 2, 3] gets cast to the string '123', then evaluates, yielding 123.
             Something slightly different happens if the array starts with a 0. For
             example, the array [0, 1, 2] gets cast to '012' just as before, but
             Jelly views '0' and '12' as two separate tokens; numeric literals
             cannot start with a 0. Since the Jelly program is monadic, the first
             token – '0' – sets the return value to 0. Since the second token –
             '12' – is also a niladic link, the previous return value is printed
             before changing the return value to 12. Then, the program finishes
             and the last return value is printed implicitly.

Dennis

Posted 2016-12-22T09:39:21.343

Reputation: 196 637

8

pbrain, 402 356 340 338 329 bytes

[(:<>)+,-.](>>>>>>)+([-]<<[->+>+<<]>>[-<<+>>]>>[-<+<+>>]<[->+<]<[-<->]<)+([-]+++++++[>+++++++++++++<-]>)+([-]+++++[>++++++++<-]>)+(-:<+++[->++++++<]>)+(-:++)+(-:++)+(----:+)+(-:++)+(-:+)+(-:+)+(-:+)+([-]++:++)+([>[->+>+<<]>>[-<<+>>]<:>>+:[[-]>+<]>-[<<<<[-.>]>>>>>>+>>>>>]<<[-]<<+<-]>>>)[-]>>>>>>>,[<<<<<<++<+++++++++++++:>>>>>>,]

Phew, @KritixiLithos and I have been working on this for 4 days now.

Prints 0x00 if input char isn't in program, index of the char (1-based) in hex otherwise. Try it online!

Explanation:

[(:<>)+,-.]
All chars listed here; like other submissions 
(>>>>>>)
@KritixiLithos added this part; I don't know what it does but saves the program
+([-]<<[->+>+<<]>>[-<<+>>]>>[-<+<+>>]<[->+<]<[-<->]<)
Comparison ;calculates z=x!=y and puts it in between x and y
Start; X _ _ _ Y
           ^
End;   X Z _ _ Y
         ^
+([-]+++++++[>+++++++++++++<-]>)
Function to add 91 to the tape
+([-]+++++[>++++++++<-]>)
Function to add 40 to the tape
+(-:<+++[->++++++<]>)
Function to add 58 to the tape
+(-:++)
Function to add 60 to the tape
+(-:++)
Function to add 62 to the tape
+(----:+)
Function to add 41 to the tape
+(-:++)
Function to add 43 to the tape
+(-:+)
Function to add 44 to the tape
+(-:+)
Function to add 45 to the tape
+(-:+)
Function to add 46 to the tape
+([-]++:++)
Function to add 93 to the tape
+([>[->+>+<<]>>[-<<+>>]<:>>+:[[-]>+<]>-[<‌​<<<[-.>]>>>>>>+>>>>>]<<[-]<<+<-]>>>)

This last function is the loop. It loops through the selected characters [(:<>)+,-.] in order and compares the input with the character. Now I'm going to give a deeper explanation on how this loop works.

12-n n+2 _ n+2: _ _ _ i _ _ _ _ _ _;  n=loop counter
                  ^                ;  i=input

The stack looks like that while in a loop. The loop will run until 12-n is 0. Then we have the counter which is n+2. This counter is also the number of the function for each of the selected characters. So when n=0, n+2 will be corresponding to the first character, ie [. >[->+>+<<]>>[-<<+>>]<: does just that, it converts the counter to the character.

Once the pointer is where the caret is, we will compare the character produced from the counter variable with the input while preserving them.

12-n n+2 _ n+2: Z _ _ i _ _ _ _ _ _;  n=loop counter
                ^                  ;  i=input

Z is 0 when the character is equal to the input, or some other non-zero integer otherwise.

Now we come up with an if-statement to check this equality.

[[-]>+<]

If Z is non-zero, ie the character and the input are not the same, we increment the next memory place.

After we come out of this if-statement, we decrement the next memory place. Now this memory place contains !Z. Finally using this, we output the index of the character if it matches with the input and then exit the loop forcibly. Else, we continue on with the loop until either it is over or a match is found.

[-]>>>>>>>
Clears first byte; goes to position to start program
,[<<<<<<++<+++++++++++++:>>>>>>,]
Loops inputs

betseg

Posted 2016-12-22T09:39:21.343

Reputation: 8 493

7

CJam, 14 12 bytes

{sq\f#p_~}_~

Uses 0-based indexing and -1 for characters that don't appear in the source.

Try it online!

Martin Ender

Posted 2016-12-22T09:39:21.343

Reputation: 184 808

6

Javascript, 34 bytes

f=a=>a.map(v=>('f='+f).indexOf(v))

It takes input as array of strings, x is -1 (0-based indexing).

LarsW

Posted 2016-12-22T09:39:21.343

Reputation: 239

It's allowed, since that method is also acceptable for quines. It doesn't open its source file and read it or use a variable initialized to the source. – mbomb007 – 2016-12-22T19:07:33.330

1@mbomb007 I can't speak for all JavaScript engines but in Firefox Function.toString works by reading the source. At one point it would crash in debug builds if the source was no longer there when it tried to read it. (I haven't tried it recently because debug builds are so crashy in general.) – Neil – 2016-12-22T19:40:37.683

I don't think it's any different than doing s='s=%s;print s%%s';print s%s in Python. It doesn't include the f=, so it's okay – mbomb007 – 2016-12-22T19:47:21.203

1You can not really do that, because the input a is supposed to be a string. There is no map function for strings. – manonthemat – 2016-12-22T20:12:46.083

@manonthemat "You can assume that the input is a string (or array)" – LarsW – 2016-12-22T20:17:51.977

This solution is allowed, because it indeed only toString()'s the function, not the entire source code; with the clever bit being that most of the code is a single function implementation. – Sanchises – 2016-12-22T21:02:26.810

5

Ruby, 41 88 86 71 69 67 61 56 bytes

a='p$<.chrs{| #index};"';$<.chars{|c|p"a='#{a}".index c}

Thx Lynn for killing 6 bytes

G B

Posted 2016-12-22T09:39:21.343

Reputation: 11 099

1a='p$<.chrsm{| #index};"';p$<.chars.map{|c|"a='#{a}".index c} should work too, taking input from STDIN. – Lynn – 2016-12-22T12:23:16.863

5

C, 153 152 143 bytes

char s[99],p[]="odeflnrti%()*+-0;<={}\\";c;f(char*i){sprintf(s,"char s[99],p[]=\"%s",p);for(c=0;c<strlen(i);)printf("%d ",strchr(s,i[c++])-s);}

Try it online!

betseg

Posted 2016-12-22T09:39:21.343

Reputation: 8 493

4

><> (Fish) 70 bytes

 #.0+4*a5;!?l|!?f4*b+l1--naolc3*1+0.01?!|~ed+0.0+2e-{:;!?+1:i-1:r}+2:"

Probably the longest ><> 1 liner I've ever made.

It will print the output for each character found on a separate line (0 indexed).

A non found character will always print the length of the code + 1 (I could change this if deemed not okay in it's current state) so in this case 71 will always be the "Not found" characters.

I'll run up an explanation once I get the time.

Some test cases;

##K = 1\n1\n71

#"# = 1\n69\n1

Try it online

><> language

Teal pelican

Posted 2016-12-22T09:39:21.343

Reputation: 1 338

I think 71 is fine as an output for not found. It's consistent, unambiguous and human-readable, which I think is more important than it being "...any output that is not a positive integer". I expanded the rules to reflect this decision. – Sanchises – 2016-12-22T16:31:47.720

3

Perl 6, 50 52 bytes

{(('R~.index$_) for}\\'R~'{((\'').index($_) for $_)}

Translation of G B's Ruby solution and Rod's Python solution.

A lambda that inputs a list of characters and outputs a list of zero-based indexes (Nil for nonexistent characters).

EDIT: Fixed an oversight - required adding 2 bytes :(

smls

Posted 2016-12-22T09:39:21.343

Reputation: 4 352

3

Clojure, 43 56 48 bytes

Edit: Damn I forgot about 2! Increased from 43 to 56.

Edit 2: Updated the sample code below this text, updated the number of bytes not to include (def f ...) but just the hash-map part.

{\{ 0\\   1\  3\0   4\1 10\3 14\4 20\2 34 \} 43}

The hash-map consists only of characters 01234{\\}, and it encodes their locations. In Clojure hash-maps can be used functions, as shown in this complete example (f could be replaced by the hash-map definition):

; Keeping track of the zero-based index:
;      00000000001111111111222222222233333333334444444444
;      01234567890123456789012345678901234567890123456789
(def f {\{ 0\\   1\  3\0   4\1 10\3 14\4 20\2 34 \} 43})

(map f "0123456789{} \\abcdef") ; (4 10 34 14 20 nil nil nil nil nil 0 43 3 1 nil nil nil nil nil nil)
(apply str (keys f))            ; " 01234{\\}"

I guess this counts :)

NikoNyrh

Posted 2016-12-22T09:39:21.343

Reputation: 2 361

2

JavaScript, 39 bytes

p=s=>[...s].map(c=>`p=${p}`.indexOf(c))

console.log( p('mapP') )

Washington Guedes

Posted 2016-12-22T09:39:21.343

Reputation: 549

1can you explain [...s] please? – Erresen – 2016-12-22T11:55:37.830

It is known as spread operator, you can see a bit more in the ES6 golfing tips.

– Washington Guedes – 2016-12-22T11:58:29.957

2Reading the source code is not allowed – Arnauld – 2016-12-22T12:27:18.453

2

Pyth, 11 bytes

xL_+N"N+_Lx

A program that takes input of a "quoted string", with any quotes in the string escaped with a preceding \, and prints a list of zero-indexed values with -1 for characters not in the source.

Try it online!

How it works

xL_+N"N+_Lx    Program. Input: Q
xL_+N"N+_Lx"Q  Implicit quote closure and implicit input
     "N+_Lx"   Yield the string "N+_Lx"
   +N          Prepend a quote
  _            Reverse
 L          Q  Map over Q:
x               Yield the index of the character in the string
               Implicitly print

TheBikingViking

Posted 2016-12-22T09:39:21.343

Reputation: 3 674

2

SmileBASIC, 128 96 88 86 bytes

?R<3+CD,4LINPUT(S$)WHILE""<S$?INSTR("?R<3+CD,4LINPUT(S$)WHILE"+CHR$(34),SHIFT(S$))WEND

An important thing to realize is that this is not really a quine challenge. You only need the source code up to the last unique character.

I put at least 1 of each character at the beginning of the code: ?R<3+CD,4LINPUT(S$)WHILE" so I only have to store a copy of the program up to the first quotation mark.

12Me21

Posted 2016-12-22T09:39:21.343

Reputation: 6 110

2

05AB1E, 19 bytes

"'ìsvDyk,"'"ìsvDyk,

Try it online!

This outputs -1 in place of missing chars.


Luis Mendo posted this (slightly modified) on Golf you a quine for great good! , adding "s" and "k" to that quine results in this answer as well. However, I can't take credit for that trivial of a modification... Luis, you can message me if you'd like to repost this and I'll just delete it. If you want to see my progress before finding that question, view edits. Well... It was significantly like his at one point.

Magic Octopus Urn

Posted 2016-12-22T09:39:21.343

Reputation: 19 422

@Sanchises works for me! – Magic Octopus Urn – 2018-04-02T18:35:34.673

Cool cool cool! – Sanchises – 2018-04-02T18:54:23.070

@MagicOctopusUrn Well done!! – Luis Mendo – 2018-04-03T06:36:57.777

1

Python, 90 88 bytes

a,b,d=" ()+.7:[]efilmnor","a,b,d=\"",lambda e:[[b.find(d),a.find(d)+7][d in a]for d in e]

Test case:

print(d("a,b(]q"))
#[0, 1, 2, 8, 15, -1]

TidB

Posted 2016-12-22T09:39:21.343

Reputation: 561

1

Stacked, noncompeting, 36 bytes

When I said this language was still in development, I meant it. Apparently, prompt used to consume the entire stack. This is why I can't have nice things. Try it here!

[tostr ':!' + prompt CS index out]:!

This is the standard quine framework. Basically, : duplicates the function [...] on the stack, which is then executed with !. Then, the inside of [...] executes with the function on the stack. It casts it to a string, appends :! (the program itself), then takes a string input with prompt. CS converts it to a character string. A character string is a bit different from a regular string in that it has operators vectorize over it. In this case, index vectorizes over the input, yielding each index of the input string in the program, finally being outputted.

For input Hello, World!, this gives:

(-1 27 -1 -1 2 -1 6 -1 2 5 -1 26 9)

I tried using the one without a quine (i.e. encoding the string of characters that appear in your source), but there is only one type of quotation mark in Stacked, namely, ', so it would be longer to do that type of solution.

Conor O'Brien

Posted 2016-12-22T09:39:21.343

Reputation: 36 228

1

Java 8, 172 122 bytes

a->{/*.indexOf(c)+\" ;}orh:Systmup*/for(char c:a)System.out.print("a->{/*.indexOf(c)+\\\" ;}orh:Systmup".indexOf(c)+" ");}

0-indexed, and gives -1 for characters that aren't part of the source code.

Explanation:

Try it online.

a->{                         // Method with character-array parameter and no return-type
  /*.indexOf(c)+\" ;}orh:Systmup*/
                             //  Comment containing the remaining characters of the code
  for(char c:a)              //  Loop over the input-array
    System.out.print(        //   Print:
      "a->{/*.indexOf(c)+\\\" ;}orh:Systmup"
                             //    String containing all the characters used in the code
      .indexOf(c)+" ");}     //    Print the index of the char, plus a space as delimiter

Kevin Cruijssen

Posted 2016-12-22T09:39:21.343

Reputation: 67 575

1

Husk, 12 bytes

m€`:'""m€`:'

Try it online!

Explanation

The explanation is using ¨ to delimit strings and ' to delimit characters:

m€`:'""m€`:'  -- implicit input, for example: ¨m"a1`¨
      "m€`:'  -- string literal: ¨m€`:'¨
  `:'"        -- append character '"': ¨m€`:'"¨
m             -- map function over each character (example with 'a'):
 €            -- | index of first occurrence (1-indexed): 0
              -- : [1,6,0,0,3]

ბიმო

Posted 2016-12-22T09:39:21.343

Reputation: 15 345

1

J, 31 22 bytes

11|1+i.~&'11|1+i.~&'''

Try it online!

1-indexed, 0 for characters that aren’t present in the code. '' stands for a single quote. Find each character in the string 11|1+i.~&', add 1, modulo 11.

FrownyFrog

Posted 2016-12-22T09:39:21.343

Reputation: 3 112

1

Perl 5 with -pl, 43 bytes

Uses newline separated input and prints -1 for characters not appearing in the program.

$s=q{$_=index"\$s=q{$s};eval\$s",$_};eval$s

Try it online!

Dom Hastings

Posted 2016-12-22T09:39:21.343

Reputation: 16 415

@Sanchises Fixed now, sorry about that. Clearly didn't read properly! – Dom Hastings – 2018-02-20T08:33:09.250

No problem. Thanks for bringing some new life into this challenge! – Sanchises – 2018-02-20T10:19:10.587

1

><>, 31 bytes

'rd3*i:0(?;}{:}-&b0&?.75*l-nao]

Try it online!

Output is 1-indexed, with 32 meaning the character is not in the code.

Jo King

Posted 2016-12-22T09:39:21.343

Reputation: 38 234

1

Stax, 19 bytes

"'sym[]I+"'"s+ym[]I

Run and debug it

Outputs 0-based index, one character per line. Turns out it's shorter than modifying the "34bL"34bL quine I wrote earlier.

Weijun Zhou

Posted 2016-12-22T09:39:21.343

Reputation: 3 396

0

Python 2, 49 48 bytes

-1 byte thanks to Jo King

c='print map(("c=%r;ex"%c).find,input())';exec c

Try it online!


Python 3, 53 52 51 bytes

-1 byte thanks to Jo King

c='print(*map(("c=%r;ex"%c).find,input()))';exec(c)

Try it online!

Mukundan

Posted 2016-12-22T09:39:21.343

Reputation: 1 188

0

Burlesque, 27 bytes

#Qup~-"#Q"j?+wd\[Ppm{pPjFi}

Try it online!

Returns list of indices with -1 for each not present.

#Q      #Push remaining code to stack
up      #Turn to string
~-      #Remove brackets
"#Q"j?+ #Add the "#Q" to the beginning
wd\[    #Remove all spaces
Pp      #Push to virtual stack
m{      #Map (apply to each char in input)
  pP    #Pop from other stack
  jFi}  #Find character in string

DeathIncarnate

Posted 2016-12-22T09:39:21.343

Reputation: 916