Intro
The challenge is to create a program/function that prints the intersection of its own source code and a given string input. This is code golf and to be more precise:
- Let
I
be the input set{"a","b","c"}
- Let
S
be the source code set{"b","f"}
- Then the intersection is what they share
I ∩ S = {"b"}
Input
Input is flexible. It should be able to handle the character encoding used for the source code.
Output
Output is flexible. It should be the set of characters that the input and source code share. Also, sets are unordered collections of distinct objects. In summary:
- Output is flexible:
- Could be any data structure (string or otherwise)
- Could unordered
- Could have a trailing
\n
- Should be distinct
Restriction
Similar to quine challenges, the program/function may not read its own source code and 0-byte solutions are not allowed.
Examples
- #1
functor x(I){ return I ∩ self; }
Inputs Outputs
------ -------
enter preformatted text here -> {"e","n","t","r","f","o","x"}
["Albrt"," Einstin"] -> {"l","r","t","n","s"}
- #2
(_)->_&"(_)->&\"\\"
Inputs Outputs
------ -------
"Security at the expense of -> "
usability comes at the expense
of security."
(0____0) -> (_)
- #3
ಠa益длф
Inputs Outputs
------ -------
Far out in the uncharted backwaters ->"a"
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.
(ノಠ益ಠ)ノ彡┻━┻ ->"ಠ益"
Test Cases
Albert Einstein
\__( O__O)_/
!@#$%^&*()_+{}|:"<>?
1234567890-=[]\;',./
(ノಠ益ಠ)ノ彡┻━┻
“¤>%,oỊȤʠ“ØụĊ5D³ṃṠɼQ»j;Ç;“;}¶”
┬──┬ ノ( ゜-゜ノ)
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.
Update
- [16-08-10]: sets are unordered collections of distinct objects
- [16-08-10]: trailing newline is acceptable