| Bytes | Lang | Time | Link |
|---|---|---|---|
| 011 | AWK | 250730T003122Z | xrs |
| 015 | sed n | 250729T214843Z | Jan Blum |
| 063 | C++ gcc | 250704T132914Z | jdt |
| 022 | Google Sheets | 250628T142755Z | doubleun |
| 085 | Bespoke | 250728T075528Z | Josiah W |
| 009 | GolfScript | 250728T061939Z | ErikDaPa |
| 011 | Pip | 250724T171210Z | DLosc |
| 100 | C64 Basic | 250724T170821Z | OSI8 |
| 044 | Scratch | 250629T150609Z | Rhaixer |
| 042 | Nim | 250724T080554Z | janAkali |
| 008 | APL+WIN | 250628T144851Z | Graham |
| 002 | Japt | 250630T120218Z | Shaggy |
| 017 | Alice | 250714T092509Z | Julian |
| 014 | Perl 5 | 250709T215129Z | Xcali |
| 2692 | Lenguage | 250714T051417Z | ATaco |
| 022 | Dart | 250708T083747Z | lrn |
| 086 | brainfuck | 250705T131849Z | matteo_c |
| 046 | Maple | 250630T203800Z | dharr |
| 027 | Bash | 250701T181446Z | wobtax |
| 043 | Tcl | 250629T165841Z | sergiol |
| 050 | PHP | 250701T152236Z | mbomb007 |
| 064 | C# | 250701T132435Z | Thomas W |
| 016 | Ruby n | 250630T211128Z | G B |
| 011 | 05AB1E legacy | 250701T050954Z | Lucenapo |
| 034 | Tcl | 250630T203810Z | sergiol |
| 037 | C gcc | 250630T014459Z | AShelly |
| 015 | X86 Assembly nasm | 250630T164727Z | AShelly |
| 026 | PowerShell Windows and Core | 250630T113659Z | user3141 |
| 004 | Vyxal | 250628T141235Z | lyxal |
| 037 | Ruby | 250630T092449Z | Ramzis |
| 022 | JavaScript Node.js | 250628T144026Z | l4m2 |
| 010 | Haskell + hgl | 250629T155729Z | Wheat Wi |
| 022 | JavaScript Node.js | 250629T123347Z | Steve Be |
| 008 | Vyxal 3 | 250629T014131Z | Themooni |
| 056 | ><> Fish | 250628T203146Z | mousetai |
| 020 | Zsh | 250628T142803Z | pxeger |
| 017 | Python | 250628T144801Z | Jonathan |
| 010 | TinyAPL beta 0.13.0 | 250628T145836Z | RubenVer |
| 004 | Jelly | 250628T142234Z | Jonathan |
| 001 | Retina 0.8.2 | 250628T143414Z | Neil |
| 006 | Uiua 0.17.0dev.1 | 250628T142421Z | Tbw |
| 031 | Python | 250628T140957Z | YurichBR |
sed -n, 15 bytes
/[]\[\\\/q1]/q1
Reads from standard input, exit code 1 if contained in the source, 0 otherwise.
C++ (gcc), 65 63 bytes
[](int*i){*i=0;for(int t:" \"*()01:;=[]forint{|}")*i|=t==i[1];}
Google Sheets, 24 22 bytes
=bul(A1,"=bul(A1,"")")
Put the character in cell A1 and the formula in B1. Gets the 1-indexed first occurrence of the character in the code, or an error value if it's not present.
Google Sheets supports international function names, and bul() is find() in Turkish. It is a valid function name in any locale, and will get automatically translated to the spreadsheet locale if it's not Turkish, and will continue to work after translation. To avoid translation, set File > Settings > Locale > Türkiye.
In an English locale, you can get the equivalent like this (24 bytes):
=find(A1,"=find(A1,"")")
A variation of =find(A1,formulatext(B1)) would work too, and there are shorter names for those functions in other languages, but that would violate self-referential rules.
Bespoke, 85 bytes
AAAAA@AA@AAAA@AA@AAAAAAAA@AAAAAAAAAA@AAA@AA@AAA@AA@AAAAAAAA@AAAAA@AAAAAAAA@A@AAAAAA@A
Equivalent to the following code (in "mnemonic" form):
INPUT CH
PUSH BI STACKTOP QUOTIENTOF
PUT XX:TRI BI;STACKTOP MINUS
STACKTOP F
OUTPUT N
Pip, 11 bytes
{}(); aNSTf
Outputs 0 for "does not contain" or a positive number for "does contain." Attempt This Online!
Explanation
{}(); aNSTf
f Main function
ST Stringify
aN Count occurrences of command-line argument in that string
{}(); The stringification adds these characters, so they need to be added
to the code as some no-ops
Questionable but interesting 10-byte solution
aQ_MRXWSTf
Outputs 0000000000 for "does not contain" or a string of nine 0s and one 1 for "does contain." Technically, if these were treated as strings in Pip, all-zeroes would be falsey and not-all-zeroes would be truthy. However, behind the scenes, they're actually lists, which would all be considered truthy, so I don't think this output method quite passes muster. It could be fixed by adding _MS at the beginning, but that's longer than my main solution.
Explanation
aQ_MRXWSTf
STf Stringify main function
MR Find every regex match of
XW Word character (letter/number/underscore)
MR and map this function to it:
aQ_ Is it equal to the command-line argument?
In other words, filter out all the extra characters added during stringification before checking if the program argument is in the result.
C64 Basic, 100 bytes
The output indicates the position of the searched character within the source code, otherwise it is 0.
Scratch, 44 bytes
Note: neither of these check for newlines because I have no idea how you would feed them one.
define(f
say<[yti\[doscn\]\\<afe(]contains(f
Full program version, 80 bytes
when gf clicked
ask()and wait
say<[an\[\]hfi\\\(wd\<rstloek\)ycg]contains(answer
APL+WIN, 12 8 bytes.
-4 bytes thanks to Adam
Prompts for input character. 1 if it exists in src code 0 if not.
⎕∊'∊⎕'''
Alice, 17 bytes
' wt.0g!].$KI(?O@
Takes the searched character as input. Prints to stdout the character if found or nothing otherwise.
' wt.0g!].$KI(?O@
' # Pushes 32, the ascii code of the space char
wt .$K # For each `i` between 32 to 0
.0g # Pushes the character at position (`i`, 0) in the source code as its ascii code
!] # Pops, writes it to the tape an shift the tape right
I( # Reads an argument from the input and search it on the tape
? # Read the tape at the current position and pushes the value
O@ # Print to stdout if found then exit
💎
Created with the help of Luminespire.
Alice, 28 bytes without source reading
'"''"w!]d$KI(?O@"w!]d$KI(?O@
Lenguage, 2692 bytes
This program consists of every byte from 0 - 255 repeated for 2692 bytes. As this is too long for an answer, a snippit of the code can be seen below:
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ................
00000010 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F ................
00000020 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F !"#$%&'()*+,-./
00000030 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 0123456789:;<=>?
00000040 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F @ABCDEFGHIJKLMNO
00000050 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F PQRSTUVWXYZ[\]^_
00000060 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F `abcdefghijklmno
00000070 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F pqrstuvwxyz{|}~
00000080 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F €‚ƒ„…†‡ˆ‰Š‹ŒŽ
00000090 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F ‘’“”•–—˜™š›œžŸ
000000A0 A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF ¡¢£¤¥¦§¨©ª«¬®¯
000000B0 B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF °±²³´µ¶·¸¹º»¼½¾¿
000000C0 C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
000000D0 D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF ÐÑÒÓÔÕÖרÙÚÛÜÝÞß
000000E0 E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF àáâãäåæçèéêëìíîï
000000F0 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF ðñòóôõö÷øùúûüýþ.
This program is equivilent to the BrainFuck code ,>+., which reads a byte, ignores it, and outputs 0x01 as every possible input byte is contained within this source code.
Dart, 22 bytes
Unnamed function returning true if passes a single-character string which occurs in its source, and false if the character doesn't occur in the source.
'contains.\'\\'.contains
Usage:
print('contains.\'\\'.contains('a')); // true
print('contains.\'\\'.contains('#')); // false
Annoying to have to escape the quote and then include the backslash too.
A same-length alternative is 'contains."'"'".contains, which then has to include " in the characters.
As a named reusable function, it could be:
var c='vr =contains.;\'\\'.contains;
bringing it to 34 bytes (adding two occurrences of vr =; and one extra c and a).
brainfuck, 86 bytes
>,>+++++[<------>-]<<<++++[->>------------<++++[->->+<[>-]>[->>+<]<<<]<]>>>>>.;=KLMN\^
Maple, 46 bytes
c->evalb(c in[";",seq(String(op(procname)))]);
op(procname) captures all the code except the final semicolon; hence the added ";" in the list.
Bash, 27 bytes
[[ "'"'" []=*$1' == *$1* ]]
Takes one character as an argument, e.g., thisscript.sh '{'. Return value is the output: 0 for true, 1 for false.
Tcl, 43 bytes
puts [regexp $argv [read [open [info sc]]]]
Program which takes an argument via command line.
PHP, 50 bytes
<?php fn($s)=>strpos('<?ph fn($s)=>tro\',;\\',$s);
The code is an anonymous function that takes the character as a string. The result is false if not contained, or an integer (the index of the first occurrence in the deduplicated code string) if contained.
C#, 64 bytes
I'd like to see some "normal" languages too.
C#, top level statements enabled. The character must be given as command line argument. The output is True or False.
Console.WriteLine("Consle.WritL(\"\\ag[0]);".Contains(args[0]));
Tcl, 34 bytes
proc C c {regexp $c [info body C]}
This only scans the part between the {}. Is my answer valid?
C (gcc), 45 37 bytes
Trying it a "normal" language:
s(s){return strstr("s(){retun ,&;}\\\"",&s);}
Edit:
Kevin Cruijssen found:
s(s){s=strstr("s({=tr\"\\,&);}",&s);}
X86 Assembly (nasm), 15 bytes
bf 00 00 00 00 66 b9 0f 00 f2 ae 0f 94 c0 c3
Function that scans its own bytecode for the byte in AL, returns 1/0 in AL.
decompiled:
find_matches:
mov edi, find_matches ; EDI = address of self
mov cx, 15 ; ECX = string length
repne scasb ; scan for AL
setz al ; return 1 or 0
ret
PowerShell (Windows and Core), 26 bytes
'''|% *ns$arg'|% *ns $args
Another 'normal' language, I guess.
A string with the characters used is passed to % (alias for ForEach-Object), which invokes the string's member "Contains()" (the only member matching *ns) for the argument.
Vyxal, 4 bytes
‛‛↔↔
Outputs an empty string for truthy, a non-empty string for falsey.
Or, if you want total nonsense:
Vyxal O, 0 bytes
Outputs nothing if the character isn't in the program.
JavaScript (Node.js), 22 bytes
f=x=>(f+f).includes(x)
-2B Steve Bennett
f= both appear in function, so no need extra
JavaScript (Node.js), 24 bytes, assuming ascii input
A=B=>B<":"?"#;@ !">B:B<A
Worse than former solution but fun to keep
Haskell + hgl, 10 bytes
fe"fe\"\\"
Explanation
fe checks if the second argument is an element of the first. "fe\"\\" is the string of all characters in the program.
An honorable mention to these 12 byte programs, which are longer but a bit more fun:
fe$sh"fe$sh"
e/$sh"e/$sh"
These one uses sh to enclose the string in quotes so that we don't have to use a backslash to escape the quote and then a backslash to escape the backslash.
Reflection
I've been saying for a long while that I should swap the names of e and fe, since fe is undoubtedly the more commonly used one. This would save 2 bytes on both versions of the answer.
Other than that I think this is as short as hgl is reasonably going to go on this particular task.
JavaScript (Node.js), 22 bytes
f=x=>(f+f).includes(x)
JavaScript (V8), 29 bytes
t=>/[=>/[\]\\.tes()]/.test(t)
Vyxal 3, 8 bytes
"q$c"q$c
"q$c"q$c
"q$c" # literal string
q # quoted
$c # contains implicit input?
💎
Created with the help of Luminespire.
<script type="vyxal3">
"q$c"q$c
</script>
<script>
args=[["\""],["$"],["c"],["a"],["%"],["P"]]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>
less fun:
Vyxal 3, 4 bytes
ᏜᏜ∩∩
outputs empty string for falsey and the character if truthy
ᏜᏜ∩∩
ᏜᏜ∩ # two character string "Ꮬ∩"
∩ # intersection of this string and implicit input
💎
Created with the help of Luminespire.
><> (Fish), 56 bytes
i:::::::"i"=}":"=}'"'=}"'"=}"}"=}"*"=}"n"=}";"=+++++++n;
For each character, save in the stack if they are equal. Then add all the qualities up and print them.
Contains the following characters:
i, :, ', ", =, }, +, n, ;
Zsh, 20 bytes
grep "[-grep \"Z-^]"
Input via stdin, outputs via exit code: 0 for yes, 1 for no.
Zsh, 0 bytes
I'm guessing you didn't intend to permit empty solutions (standard quine rules would forbid it), but this follows your rules. Input is ignored, output is via exit code (0 for no, 1 for yes).
Python, 17 bytes
'\.count\''.count
An unnamed function that accepts a character and returns 1 (truthy) if present in its source code or 0 (falsey) if not.
Try it online! (Python 3) Or Try in Python 2 Or Try in Python 1.
TinyAPL beta 0.13.0, 10 bytes
∊∘"∊∘⍘"⍘⍘"
is the character contained in the string ∊∘"⍘?
Jelly, 4 bytes
e⁾e⁾
A monadic Link that accepts a single character and yields 1 (truthy) if it is one of the two used in the source code and 0 (falsey) otherwise.
How?
e⁾e⁾ - Link: character, C
⁾e⁾ - two-character list -> "e⁾"
e - {C} exists in {that}?
If a full program were allowed, then 0 bytes - ignoring stdin TIO.
Retina 0.8.2, 1 byte
1
Try it online! Link includes... test cases? But there's not much to test really. The program counts the number of 1s in the input, so if the input is 1, the program outputs 1 accordingly, otherwise the input character is not in the program's code, and therefore the output is 0.
(Shamelessly stolen from my answer to Source Code Byte Frequency. As you can see, almost any single character would work.)
Uiua 0.17.0-dev.1, 6 bytes SBCS
∊$ $∊
A palindrome! Simply checks whether the character is a member of the string $∊.
Python: 31 bytes
d=lambda d:d in"\\ \":=abdilmn"


