| Bytes | Lang | Time | Link |
|---|---|---|---|
| 050 | Swift 6 | 250630T151016Z | macOSist |
| 004 | Vyxal 3 | 250629T133350Z | Themooni |
| 013 | Japt v2.0a0 | 170922T162728Z | Shaggy |
| 150 | brainfuck | 230114T035054Z | l4m2 |
| 033 | Python 3 | 211104T122211Z | Jakque |
| 010 | Burlesque | 200119T150712Z | DeathInc |
| 012 | W | 191218T111521Z | user8505 |
| 007 | Husk | 190323T061217Z | Unrelate |
| 038 | Perl 6 | 190301T050753Z | Jo King |
| 018 | Brachylog newer | 190301T023424Z | Unrelate |
| 018 | J | 170923T101644Z | FrownyFr |
| nan | JavaScript Chrome 58 on OS X 10 | 170922T161536Z | Tornado5 |
| 091 | Lua | 170922T231547Z | Jonathan |
| 058 | Java OpenJDK 8 | 170922T142330Z | Nevay |
| 029 | Bash | 160810T195321Z | Riley |
| 131 | Java 8 | 170922T080641Z | Kevin Cr |
| 061 | Vim | 160817T031227Z | Destruct |
| 036 | C# | 160813T020750Z | milk |
| 044 | Python 3 | 160810T190633Z | Jeremy |
| 061 | PHP | 161221T172101Z | Titus |
| 032 | MATLAB | 161221T153056Z | Sanchise |
| 038 | q | 160810T200816Z | skeevey |
| 008 | Pyth | 160815T221213Z | Steven H |
| 064 | SQF | 160812T051918Z | Οurous |
| 055 | Perl 6 | 160810T190745Z | Brad Gil |
| 035 | Mathematica | 160813T233644Z | LegionMa |
| 006 | Actually | 160811T181903Z | user4594 |
| 020 | Retina | 160811T155628Z | mbomb007 |
| 140 | Java 8 lambda | 160811T105255Z | Frozn |
| 047 | sed | 160811T231901Z | Geoff Re |
| 037 | Matlab | 160812T095539Z | Stewie G |
| 222 | ListSharp | 160811T215135Z | downrep_ |
| 057 | JavaScript ES6 | 160810T202814Z | Neil |
| 008 | Dyalog APL | 160810T184214Z | Adá |
| 023 | Brachylog | 160811T091210Z | Fatalize |
| 008 | Pyth | 160810T185708Z | Leaky Nu |
| 044 | Python 2 | 160811T013631Z | Sp3000 |
| 006 | Jelly | 160810T190100Z | Dennis |
| 030 | Haskell | 160810T232829Z | MarLinn |
| 3435 | Ruby | 160810T204007Z | Value In |
| 008 | CJam | 160810T201954Z | xenia |
| 039 | Python 2 | 160810T191735Z | KarlKast |
| 129 | R | 160810T201010Z | user5957 |
| 048 | Python | 160810T193134Z | Iguanodo |
| 142 | C | 160810T193749Z | owacoder |
| 104 | PowerShell v4+ | 160810T193347Z | AdmBorkB |
| 008 | MATL | 160810T183818Z | Luis Men |
| 006 | GolfScript | 160810T192309Z | Dennis |
| 011 | 05AB1E | 160810T183856Z | Adnan |
Vyxal 3, 4 bytes
ᏜᏜ∩∩
ᏜᏜ∩∩
ᏜᏜ∩ # two character string "Ꮬ∩"
∩ # intersection of this string and implicit input
💎
Created with the help of Luminespire.
<script type="vyxal3">
ᏜᏜ∩∩
</script>
<script>
args=[["∩"],["a"],["Ꮬ∩"]]
</script>
<script src="https://themoonisacheese.github.io/snippeterpreter/snippet.js" type="module"/>
Japt v2.0a0, 15 13 bytes
My very first "proper" quine. At long fecking last!
oQ+"oQ+ â"Q â
oQ+"..."Q â :Implicit input of string
o :Keep only those characters that appear in
Q : Quotation mark
+"..." : Append literal string
Q : Passed as a second argument to the o method to disable the case insensitive flag (any truthy value would work)
â :Deduplicate
brainfuck, 150 bytes
,[[>+>+<<-]>>[-[->>+<<]+>>]+>+[--<[-<<]>.>+>[-]]-<[-<<]>[-]<,] !"#$%&'()*/0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_`abcdefghijklmnopqrstuvwxyz{|}~
Support 32-126
main code(set remove dup) 62
Burlesque, 10 bytes
#QupIN#Qvv
Turns out the lazy way worse than doing it generally because I can't get a quote within a quote nicely. "IN_+"'"_+IN
#Q #Push the code onto the stack
up #Convert to string
IN #Intersection
#Q #Make sure a #Q is captured
vv #Drop the resulting push
W, 12 bytes
34C+t"34C+tt
Explanation
34C+t" % Everyone in the execution sequence excluding a quote
34C+ % Add a (") quote
t % Trim out everything in this string in input
t % Trim the string so that the intersection is kept
Husk, 7 bytes
n"n\\\"
n The intersection of
"n\\\" the string n, \, "
with the input.
I tried to work around having to escape the quote with a backslash, but that just made it longer:
Husk, 8 bytes
n:'""n:'
n The intersection of
'" the character "
: prepended to
"n:' the string n, :, '
with the input.
Another attempt to eliminate backslashes, which would be two bytes shorter if it didn't need to remove duplicates:
Husk, 7 bytes
uns"nsu
u Without duplicate elements,
n the intersection of
s the string representation of
"nsu the string n, s, u
with the input.
Perl 6, 38 bytes
<say .comb∩$*IN.comb#<>~EVAL>~~.EVAL
The generalised quine still manages to beat out the trivial program by a few bytes
Perl 6, 41 bytes
say <$*. <>INabcmosy∩>.comb∩$*IN.comb
Brachylog (newer), 18 bytes
{∈"{∈\\\"&}ˢd"&}ˢd
It's this plus the de-duplication predicate. Doesn't necessarily beat Fatalize's solution since his is in an older and very different version of the language.
J, 18 bytes
'''&()[-.'&([-.-.)
How it works
''&()[-. the character set, '' stands for '
& is the left operand
([ ) the set> itself, ignore <the input
( -.) the set> except any characters in <the input
(the wrong ones remain)
( -. ) the set itself> except <the wrong characters
JavaScript (Chrome 58 on OS X 10), 12654 12426 11992 Bytes
https://paste.ubuntu.com/25593218/
https://paste.ubuntu.com/25595798/
https://paste.ubuntu.com/25595831/
The original code:
var t=prompt();"!+()[]".split("").forEach(function(f){if(t.includes(f))alert(f)})
This was then converted into a programming style called jsfk which only uses these six characters:
(+)[!]
using an online compiler.
Lua, 91 bytes
Old challenge, but still lacking a Lua solution, so...
s=...(" s=.(\\\"):gub,fnctiod1awre"):gsub(".",function(c)c=s:find(c,1,1)and io.write(c)end)
Java (OpenJDK 8), 58 bytes
s->s.filter("s->.filter(\"\\:cona)d"::contains).distinct()
Accepts the input as Stream<String>, whereas each character of the input is a stream element, and returns a filtered, distinct stream.
Bash, 45 50 41 39 37 34 29 bytes
-9 bytes thanks to Geoff Reedy
-4 bytes thanks to Dennis
-5 bytes thanks to Nahuel Fouilleul
grep -o '[] [|\'\'grepouniq-]
Java 8, 131 129 131 bytes
a->{java.util.Set r=new java.util.HashSet();for(String s:a)if("a->{jv.utilSe r=nwHsh();fog:\"\\cd}".contains(s))r.add(s);return r;}
+2 bytes again due to a bug-fix
Explanation:
a->{ // Method with String-array parameter and Set return-type
java.util.Set r=new java.util.HashSet();
// The result Set
for(String s:a) // Loop over the input String-array
if("a->{jv.utilSe r=nwHsh();fog:\"\\cd}".contains(s))
// If the current character is part of the source-code:
r.add(s); // Add it to the Set
// End of loop (implicit / single-line body)
return r; // Return the result-Set
} // End of method
Vim, 78 68 78 79 61 keystrokes
Completely changed my approach:
oo/\$kjxd<esc>/o<cr>xj$/\/<cr>xj$/\\<cr>xj$/$<cr>xj$/k<cr>xj$/x<cr>xj$/j<cr>xj$/d<cr>xkdd
How it works:
First, it makes a line with all the program characters, then, it finds the first instance of each of the program characters, which is either in the input, if the input and output intersect, or the output if they don't, deletes it, moves to the last character of the file (so it wraps around) and does that for each unique character in source, except d, where instead of moving to the end of the file, it finishes up by deleting the input
C#, 36 bytes
s=>s.Intersect("s=>.Interc(\"\\);");
Intended cast is Func<string, IEnumerable<char>> (string input, IEnumerable<char> output).
Python 3, 44 bytes
Thanks Karl for saving me one byte :-) Thanks Dada for saving me two bytes!
I think this works, but it's my first quine challenge so I'm not 100% sure. :\
print(set("printseu()&'"+'+"')&set(input()))
Lambda version with 43 bytes:
lambda a:set(" lambdaset()&'"+':+"')&set(a)
PHP, 61 bytes
<?=preg_filter("_<\?=[aefiglprtv$(\_[\],)\\;1\"]_",$argv[1]);
takes input from first command line argument.
no regex, 74 bytes
for(;""<$c=$argv[1][$i++];)if(strstr("aceghiosrtv()$<=[1]\;\"",$c))echo$c;
takes input from first command line argument. Run with -nr.
Note: ; needs no escaping; so PHP takes the backslash before the semicolon literally.
MATLAB, 32 bytes
@(t)intersect(t,'@(t)inersc,''')
Essentially the same as Stewie Griffin's approach (the intersect built-in is hard to avoid), but this edition saves an entire 5 bytes over his by taking the input as an anonymous function, with the variable name t chosen to occur within intersect (any other character in that string would have done as well). Call as ans('yourInput').
q (38 bytes)
Reads from stdin
"readint0\\\" "inter read0 0
edit: was missing backslash
Pyth, 6 8 Bytes
{@"{@\"\
Expects input as a string.
Explanation:
@ Q Intersect implied input with:
"{@\"\ The string containing {@"\
{ and then remove duplicates.
SQF, 71 69 64 bytes
Using the file-as-a-function format:
i="-_h ;""=()sSplitrng"splitString"";i-(i-(_this splitString""))
Call as "STRING" call NAME_OF_COMPILED_FUNCTION
Perl 6, 56, 55 bytes
"French" / Unicode version (55 bytes)
say perl q.say perlq∩$*IN\\\.comb:..comb∩$*IN.comb:
"Texas" / ASCII versions (56 bytes)
say (q.sayq(&) $*IN\\\.combperl..comb (&)$*IN.comb).perl
say perl q.sayq(&) $*IN\\\.comb:perl..comb (&)$*IN.comb:
Non-golfed:
my \Source = 'my \\Source = \'say ( $*IN.comb.Set ∩ Source.comb.Set ).perl\'';
say ( $*IN.comb.Set ∩ Source.comb.Set ).perl
Examples:
$ echo -n 'say perl q.say perlq∩$*IN\\\.comb:..comb∩$*IN.comb:' > test-unicode.p6
$ echo -n 'say (q.sayq(&) $*IN\\\.combperl..comb (&)$*IN.comb).perl' > test-ascii.p6
$ perl6 test-ascii.p6 <<< 'abcdefghijklmnopqrstuvwxyz'
set("p","a","l","r","c","q","b","s","e","m","y","o")
$ perl6 test-unicode.p6 < test-unicode.p6
set("\\","I","p"," ","a","c","l","r","q","b","∩","*","s","m","e",".","y",":","o","N","\$")
$ perl6 test-ascii.p6 < test-ascii.p6
set("p","\\","I"," ","a","l","r","c","q","b",")","*","s","e","m","\&",".","(","y","o","N","\$")
$ perl6 test-ascii.p6 < test-unicode.p6
set("p","\\","I"," ","a","l","r","c","q","b","*","s","e","m",".","y","o","N","\$")
$ perl6 test-unicode.p6 <<< 'Albert Einstein'
set(" ","l","r","b","s","e")
$ perl6 test-unicode.p6 <<< '\__( O__O)_/'
set("\\"," ")
$ perl6 test-ascii.p6 <<< '!@#$%^&*()_+{}|:"<>?'
set(")","*","\&","(","\$")
$ perl6 test-unicode.p6 <<< "1234567890-=[]\\;',./"
set("\\",".")
$ perl6 test-unicode.p6 <<< '(ノಠ益ಠ)ノ彡┻━┻'
set()
“¤>%,oỊȤʠ“ØụĊ5D³ṃṠɼQ»j;Ç;“;}¶”
set("o")
$ perl6 test-unicode.p6 <<< '┬──┬ ノ( ゜-゜ノ)'
set(" ")
$ perl6 test-ascii.p6 <<< 'Far out in the uncharted backwaters of the unfashionable end of the Western Spiral arm of the Galaxy lies a small unregarded yellow sun. Orbiting this at a distance of roughly ninety-eight million miles is an utterly insignificant little blue-green planet whose ape-descended life forms are so amazingly primitive that they still think digital watches are a pretty neat idea.'
set("p"," ","a","l","r","c","b","s","e","m",".","y","o")
Mathematica, 35 bytes
Characters@"\"#&@C\acehrst⋂"⋂#&
Anonymous function. Ignore any generated messages. Takes a list of characters as input and returns a list of characters as output. The Unicode character is U+22C2 for \[Intersection].
Actually, 6 bytes
`∩è`è∩
Explanation:
`∩è`è∩
`∩è` push the function `∩è` (which contains every character in the source code except '`')
è repr (same as Python repr - leaves "`∩è`", which contains every character in the source code)
∩ set intersection with input
Retina, 21 20 bytes
Removes characters not in the source code, then removes duplicate characters.
[^Ds.n\n[-a_-]
Ds`.
Java 8 lambda, 152 142 140 characters
Quite short:
s->s.chars().mapToObj(i->(char)i).filter(c->"COSTab\"\\cefh(i)j+l-mn.oprstuv>".contains(""+c)).collect(java.util.stream.Collectors.toSet())
Or ungolfed over here:
public class Q89400 {
static Set<Character> inAndQuine(String in) {
return in.chars()
.mapToObj(i->(char)i)
.filter(c->"COSTab\"\\cefh(i)j+l-mn.oprstuv>".contains(""+c))
.collect(java.util.stream.Collectors.toSet());
}
}
Of course the ungolfed solution is wrong, as it doesn't match the curly brackets and some more characters, it's just their for the sake of completeness.
The function takes input as a String and returns a java.util.Set<Character> containing the characters which are present in both input and source.
Updates
It turned out that the solution wasn't working. I thought String#contains tests for a regex match but it is just a literal matching. I added some escaping to quote the characters like . but this wasn't necessary but ruined everything instead. Now without this escaping we save some characters and now it actually works :)
Thanks to @NonlinearFruit for reminding me of using one-character variables.
sed, 47 characters
:s;st[^])(*\1.s2t:[;^]tt;st\(.\)\(.*\1\)t\2t;ts
I'm a little disappointed at how long this came out to be, especially the bit to remove repeated characters.
Matlab, 37 bytes
Quite simple:
Uses the builtin intersect to find the intersection. The source code is hard coded. Input must be given inside quotation marks ''
intersect(input(''),'''intersc(pu),')
ListSharp, 222 bytes
STRG S=READ[<here>+"\\S.txt"]
ROWS T=ROWSPLIT S BY [""]
ROWS R=ROWSPLIT "STRG =EAD[<her>+\".tx]OWPLIBYCFMHVNc#isn()oay\r\n" BY [""]
ROWS R=SELECT FROM T WHERE[EVERY STRG IS ANY STRG IN R]
SHOW=<c#R.Distinct().ToArray()c#>
ridiculous but im entertained
JavaScript (ES6), 59 57 bytes
f=
t=>[..."\"().=>O[\\]defilnrtx~"].filter(e=>~t.indexOf(e))
;
<input placeholder=Input oninput=o.value=f(this.value).join``><input placeholder=Output id=o>
Returns an array of characters present in both the original string/character array and the source code. Edit: Saved 2 bytes thanks to @user81655.
Dyalog APL, 8 bytes
'∩''⊢'∩⊢
∩ is returns those characters from the left argument that are present in the right argument (if the left argument has no duplicates – as in this case – then the result also has no duplicates
⊢ is the argument
Then the string just has those two plus the quote character (doubled, as it is in a string).
Brachylog, 23 bytes
:{e.~e":{}e~\"fd\."}fd.
Explanation
:{ }f Find all chars that verify the predicate below
d. Remove duplicates and output
e. Take a char from the input ; this is our output…
~e":{}e~\"fd\." … if that char is in the string :{}e~"fd. (the first \ is here
to escape the ")
Pyth, 9 8 bytes
1 byte thanks to Sp3000
@Q"\Q@\"
@Q"\Q@\"
@Q"\Q@\"" implicit string ending
@Q intersect the input with
"\Q@\"" the string containing '\', 'Q', '@', '"'.
Python 2, 44 bytes
x='c=set;print c(`x`)&c(raw_input())';exec x
Just for fun, here's a quine-like full program submission. Outputs the string representation of a Python 2 set.
Jelly, 10 6 bytes
“Ṿf”Ṿf
How it works
“Ṿf”Ṿf Main link. Argument: s (string)
“Ṿf” Set the return value to 'Ṿf'.
Ṿ Uneval; yield '“Ṿf”'.
f Filter; remove the characters from '“Ṿf”' that do not appear in s.
Haskell (30 bytes)
This is such a boring solution... But I couldn't do better. :(
filter(`elem`"f(term)\"i`l\\")
Ruby, 34 + n flag = 35 bytes
Doesn't exactly work with multi-lined input, since -n causes the program to process STDIN line-by-line. There aren't newlines in this code, but trying to input something like that will output multiple arrays instead of one. If that is not good according to spec, please inform me and I will fix.
p $_.chars&"\\\"p $_.chars&".chars
CJam, 8 bytes
"`q&"`q&
Explanation:
"`q&" e# Push that string to the stack
` e# Stringify, pops the string and pushes "\"`r&\"" to the stack
q e# Pushes the input to the stack
& e# Union, pops two elements and pushes a list of every element that is contained in both.
Python 2, 56 46 39 Bytes
-1 Byte thanks to @Jeremy
lambda a:set(':&()smelt\ bad\'')&set(a)
anonymous lambda function, takes a string, returns a set
old version:
lambda x,w=set('newmatrixbuspdl_:-)(=,\ \''):w-(w-set(x))
R, 129 bytes
f=function(s){b=strsplit("f=unctio(s){arpl;,[1]b\\\"qemh0T}",c())[[1]];cat(b[unique(pmatch(strsplit(s,c())[[1]],b,0,T))],sep="")}
If I ungolf it, it needs to have weird things changed like a newline in the string for b. Anyhow, its super simple -- builds a vector with all characters in the function in it. Then it pulls the input into a vector, and checks membership.
Python, 48 bytes
First thing I though of. It can probably be golfed more.
Input comes from sdtin. Output goes to stdout as a set object
print set(raw_input())&set("raw_pint se(u)\&\"")
C, 142 bytes
main(i){char*p,a[]="remain([*]){fought?>:01;,\\\"=capsv+-l}";for(;(i=getchar())>=0;p?putchar(i),memmove(p,p+1,a+strlen(a)-p):0)p=strchr(a,i);}
PowerShell v4+, 122 104 bytes
([char[]]($args[0]+'acegfhmnoprstu012|][()"?+_,.$-{0}{1}{2}'-f("'","}","{"))|group|?{$_.count-gt1}).name
Ugh. Quines or quine-like code in PowerShell sucks, because the string replacement formatting is so clunky.
The string ace...{2} in the middle is every character that's present in the rest of the code. The {0}{1}{2} is used in conjunction with the -format operator to pull the '{} characters into the string.
That's combined as a char-array with the input $args, then fed into the pipeline. The first stop is Group-Object which (essentially) creates a hashtable of the input objects and how many times they occur in the input. That's piped to |?{...} the Where-Object to only select those items that have a .count greater than 1. We encapsulate that in parens, and pluck out the .Name portion of the hashtable (which is where the v4+ requirement comes into play, otherwise we'd need an additional |Select Name stage to the pipeline).
Those elements are left on the pipeline (as an array), and printing is implicit.
MATL, 8 bytes
'X&'''X&
Input is a string enclosed in single quotes. If the string contains a single-quote symbol, it should be duplicated to escape it.
Explanation
'X&''' % Push string with the three characters used by the program. The single-quote
% symbol needs to be escaped by duplicating it
X& % Take input implicitly. Set intersection. Display implicitly
GolfScript, 6 bytes
"`&"`&
How it works
# (implicit) Push the input on the stack.
"`&" # Push the string '`&' on the stack.
` # Inspect; turn the string into '"`&"'.
& # Perform set intersection.