text:
List of possible birth years of living humans
The Challenge
Output a list of years that starts with the current year and ends 120 years ago. The birth year of every living human would be included in this list.
Details
The list should be in descending order.
Every built-in function to manipulate arrays and/or lists is allowed.
Shortest code in bytes wins.
When run this year 2016, the output would be
2016, 2015, ..., 1897, 1896
When run next year 2017, the output would be
2017, 2016, ..., 1898, 1897
Etc.
Update

Some have asked about the format of the list. As most have guessed, it doesn't matter. Insert any separator between the numbers. Intuitively most inserted a comma or space or both, newline or output an array.
Quasi superhumans like Jeanne Calment are an exception to the rule stated in my question.

Please help me understand how to improve my question. It's my first code golf question.

I recommend the sandbox for getting feedback before posting a challenge (not just for your first challenge - most of us use it for every challenge).

Thanks. I didn't know the sandbox existed. Not sure though if I know now should delete my question first. Seems a legit code golf question, but I'll go to the sandbox first.

I don't see anything wrong with this challenge. One thing that might be worth specifying is whether the output should always start with 2016, or with the year in which it is run (will it start with 2017 if run next year?). This will affect whether it is a fixed output challenge, or needs to access the current date.

If you get lots of downvotes, it probably means something is wrong. If you just get one downvote, it doesn't necessarily mean anything. It's worth asking just in case, but sometimes a challenge gets a downvote just at random.

I think you should probably either specify a separator to use between years, or explicitly say we can use any separator.

Jeanne Louise Calment lived 122 years.

Lad, that was way too early of an accept.

Does the output format matter?

And you have an off-by-one besides.  You can have a 119 year old born in 1895.

Is the challenge: "Print all the numbers from y - 120 to y" or "print all the birth years of living people"? Because if someone born in 1896 is alive today, that doesn't mean that there are also still people from 1898 around.

Also, if Jeanne Louise Calment was the oldest recorded person ever, I think it's safe to say that 123 years is the upper limit. Why not go back 123 years?

Pyke, 6 bytes
wC7m-

Try it here!
w     - 121
   m- - for i in range(^):
 C7   -  current_year-i

(After w, the codepoint for 153 is present but it isn't printable)

Wow, that was a quick checkmark. Maybe wait for a Jelly answer?

Whilst I agree it was a quick checkmark, I doubt even Jelly can do it in 5

Why do you have a variable for 121? Just because it is a square number? But well done!

The w actually has an unprintable byte afterwards that makes it 121

What encoding does Pyke use?

@LeakyNun it's configurable, whatever the default for the server it's running on. On pyke.catbus, I set it to Windows-1252

Pyth, 11 9 8 bytes
-L.d3C\y

Works by mapping over the range [0...120] and subtracting every number from the current year. The range is built implicitly by using 121 as the map argument. To avoid a separating whitespace between .d3 and 121 we get this number by converting y to it's codepoint.
Thanks to @FryAmTheEggman for coming up with this approach!
Try it here!
Old 9-byte solution:
_>121S.d3

Try it here!
Builds the range [1...<current year>] and only takes the last 121 elements of it.

You should reverse the list so that it starts with the current year

-L... saves a few bytes.

@ChristiaanWesterbeek Missed that part, fixed. Thanks for spotting!

@Jakube Used a different approach now, but thanks for the reminder that this exists, didn't use Pyth a lot in the last time!

-L.d3C\y should work for 8.

@FryAmTheEggman Very clever, thanks! :) Gotta do more Pyth, needed way too long to understand how that works...

R, 34 bytes
(format(Sys.Date(),"%Y"):0)[1:121]

See here on an online interpreter.
Edit Could be reduced to 33 bytes by using substr.
(substr(Sys.Date(),1,4):0)[1:121]

but technically this solution will only work until the 9999-12-31.

This is awesome. I did not know it could typecast a string into a number when using the : operator...

BASH + coreutils, 35 33 bytes
x=`date +%Y`;seq $x -1 $((x-120))

in your case, quotes are unneeded:  change :  date +"%Y" into date +%Y

x=`date +%Y`;seq $x -1 $[x-120] or seq $[x=`date +%Y`] -1 $[x-120] works as well.

10 bytes shorter if you have OSX or are willing to install jot on Linux

AngularJS + Lodash, 274 bytes

angular.module('x',[]).controller('x',['$scope',function(x){x.x=_.range(9,new Date().getFullYear()+1).slice(-121).reverse()}])
<script src=//goo.gl/M5LvGe></script><script src=//goo.gl/opljJl></script><select ng-app=x ng-controller=x multiple><option ng-repeat="x in x">{{x}}

Output

CJam, 14 12 11 bytes
Saved 2 bytes thanks to Sp3000 and 1 byte thanks to Martin Ender
et0=121,f-p

Try it online!
Explanation
et0=         e# Push the current year
    121,     e# Push the range 0, 1, ..., 120
        f-   e# For each item in the range, subtract it from current year
          p  e# Print the array

HP50g RPL, 97 bytes
120 'S' STO DATE ->STR 6 9 SUB OBJ-> 'Y' STO {} S WHILE 0 >= REPEAT Y S - + 'S' DECR END REVLIST

Ungolfed:
120
'span' STO     @ Store the span of years to cover.
DATE           @ Get the date as number 11.082016.
→STR           @ Convert to string "11.082016".
               @ (Number format must allow all these decimal places.)
6 9 SUB        @ "11.082016" Substring for the year.
               @       ^  ^
               @  123456789
OBJ→           @ Convert string to number.
'year' STO     @ Store as the year to start at.
{} span        @ Start empty list to collect the years.
               @ Leave loop counter on the stack.
WHILE 0 ≥      @ Loop until the counter goes negative.
REPEAT
  year span -  @ E.g. on first iteration: 2016 - 120 = 1896.
  +            @ Append the year to the list on the stack.
  'span' DECR  @ Decrement loop counter and leave on stack.
END
REVLIST        @ Put list in reverse chronological order.

Showing a list of 2016 down to 1896:

Edited answer to get the current year from the calculator.

Dyalog APL, 11 10 bytes
120↑⌽⍳⊃⎕ts

120↑ take 120 elements
⌽ of the reversed
⍳ indices until
⊃ the first element of
⎕TS TimeStamp in the format [YYYY, M, D, h, m, s, t]
TryAPL online!

Old version:
(⊃⎕TS)-⍳120

⊃⎕TS first element of [YYYY, M, D, h, m, s, t]
- minus
⍳120 [0, 1, 2, ..., 118, 119]
Requires ⎕IO←0, which is default on many systems.
TryAPL online!

05AB1E, 8 7 bytes
Code:
žg120Ý-

Explanation:
žg         # Get the current year.
  120Ý     # Create the list [0, 1, ..., 119, 120].
      -    # Substract, which leaves [year - 0, year - 1, ..., year - 120].

Uses the CP-1252 encoding. Try it online!.

PowerShell, 26 24 bytes
@TimmyD improved version:
0..120|%{(date).Year-$_}

Was:
($d=(date).year)..($d-120)

where date runs Get-Date

Blargh, should have answered earlier. That's exactly the straightforward version I had ready. Then work interfered :D A fun version would also be: ((date).year..0)[0..120]; alas it's not shorter.

I find it interesting that date is equivalent to Get-Date when date is actually not an alias to Get-Date.  I've seen this called the "implied verb" rule and it is rarely ever documented in PowerShell literature.

@Bevo It's useful for CodeGolf, but a bit risky for any other use. See: http://codegolf.stackexchange.com/a/778/571 and comment chain; it's both prone to name clashes and very slow.

Vitsy + *sh + JavaScript, 33 26 21 18 bytes
Vitsy doesn't have native time/date retrieval, so I had to use shell and eval for this one.
Thanks to @Caleb for helping me shear off another 3 bytes!
'Y%+ etad',Dca*-HZ

'Y%+ etad'               Push the string 'date +"%Y"' to the stack.
          ,              Execute through shell.
           Dca*-         Dupe n, push n - 120.
                H        Pop x, y, push range(x, y) to the stack.
                 Z       Output all stack as characters.

You can't try this one online, because it uses both shell AND eval.
Output is as character codes.

You should be able to trim a couple bytes off of this because you don't need the double quotes around the date format string (since there are no spaces in it); date +%Y works just fine.

@Caleb Perfect, thanks! Made the need for a JS eval non-existent as well.

R, 47 39 bytes
as.double(substr(Sys.Date(),1,4))-0:120

If only someone invented a UTF-8 implementation of R with conveniently abbreviated frequently used system functions...
UPD: shaved off 7 (!) bytes owing to plannapus, who suggested subrtacting a 0:120 vector rather than counting from a to (a-120) and 1 byte grâce à user5957401, who noticed that double would work as well as numeric. Old version:
a=as.numeric(format(Sys.Date(),"%Y"));a:(a-120)

Fiddling around with and seq(a<-...,a-120) can only worsen the situation.

using the type forcing command as.double instead of as.numeric will save you a byte. Similarly, if instead of formatting a date, you treat the date response as a string to pull from and use substr(Sys.Date(),1,4) you save another byte

MATL, 10 bytes
1&Z'0:120-

Try it online!
1&Z'      % Push first component of "clock" vector, which is year
0:120     % Literal vector [0, 1, 2, ..., 120]
-         % Subtract element-wise. Implicitly display

Mathematica/Wolfram Language, 28 bytes
Date[][[1]]-#&/@Range[0,120]

Welcome to PPCG!

Welcome to PPCG! You don't need to use a map here since subtraction is threaded over lists automatically. And -Range@121+1 saves a byte over the zero-based list. And #&@@ a byte over [[1]]. That said, unless stated otherwise in the challenge, all submissions have to be functions or full programs, and this code is merely a snippet/expression. The shortest fix would be making it an unnamed function by appending &.

@MartinEnder Thanks for the feedback! I should have caught Minus being list able, minor mental lapse, but the other tips are much appreciated!

#&@@Date[]-#&/@0~Range~120& will save you two bytes, but then making it a function requires adding the & on the end (which I think yours needs anyway), so -1 byte in total.

05AB1E, 9 bytes
121FžgN-=
Try online

Welcome to the site! :)

Bash on OS X, 23
jot 121 `date +%Y` - -1

This will also work on Linux if you have BSD jot installed (e.g. sudo apt-get install athena-jot.

Python 2, 64 62 54 bytes
import time
n=time.gmtime()[0]
exec'print n;n-=1;'*121

@KarlKastor thanks for 8 bytes!

time.gmtime().tm_year is 3 bytes shorter

time.gmtime()[0] even shorter

@KarlKastor nice! Playing with the time module is like walking into a maze every time for me. So many ways to get lost

php, 73 66 58 42 bytes
<?=implode(', ',range($j=date(Y),$j-120));

Output:

2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006,
  2005, 2004, 2003, 2002, 2001, 2000, 1999, 1998, 1997, 1996, 1995,
  1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984,
  1983, 1982, 1981, 1980, 1979, 1978, 1977, 1976, 1975, 1974, 1973,
  1972, 1971, 1970, 1969, 1968, 1967, 1966, 1965, 1964, 1963, 1962,
  1961, 1960, 1959, 1958, 1957, 1956, 1955, 1954, 1953, 1952, 1951,
  1950, 1949, 1948, 1947, 1946, 1945, 1944, 1943, 1942, 1941, 1940,
  1939, 1938, 1937, 1936, 1935, 1934, 1933, 1932, 1931, 1930, 1929,
  1928, 1927, 1926, 1925, 1924, 1923, 1922, 1921, 1920, 1919, 1918,
  1917, 1916, 1915, 1914, 1913, 1912, 1911, 1910, 1909, 1908, 1907,
  1906, 1905, 1904, 1903, 1902, 1901, 1900, 1899, 1898, 1897, 1896

If we don't need to separate with ,, then 58 57 41 bytes:
<?=implode(' ',range($j=date(Y),$j-120));

Thanks to insertusernamehere for saving 16 bytes

You don't really need to separate with ,, look at many of the other answers.

It looks that way, but I'll put in two options so I can do what most are, and also what was requested

I've managed to get the comma answer down to my original non-comma answer size.  That's as much as I think I can golf it

You can remove the <?php tag since we allow running with -r for free

Would I then count the quotes needed round it, or just the actual execution code?

Golf off 16 bytes: <?=implode(', ',range($j=date(Y),$j-120));

I think you can count just the execution code, not anything needed to invoke it (such as the surrounding quotes or shell escapes to get the right string passed to the parser. But I think you do need a print , which is a step backwards from <?=.  You might look around at other PHP answers on popular questions and see about the print thing.

37 bytes (using win-1252 encoding) <?=join(~ß,range($j=date(Y),$j-120));

PostgreSQL, 57 bytes
Who needs a FROM :-).  Probably shouldn't work, but it does, try it at sqlfiddle
select date_part('y',current_date)-generate_series(0,120)

JavaScript, 60 53 48 Bytes
f=x=>x>Date().split` `[3]-121&&(alert(x),f(x-1))

I used a recursive solution.

You can replace console.log with alert, and remove the last ;.

Save 5 bytes with f=x=>x>Date().split" "[3]-121&&(alert(x),f(x-1)), replacing the quotation marks with backticks.

Python 2, 62 bytes
import time
for n in range(121):print int(time.ctime()[-4:])-n

And at 64 bytes:
for n in range(121):print int(__import__("time").ctime()[-4:])-n

JavaScript, 55 52 50 49 bytes
for(a=d=s=Date().substr(11,4);d-->s-120;)a+=" "+d

+9 bytes to alert the data (not necessary if you run this in a console).
for(a=d=s=Date().substr(11,4);d-->s-120;)a+=" "+d;alert(a)

-4 bytes if the delimiter isn't necessary.
for(a=d=s=Date().substr(11,4);d-->s-120;)a+=d

for (a = d = s = Date().substr(11, 4); d --> s - 120; )
    a += " " + d;
console.log(a);

The []s appear to be unnecessary.

@Neil: Thanks. My original solution used an array, but I hadn't thought to remove it.

You can save one byte using a for instead of while on this: for(a=d=s=Date().substr(11,4);d-->s-120;)a+=" "+d!

Oracle SQL 11.2, 111 bytes
SELECT LISTAGG(TO_CHAR(SYSDATE,'YYYY')-LEVEL+1,', ')WITHIN GROUP(ORDER BY LEVEL)FROM DUAL CONNECT BY LEVEL<122;

I would be tempted to say the the listagg isn't required and just the set of ordered rows

C, 87 85 76 74 65 bytes
main(int i,char**v){for(i=0;i<121;printf("%d,",atoi(v[1])-i++));}

Ungolfed:
main(int i,char**v){
    for(i = 0; i < 121; printf("%d,", atoi(v[1])-i++));
}

My first code golf - Any pointers would be well received. Would be nice if I could cut out the argc/argv junk, but I'm not that skilled a C programmer. Improvements welcome.
EDIT: The current year is obtained from the commandline - specifically by a group of automated, well trained drinking birds.
EDIT 2: 85 bytes Thanks to Easterly Irk (removed spaces around arg function parameters)
EDIT 3: 76 bytes Thanks to anatolyg for pointing out the obvious (removed verbose argc/argv param names)
EDIT 4: 74 bytes Thanks to Yay295 (char**v, changed year delimiter)
EDIT 5: 65 bytes thanks to Yay295 and matt (re-used the variable i, removed variable x, changed while to for loop, updated printf to include atoi() read and i++)

Can't you a space? int argc, char -> int argc,char?

Replace argc by c (or better replace int argc by just int) and argv by v. Also replace while by for. The latter change requires some experience in C (but may be fun regardless).

@anatolyg oh, duh (for the argc/argv stuff). Wouldn't the 'for' loop be the same length as the while loop? for(;i>x;) vs while(i>x)?

char*v[] -> char**v saves 1 byte. You can save another by delimiting your years with a space or a comma instead of a newline.

You can make it shorter.  71 bytes.
main(int c,char**v){int i=0;while(i<120)printf("%d,",atoi(v[1])-i++);}

@Matt: Nice, but we can go one further. main(int i,char**v){i=0;while(i<121)printf("%d,",atoi(v[1])-i++);}. Also, we've been off by 1.

@Yay295 - sweet! good reuse of i.

Even shorter. 65 bytes  main(int i,char**v){for(i=0;i<121;printf("%d,",atoi(v[1])-i++));}

63 bytes: main(i,v)char**v;{for(i=0;i<121;printf("%d,",atoi(v[1])-i++));}

Processing, 51 42 41 bytes
for(int i=0;i<121;)print(year()-i+++" ");

Ungolfed
for(int i = 0; i < 121;)
    print(year() - i++ + " ");

Processing is just a wrapper for Java if you didn't know, and takes most of the boilerplate away, so the obvious solution is also super short compared to a Java version.  Also opens a window for drawing graphics, but having that doesn't appear to disqualify me :)

for(int i=0;i<121;)print(year()-i+++" ");

I love the "+++", it looks so suspicious.  Thanks for the suggestion!

MATLAB, 18 bytes
Assuming the output format doesn't matter (aside form descending order), the following program prints the last 121 years starting with the current one.
year(date)-(0:120)

It requires MATLAB version r2014a or higher. Earlier versions didn't include the year function.

Go, 71 bytes
import."time"
func f(){for t,i:=Now().Year(),0;i<120;i++{println(t-i)}}

Attempt This Online!
Prints to STDERR.

jq, 46 characters
(45 characters code + 1 character command line option)
now|strftime("%Y")|tonumber|range(.;.-121;-1)

Sample run:
bash-4.3$ jq -n 'now|strftime("%Y")|tonumber|range(.;.-121;-1)' | head
2016
2015
2014
2013
2012
2011
2010
2009
2008
2007

On-line test

Vim, 32 29 keystrokes
Thanks to @daniero for some help on saving some keystrokes and making the output a little neater.
"=strftime('%Y')<Enter>pqqYp<Ctrl-x>q118@q

<Enter> is Enter
<Ctrl-x> is Ctrl + X

Explanation:
"                                          # Put into the register {
 =strftime('%Y')                           #   This year in YYYY form
                <Enter>                    # }
                       p                   # Paste the register
                        qq                 # Record macro q {
                          Y                #   Yank (copy) the current line
                           p               #   Paste
                            <Ctrl-x>       #   Decrment number at cursor
                                    q      # }
                                     118@q # Do macro q 118 times

Output format:
Each number is on a separate line like below.
2016
2015
.
.
.
1898
1897

OP clearly asks for a future-proof version, so only the second one answers the question. Don't you need to punch the Enter key (commonly refered to as <CR> in Vim context) after :pu=strftime('%Y')? Also, you can skip some keystrokes by using Y with copies the whole line. In total: :pu=strftime('%Y')<CR>qqYp<Ctrl-x>q118@q - 30 keystrokes

Also, you can yank from the = register: "=strftime('%Y')<CR>pqqYp<Ctrl-x>q118@q - 29 keystrokes, and it gets rid of the first empty line

If you're allowed to use shell as well then you can save five more keystrokes with the date utility: :.!date +\%Y<CR>qqYp<C-x>q118@q

PHP, 40 35 33 bytes
while($i<121)echo date(Y)-$i++._;

I'm just going to pretend that error reporting is always disabled for code golfing... :)
[Edit 1: Saved 5 bytes via manatwork]
[Edit 2: Saved 2 bytes via Titus]

Forget good coding habits here. ;) Call that date() 121 times: while($i<121)echo date(Y)-$i++." ";.

@manatwork: save another two bytes by using the underscore (or any letter or 0) as separator: while($i<121)echo date(Y)-$i++,_; (33 bytes)

@manatwork Oh cripes how did I miss that? :)

@Titus Nice. I used the "interpret an unquoted constant as a string" thing already once here, and still totally missed this one.

It is always assumed that config is at default settings, so in PHP: E_NOTICE, E_DEPRECATED and E_STRICT are off -> You´re safe. (for different settings you have to either add the command or the string to add to config to your byte count)

OK great, the default recommended ini that ships with the source turns E_NOTICE back on. Good to know I can ignore that.

I wrote almost the exact same answer, then noticed yours on page 2 :( for(;$i<121;)echo~ß,date(Y)-$i++;

On second thought, you can still shave off 3 bytes (using the dodgy delim rule): for(;$i<121;)echo$i++-date(Y);

Perl, 33 bytes
say+(gmtime)[5]-$_+1900for 0..120

Run with -M5.010 or -E :
perl -E 'say+(gmtime)[5]-$_+1900for 0..120'

k, 27 bytes
Output as specified
1@", "/:$(`year$.z.d)-!121;

Example:
k)1@", "/:$(`year$.z.d)-!121;
2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006, 2005, 2004, 2003, 2002, 2001, 2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984, 1983, 1982, 1981, 1980, 1979, 1978, 1977, 1976, 1975, 1974, 1973, 1972, 1971, 1970, 1969, 1968, 1967, 1966, 1965, 1964, 1963, 1962, 1961, 1960, 1959, 1958, 1957, 1956, 1955, 1954, 1953, 1952, 1951, 1950, 1949, 1948, 1947, 1946, 1945, 1944, 1943, 1942, 1941, 1940, 1939, 1938, 1937, 1936, 1935, 1934, 1933, 1932, 1931, 1930, 1929, 1928, 1927, 1926, 1925, 1924, 1923, 1922, 1921, 1920, 1919, 1918, 1917, 1916, 1915, 1914, 1913, 1912, 1911, 1910, 1909, 1908, 1907, 1906, 1905, 1904, 1903, 1902, 1901, 1900, 1899, 1898, 1897, 1896

It can be shortened more by not formatting the output and merely returning the list of integers:
(`year$.z.d)-!121

Fourier, 17 bytes
121(5d-io10ai^~i)

Since no output format is specified, each year is separated by a newline:
Try it online

LaTeX, 129 bytes
Or, if I'm allowed to skip the document class definition & setup, and just count the package import and for loop code: 79 bytes.
\documentclass{book}\usepackage{tikz}\begin{document}\foreach \n in {0,...,120}{\pgfmathint{\year\n}\pgfmathresult}\end{document}

Ungolfed:
\documentclass{book}
\usepackage{tikz}
\begin{document}
\foreach \n in {0,...,120}
{
\pgfmathint{\year-\n}\pgfmathresult}

\end{document}

Output (w/ free page number :) ):

LaTeX (90 bytes without "free page number"): \documentclass[tikz]{standalone}\document\foreach~in{0,...,120}{ \the\numexpr\year-~}\stop
Plain TeX (60 bytes with "free page number"): \input tikz \foreach~in{0,...,120}{ \the\numexpr\year-~}\bye

Japt, 12 6 bytes
Saved 6 bytes thanks to @ETHproductions
#yonKi

Try it online!
Explanation:
#yonKi
#y          // # gets the char-code of y, which is 121
  o         // Create a range from [0...121]
   nKi      // At each item, perform .n(K.i()), which subtracts each item from Ki (Current year)

Minim, 49 Bytes
Program is run as follows:
C:\Users\chris> minim -f golf.min

Golfed:
[]="xyear".\<1.\>[1].#<[1]--i.$<32._^!--[0].C-=4.

With whitespace and comments:
[] = "xyear".  ; Insert the string 'xyear' into memory from index 0 \
                 The 'x' character corresponds to the value '120'
\< 1.          ; Insert 1 as a system call argument \
                 This corresponds to the index in memory of the \
                 function name to call, 'year'
\> [1].        ; Call the function and insert the result at memory index 1
    #< [1]--i. ; Print memory index 1 as an integer, post-decremented
    $< 32.     ; Print a space
    _^ !--[0]. ; Skip the next statement if memory index 0, pre-decremented, is 0
C -= 4.        ; Subtract 4 from the program counter

GitHub Repository

Haskell 125 bytes
The imports take up a large part of the byte count
import Data.Time.Clock
import Data.Time.Calendar
main=fmap((\(x,_,_)->[x-120..x]).toGregorian.utctDay)getCurrentTime>>=print

I'm afraid the list is in the wrong order, the spec says current year first. Howevery we can save a few bytes: a) import Data.Time should be enough for all needed functions. b) use the infix version of fmap, i.e. <$>. c) do x<-toGregorain ... ;print[x-120..x] is shorter than the lambda. d) You can extract the year from getZonedTime via read.take 4.show<$>getZonedTime. All in all, including correct order: import Data.Time;do y<-read.take 4.show<$>getZonedTime;print[y,y-1..y-120].

SQLite, 82 80 bytes
with b(y)as(select strftime('%Y')union select y-1 from b limit 121)select*from b

SQLFiddle
(For ANSI SQL, replace the strftime() with extract(year from current_date).)
(2 bytes saved thanks to @MickyT)

You can save yourself a couple with select*from b rather than select y from b

C# - DotNet core - 133 bytes
Golfed
class Program{static void Main(){int x=0,y=System.DateTime.Now.Year;while(x<121){System.Console.Write($"{y-x++}"+(x<121?", ":""));}}}

Ungolfed
class Program
{
    static void Main()
    {
        int x=0, y=System.DateTime.Now.Year;

        while(x<121)
        {
            System.Console.Write($"{y-x++}" + (x < 121 ? ", " : ""));
        }
    }
}

Output:

I'm sure this can be improved. I don't particularly like the if statement to display or hide the trailing comma.

Javascript: 68 82 59 bytes
i=121;while(i--){x[i]=Date().substr(11,4)-i;}console.log(x)

Will this give a proper output when run in 2017?

yes, now it will, oops :-)

Ruby, 47 40 39 bytes
p [*0..Time.new.year].last(121).reverse

Thanks to @Value Ink for 7 bytes!
Ideone link: https://ideone.com/yRovUl

Some people are submitting programs where the separator is newline, so you can take out the joining operation and just puts it. Or use p *<the rest> because they're all integers

Thank you @Value Ink. Since outputting an array is allowed, I used plain p instead p *<the rest>

Coffeescript, 29 bytes
->a=Date()[11..14];[a..a-120]

Welcome to Programming Puzzles & Code Golf!

Thanks! I've been lurking for a while, finally had time to start

JavaScript (ES6), 65 bytes
[...Array(1+- -Date().substr(11,4)).keys()].slice(-121).reverse()
You're welcome to improve and shorten it...
Thanks to @Yay295 for the fix. I was 1 year off.

[...Array(+Date().substr(11,4)).keys()].slice(-120).reverse() is less!

56 Bytes in ES5:
s='';for(i=120;i--;)s+=new Date().getFullYear()-120+', '

@innovati: That prints the same year over and over. If you replace the last '120' with 'i' as I expect you meant, it's still in the wrong order.

@ChristiaanWesterbeek,@eithedog: You're both off by 1. Try [...Array(1+- -Date().substr(11,4)).keys()].slice(-121).reverse() instead.

Python 2, 67 bytes
from datetime import*;for i in range(121):print date.today().year-i

Thanks to Sp3000 for removing one byte

For future reference: In most situations, __import__ isn't really needed, e.g. here you can do from datetime import* and print date.today().year-i instead for -1 byte.

VBA, 54 bytes
In the immediate pane:
For i=0 To 120:?Year(Date)-i &IIf(i=120,"",", ");:Next

In an actual Sub procedure (the VBE adds whitespace and changes ? to Print, but the code is per language specs without the whitespace and using the ? shorthand nonetheless):
Sub A()
For i = 0 To 120: Print Year(Date) - i & IIf(i = 120, "", ", ");: Next
End Sub

That's 88 characters per Notepad++, with i being an undeclared, implicit Variant local variable.
Both produce the output exactly as specified in the question, comma-separated and with a space between each year:
2016, 2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006, 2005, 2004, 2003, 2002, 2001, 2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984, 1983, 1982, 1981, 1980, 1979, 1978, 1977, 1976, 1975, 1974, 1973, 1972, 1971, 1970, 1969, 1968, 1967, 1966, 1965, 1964, 1963, 1962, 1961, 1960, 1959, 1958, 1957, 1956, 1955, 1954, 1953, 1952, 1951, 1950, 1949, 1948, 1947, 1946, 1945, 1944, 1943, 1942, 1941, 1940, 1939, 1938, 1937, 1936, 1935, 1934, 1933, 1932, 1931, 1930, 1929, 1928, 1927, 1926, 1925, 1924, 1923, 1922, 1921, 1920, 1919, 1918, 1917, 1916, 1915, 1914, 1913, 1912, 1911, 1910, 1909, 1908, 1907, 1906, 1905, 1904, 1903, 1902, 1901, 1900, 1899, 1898, 1897, 1896

If the commas aren't a requirement (as some other answers seem to presume), then the IIf part can be dropped, cutting the immediate pane code down to 33 bytes:
For i=0 To 120:?Year(Date)-i:Next

ListSharp, 71 bytes
NUMB a=<c#DateTime.Now.Yearc#>
[FOREACH NUMB IN a TO a-120 AS y]
SHOW=y

Uses embedded c# code, new feature!!

Nim, 60 bytes
import times
for a in 0..120:echo getTime().getGmTime.year-a

Outputs each year on a new line. We use the getTime to get the current UNIX time, then convert it to UTC with getGmTime, get the year minus the counter variable, and echo it.

Batch, 67 bytes
@set/ay=%date:~-4%,z=y-120
@for /l %%i in (%y%,-1,%z%)do @echo %%i

Python 3, 54
import time
print(*range(time.gmtime()[0],0,-1)[:121])

C#, 83 76 bytes
n=>{for(n=0;n<121;)System.Console.Write(System.DateTime.Now.Year-n+++" ");};

JavaScript (ES6), 66 54 51 bytes
My first foray into code golf so I'm open to suggestions for improvements.
The following will output an array of the required years.

f=

_=>[...Array(121)].map((x,y)=>Date().split` `[3]-y)

console.log(f());

History
54 bytes
_=>Array(121).fill(Date().split` `[3]).map((x,y)=>x-y)

66 bytes
(y=[Date().split` `[3]],x=121)=>{while(x--)y[x]=(y[0]-x);return y}

Well done this was my solution before i read any comments _=>[...Array(121)].map((v,i)=>Date().substr(11,4)-i)

Vyxal, 11 9 bytes
kðt:122-r

Try it Online!
-2 thx to @lyxal

K (ngn/k), 12 bytes (Non-competitive)
{x,x-1+!120}

Try it online!
K lacks any date-related functions, so this one is non-competitive.
Explanations:
{x,x-1+!120}  Main function. Takes x as input
       !120   Generate a range from 0 to 120 (exclusive)
     1+       +1 to each number (1..120)
   x-         x subtract to each number (x-1..x-120)
 x,           Concat x itself as the first number of the array (x,x-1..x-120)

Julia 1.0, 46 45 bytes
using Dates
y=year(now())
show([y:-1:y-120;])

Try it online!

-1 byte thanks to @amelies: replace print with show

show instead of print to save 1 byte

Thunno 2, 6 bytes
kOṇÞL-

Attempt This Online!
Explanation
kOṇÞL-  # Full program
kO      # Push the current year
  ṇÞ    # Compressed integer 121
    L   # Lowered range
     -  # Subtract
        # Implicit output

Python 2, 113 bytes
import datetime
theYear = datetime.datetime.now()
for i in range(theYear.year, theYear.year-121, -1):
   print i,','

Welcome to Code Golf! You need to list the language you're using, and because this is a [tag:code-golf] challenge, you also need the bytecount.

This is definitely Python 2.

Thanks. How can I calculate the bytes?

Java 75 74 bytes
public void possible(){
  for(int i=0;i<120;){
    System.out.println(new Date().getYear()-i++);
  }
}

Golfed :
void p(){for(int i=0;i<120;)System.out.println(new Date().getYear()-i++);}

1 byte off. Thanks to @LeakyNun

void p(){for(int i=0;i<120;)System.out.println(new Date().getYear()-i++);}

What version of Java is this? As far as I'm aware, getYear() gives you the year since 1900. That means that the current output would be [116, -3]. You'd have to add +1900 (5 bytes) in order to get the correct output. Also, Date requires an import (java.util.Date), which would add to the byte count too.

@MH. is right, this code will not compile without the imports so you need to either new java.util.Date() or add the import. Also, why don't you shorten it further by replacing the method with a lambda expression?

QBIC, 33 bytes
A=right$(_D,4)┘[!A!,!A!-120,-1|?a

TI-Basic, 22 19 bytes
max(getDate:seq(I,I,Ans,Ans-120,~1

getDate:Ans(1 can be max(getDate.

Groovy, 57 bytes
d=new Date().getYear()+1899;(d..d-120).each{println it}

Explanation
d=new Date().getYear()                               //returns how many years have passed since 1900
                      +1899;                         //adding 1900 will give us the current year, but we want the program to start one year before, so we do +1900-1=1899
                            (d..d-120)               //a range from the current year -1 to 120 years before that
                                      .each{print it}// for each element in the range, print it.

Output
2016
2015
2014
...
1898
1897
1896

Because of the 1899 trick, it starts with 2016 instead of 2017
Tested on the Groovy Web Console

VBA 49 bytes
a=year(now):for i=a to a-120 step-1:msgbox i:next

JavaScript, 75 71 bytes
Saved 4 bytes thanks to Zachary.
e="";for(y=(new Date).getFullYear(),i=y;i>=y-120;i--)e+=i+" ";alert(e)

Prints all years into a single alert.
I'm sure it could be improved.
History
75 bytes
var e="";for(y=(new Date).getFullYear(),i=y;i>=y-120;i--)e+=i+" ";alert(e);

(Every year was in a separate alert)
for(y=(new Date).getFullYear(),i=y;i>=y-120;i--)alert(i);

Welcome to PPCG! I'm not sure whether there exists a consensus on this, but I do not think that opening an alert for each element counts as outputting the list.

Hello. It is now in a single alert. (but with more bytes... :))

Two things, I don't think you need the var before e, and I also don't think you need a semicolon after alert(e).

Tcl, 76 bytes
set y [clock format [clock seconds] -format %Y]
time {puts $y;incr y -1} 121

Try it online!

VBA, 31 Bytes
Anonymous VBE immediate window function that takes no input and outputs to the VBE immediate window
For i=0To 120:?Year(Now)-i:Next

Factor, 30 bytes
[ now year>> dup 120 - [a,b] ]

Try it online!
now     ! T{ timestamp { year 2022 } { month 10 } ... etc }
year>>  ! 2022
dup     ! 2022 2022
120     ! 2022 2022 120
-       ! 2022 1902
[a,b]   ! { 2022 2021 2020 ... 1902 }

jq -n, 24 bytes
now|gmtime[0]-range(121)

Try it online!

Arturo, 24 bytes
$=>[y:now\year y..y-120]

Try it!
$=>[           ; a function
    y:now\year ; assign current year to y
    y..y-120   ; the range y down to y-120
]              ; end function

Lua, 40 bytes
for i=0,120 do print(~~os.date"%Y"-i)end

Try it online!
The ~~ is used to remove a trailing .0 from each year.

Ruby, 39 36 bytes
t=Time.new.year;t.downto(t-120).to_a

Old:
t=Time.new.year;(t-120..t).to_a.reverse

Should be obvious.

Where's the output?

Output is implicit. It's the return value of the last statement. Test it here: https://repl.it/CmDY/0

Output is not implicit: You can print the result, or you can return it from a function. From the codegolf wiki: Both programs and functions may output by writing to STDOUT. Functions may also use their arguments or return value(s) for output.

@daniero Sorry, I explained it badly. My program still holds to that definiton tho.

I'm sorry to be so strict and boring -- of course i know what you mean, but your answer is sloppy, as it doesn't do anything. All other answers here, as far as I can tell, either prints something or returns something.

And oh, maybe this bit of the tag wiki is more relevant: Answers may be either full programs or functions (or equivalent). As a full program your answer doesn't do anything.

couldn't this be made into an executable program just by putting it in a proc, i.e.
->{Time.new.year;t.downto(t-120).to_a}
which comes out to only 2 more bytes

@DaneAndersen that code doesn't define t

Just do p *t.downto(t-120) :D no proc object needed

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Fix my IPv4 address's missing periods
Sometimes when I'm typing out an IPv4 address, I get all the numbers right, but I forget to type one or more periods. I'd like to have a program (or function) that takes my broken IPv4 address and outputs all possible valid placements of the missing periods.
Input
The input will always be a string that is a transformation of a valid IPv4 address (see particulars below). It will always have been transformed solely by the elimination of one or more period characters.
You submission does not need to handle inputs outside of this format.
Output
A collection or list, in no particular order or format, of strings representing all valid IPv4 addresses that can be created from the input by the insertion of period characters into the input.

The output may be a language-native list or other ordered or unordered collection type.
Alternatively, it may be a string sequence of IPv4 address delimited in some clear way.

If you use a single-character delimiter to delimit your string, periods and digits are not allowed as that single-character delimiter. I realize that, unlike numbers, periods as delimiters are not ambiguous (since every fourth period would necessarily be a delimiter) but for the sake of readability, I am disallowing it.

IPv4 address format
While IPv4 addresses are really just a sequence of four binary octets, this challenge uses a restricted dotted decimal format.

An IPv4 address is a four decimal values separated by three periods.
Each of the four values are in the range 0 to 255, inclusive.
Leading zeros are not allowed in any number value. (Standalone one-character 0 is allowed; any other number beginning with a zero is not: 052, 00, etc.)

Test Cases
Input is on the first line, output on second line (here, structured as a comma-separated list of quoted strings, separated by commas, surrounded by [ ], but you may use any reasonable format or structure, as specified above). Some examples have notes on a third line to highlight the application of a particular rule.
192.168.1234
["192.168.1.234", "192.168.12.34", "192.168.123.4"]

192.1681234
["192.16.81.234", "192.168.1.234", "192.168.12.34", "192.168.123.4"]
(Note: 192.1681.2.34 (etc.) is illegal because 1681 is greater than 255)

1921681.234
["19.216.81.234", "192.16.81.234", "192.168.1.234"]

1921681234
["19.216.81.234", "192.16.81.234", "192.168.1.234", "192.168.12.34", "192.168.123.4"]

192.168.1204
["192.168.1.204", "192.168.120.4"]
(Note: 192.168.12.04 is illegal because of leading zero)

192.168.123
["1.92.168.123", "19.2.168.123", "192.1.68.123", "192.16.8.123", "192.168.1.23", "192.168.12.3"]

192.168.256
["192.168.2.56", "192.168.25.6"]
(Note: Any combination that would leave 256 intact is illegal)

120345
["1.20.3.45", "1.20.34.5", "1.203.4.5", "12.0.3.45", "12.0.34.5", "120.3.4.5"]
(Note: 12.03.4.5 (etc.) is illegal due to leading zero.)

012345
["0.1.23.45", "0.1.234.5", "0.12.3.45", "0.12.34.5", "0.123.4.5"]
(Note: the first segment must be 0, because `01` or `012` would be illegal.)

000123
["0.0.0.123"]

(I made these examples by hand, so please alert me to any mistakes you may find.)

output order is matters?

@YOU No: "A collection or list, in no particular order or format..."

Leading zeros are not allowed: Does that apply to the input too?

@LuisMendo Valid input is the set of all possible IPv4 address, as defined in "IPv4 address format" here, but with one or more periods removed. If it is not possible to add periods to an input such that it no longer has leading zeroes, then it fails to fall within that set (since there is no way such an input could have been created from an initially-valid IPv4 address but then had periods removed). It is possible for an input to be something like 1.02.34, since such an input could have been created by removing the middle period from the valid IP 1.0.2.34.

So.... "000125" should only return one correct solution... 0.0.0.125?

@Keeta That is exactly correct. (I just added it as a test case.)

Pyth, 24 bytes
f&q4lJcT\.!-J`M256jL\../

Try it online
How it works
                      ./Q   all partitions of input
                  jL\.      join each on .
f                           filter for results T such that:
      cT\.                    split T on .
     J                        assign to J
    l                         length
  q4                          equals 4
 &                            … and:
           -J`M256              J minus the list of representations of [0, …, 255]
          !                     is false (empty)

Pyth, 17 bytes, very slow
@FjLL\.,^U256 4./

Warning.  Do not run.  Requires approximately 553 GiB of RAM.
How it works
       ,             two-element list of:
        ^U256 4        all four-element lists of [0, …, 255]
               ./Q     all partitions of input
  jLL\.              join each element of both on .
@F                   fold intersection

Nice! Just for my own understanding, "all partitions of input" means all possible ways of segmenting the input, right? So you make every possible split and then rejoin the splits with periods, so you end up with loads of candidates like 1.9.2.1.6.8.1.2 and 19.2.1.6.8.1.2 etc.? (But then obviously all the invalid ones get filtered out)

@apsillers Correct.

C (gcc/linux), 125 121 bytes
i;f(char*a){do{char*y=a,s[99],*x=inet_ntop(2,&i,s,99);for(;*x&&!(*x^*y&&*x^46);++x)y+=*x==*y;*x|*y||puts(s);}while(++i);}

Loops over all possible IPv4 addresses, and does a custom comparison that skips over extra dots in the generated ip address (but not in the main comparison address) to decide whether to print or not. Very slow, but should finish within 1 hour on a reasonable PC.

You can remove the i=0;.

@ReleasingHeliumNuclei I thought I couldn't (a function must be re-usable), but now I realize that after the function i is 0 again...

Perl 5, 91 bytes
<>=~/^(([1-9]?|1\d|2[0-4])\d|25[0-5])\.?((?1))\.?((?1))\.?((?1))$(?{print"$1.$3.$4.$5 "})^/

The program expects a single line of a single input and outputs space-delimited list of candidates.
Explanation
The program exploits the backtracking feature of regex to loop over all possibilities of forming a valid IPv4 address from the input string.
^(([1-9]?|1\d|2[0-4])\d|25[0-5])\.?((?1))\.?((?1))\.?((?1))$

The IPv4 regex with optional ., nothing of note here.
(?{print"$1.$3.$4.$5 "})

A code evaluation expression which prints out the content of the capturing groups.
^

Make the match fails and force backtracking.
Example run
$ echo "012345" | perl G89503.pl
0.12.34.5 0.12.3.45 0.1.23.45 0.1.234.5 0.123.4.5

JavaScript (ES6), 147 141 135 bytes

f=(s,n=0)=>(a=s.split`.`)[3]?a.every(s=>s==`0`|s[0]>0&s<256)?s+' ':'':[...s].map((_,i)=>i>n?f(s.slice(0,i)+`.`+s.slice(i),i):``).join``
<input placeholder=Input oninput=o.textContent=f(this.value)><div id=o style=font-family:monospace;width:1em>Output

Edit: saved 6 bytes thanks to @apsillers. Saved another 6 bytes by copying @YOU's validity test.

is there a difference between [1-9]|0 and [0-9] or \d??

@apsillers Ah yes, an earlier version of my code could generate a trailing . which would throw the test, but I think this version is OK.

@YOU The important bit is that the 0 has a $. (It's also missing a ^, so thanks for drawing my attention to it.)

@apsillers Sadly splice doesn't work like that, it modifies the array and returns any removed elements.

Python 3, 232 bytes
import re,itertools as t,ipaddress as k
R=range
i=input()
for d in R(5):
 for p in t.combinations(R(len(i)),d):
  n=i;o=0
  for a in p:n=n[:a+o]+'.'+n[a+o:];o+=1
  try:k.ip_address(n);print(n*(not re.search(r'\D?0\d',n)))
  except:0

Pretty simple: We place periods everywhere and print if the IP address with the periods placed is valid. We check the validity of the IP adresses by (ab)using ipaddress.ip_address, which raises an exception if the input is not a valid IP address. The challenge defines some additional rules that ip_address doesn't handle (namely, that there can be no leading zeroes), so we check for those too with a regular expression, then print.
Outputs each solution on a new line, mixed with an arbitrary number of blank lines.
Example run:
$ echo 012345 | python fixip.py
0.1.23.45
0.1.234.5
0.12.3.45
0.12.34.5
0.123.4.5

$ echo 000123 | python fixip.py
0.0.0.123

_

Here's my older, 248-byte Python 2 solution. The second and third indent levels are \t (raw tab) and \t  (raw tab plus space) respectively. This plays really badly with Markdown, so the tabs have been replaced by two spaces.
import socket,re,itertools as t
R=range
i=input()
for d in R(5):
 for p in t.combinations(R(len(i)),d):
  n=i;o=0
  for a in p:n=n[:a+o]+'.'+n[a+o:];o+=1
  try:
   socket.inet_aton(n)
   if n.count('.')==3and not re.search(r'\D?0\d',n):print n
  except:0

Requires the input surrounded with quotes (e.g. "123.456.789"). Outputs each generated IP address on a new line.
Saved 9 bytes thanks to @grawity!

Would ipaddress.ip_address() be shorter than aton+manual check?

Brachylog, 110 bytes
:ef:{".",@N.|.}ac:3f:{@n:"."rz:cacb.}a.
,4yeN,?:N:6i.@nMl4,M:{:7&<256}a
~c[A:B]h:@N:Bc.
:ef:{,"0":"9"y:.m?}ac.

Try it online!

Python 3, 262 260 bytes
p,l,L,T=set(),-1,len,tuple
while l<L(p):l=L(p);p|={T(z[:i]+(y[:j],y[j:])+z[i+1:])for z in set(p)or[T(input().split("."))]for i,y in enumerate(z)for j in range(1,L(y))}
print(['.'.join(x)for x in p if L(x)==4and all(y=='0'or y[0]!='0'and int(y)<256for y in x)])

No libraries used, but late and longer, may be I am missing some obvious golfing techniques.
Results anyway.
for x in 192.168.1234 192.1681234 1921681.234 1921681234 192.168.1204 192.168.123 192.168.256 120345 012345 000123; do
echo $x | python3 ipv4.py
done;

['192.168.123.4', '192.168.1.234', '192.168.12.34']
['192.16.81.234', '192.168.1.234', '192.168.123.4', '192.168.12.34']
['19.216.81.234', '192.168.1.234', '192.16.81.234']
['19.216.81.234', '192.168.123.4', '192.168.12.34', '192.16.81.234', '192.168.1.234']
['192.168.1.204', '192.168.120.4']
['192.16.8.123', '19.2.168.123', '1.92.168.123', '192.168.1.23', '192.168.12.3', '192.1.68.123']
['192.168.25.6', '192.168.2.56']
['1.20.3.45', '1.203.4.5', '12.0.34.5', '120.3.4.5', '1.20.34.5', '12.0.3.45']
['0.1.23.45', '0.12.3.45', '0.12.34.5', '0.123.4.5', '0.1.234.5']
['0.0.0.123']

I thought I'd copy your validity test and wondered whether you need the parentheses around the or clause?

@Neil, thanks, didn't need those.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Reduce and generalize a list of string
The goal of this challenge is to reduce a list of string to a shorter more general list of string.
Input
The Input is provided with space between the string (a b c) or in list form (["a","b", "c"]). It's a list list of string that can be of the following form :

aaa
aaaX
aaaX/Y

With aaa any set of non capital alphabetic letter, and X or Y any digit between 0 and 9.
Ouput
A list of generalized string that can be separated by anything. String are of the form :

aaa
aaaX
aaaX/Y

With aaa any set of non capital alphabetic letter that were in the input list. X and Y stay the same and symbolise the digit. The goal of the challenge is to reduce the input list of string into their generic representation.
Examples
Two strings can be reduced :
Input : regex1 regex2 split1/0
Output : regexX splitX/Y

Full example :
Input : toto toto titi titi1 titi2 titi5 tutu tutu0 tutu1 tutu1/2 tutu0/1
Output : toto titi titiX tutu tutuX tutuX/Y

Another example :
Input: ["foo0","bar0","baz0/0","eth0/0","eth0/1","eth1/0","eth1/1","vlan8","modem0"]

Output: ["fooX","barX","bazX/Y","ethX/Y","vlanX","modemX"]

Scoring
This is code-golf; shortest code in bytes wins.

Can we take array of strings input, i.e. ["regex1","regex2","split1/0"]?

I'll modify the question a bit to allow it =)

You may want to put the last line elsewhere, at least not in the scoring section

It's still in the scoring section...

Is extra trailing newlines okay?

The output can be as dirty as you want, it just have to separate value with something.

Alright, noted.

Is foo1bar2 a possible input?

No, it's always a slash before the second digit if there is one.

Retina, 25 18 13 bytes
6 byte thanks to FryAmTheEggman, and for inspiration of extra 1 byte.
\d
X
/X
/Y
D`

Try it online!

Wow, Upvoted because 120 seconds to answer is so impressive !

@Pierre.Sassoulas This site has seen faster answers.

Perl, 29 27 bytes
Includes +1 for -p
Give input list as seperate lines on STDIN:
perl reduce.pl
regex1
regex2
split1/0
^D

reduce.pl:
#!/usr/bin/perl -p
s/\d/X/&&s//Y/;$_ x=!$$_++

Brachylog, 61 59 44 42 bytes
2 bytes thanks to Fatalize.

:{:ef:{~s"0123456789","X".;?.}ac.}a:{rbh"/",?rbr:"Y"c.;?.}ad.
:{:ef:{~s"0123456789","X".;?.}ac.L(rbh"/",Lrbr:"Y"c.;.)}ad.
:{s"/",?rbbbr:"X/Y"c.;.?t~s@A;?rbr:"X"c.}ad.
:{s"/",?rbbbr:"X/Y"c.|.t~s@A|rbr:"X"c.}ad.

Try it online!

Dyalog APL, 21 bytes
∪'/\d' '\d'⎕R'/Y' 'X'

⎕R regex replaces the left-side strings with the right-side ones
∪ returns the unique elements
TryAPL online!

Python, 69 bytes
import re
lambda s:set(re.sub("\d","X",s).replace("/X","/Y").split())

Javascript, 92 78 bytes
a=a=>[...new Set(a.replace(/\d/g,"X").replace(/\/./g,"/Y").split` `)].join` `;

Oh whoops... I'll go fix that

You don't need a bunch of that boilerplate, just write this as a=>[...new Set(a.replace(/[0-9]/g,"X").replace(/\/./g,"/Y").split\ `)].join` `. Also why not use \dinstead of[0-9]`?

I tried the first suggestion, JSfiddle didn't like it. I'll try it on babel.

PHP, 104 bytes
<?=join(' ',array_unique(explode(' ',preg_replace('%\d%','X',preg_replace('%\d/\d%', 'X/Y',$argv[1])))))

expects input as single argument
I could replace the join(' ',array_unique(explode(' ',...))) with preg_replace('%(\b\w+\b)(?=.*\b\1\b)%','',...), but it´s 6 bytes shorter via the array.
127 bytes for list of arguments:
<?foreach($argv as$i=>$s)if($i)$r[]=preg_replace('%\d%','X',preg_replace('%\d/\d%', 'X/Y',$s));echo join(' ',array_unique($r));

120 bytes for a function on an array:
function r($a){foreach($a as$s)$r[]=preg_replace('%\d%','X',preg_replace('%\d/\d%', 'X/Y',$s));return array_unique($r);}

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Automate the OEIS
We see a lot of challenges here asking for a function to create a sequence from the OEIS.  While these challenges are fun, as a programmer I see an opportunity for automation.
Your challenge is to make a program that takes the index of a sequence (e.g. A172141) and some integer n (e.g. 7), and pulls the appropriate value from the appropriate webpage.
I/O
As mentioned, your program should take a sequence index and some value n as input and output the nth term in that sequence. You accept any index in the sequence's B-files. If the index is greater than the largest index listed in the B-files you may throw an exception or output whatever you choose (these are not in the test cases).  Standard methods of input and output are permitted.
Restrictions on web use
You should not access any websites other than https://oeis.org and http://oeis.org.  This includes url shorteners, your own personal website, and this question itself.  If you would like to access some other website and you believe that it is not unfair to allow you to do so, you can leave a comment and I will arbitrate.
Scoring
This is a code golf challenge so the program with the least bytes used in its source code wins.  Standard loopholes are disallowed.
Test Cases
Assuming that your machine has proper internet connection and the OEIS servers are up and running the following inputs and outputs should correspond.
A172141, 7   -> 980
A173429, 4   -> 276
A190394, 6   -> 16
A002911, 11  -> 960
A052170, 3   -> 24
A060296, 8   -> 3
A178732, 5   -> 27
A000001, 1   -> 1
A000796, 314 -> 3
A001622, 162 -> 8
A002206, -1  -> 1

Tip

When accessing the B-files http://oeis.org/b<A-number>.txt will redirect to the proper B-file.

It's not clear to me up which indices we have to support. The last two test cases hint that we should query, e.g., oeis.org/A000796/b000796.txt rather than oeis.org/A000796/list. Is the fomer what you mean by B-files? In that case, mentioning the offset is rather superfluous.

@Dennis Sorry I think that was the result of multiple edits over time.  I will edit for clarity,

I think this should have spent more time in the sandbox, because I'm sure it wasn't your intention that sequences without B-files should be unsupported.

@PeterTaylor according to the OeisWiki "If no b-file has been uploaded for a particular sequence, the server generates a b-file containing exactly the terms displayed, for convenience with automated tools."  so there should be a B-file for every sequence.  Although you may be right about prematurely moving this challenge from the sandbox.

Well, I've learnt something useful today.

What is that last testcase with a negative index?

@Scimonster The list of Gregory Coefficients A002206 starts at index -1.  That would be the first item listed.

relevant tool

Bash + coreutils + w3m, 51 45 42 bytes
w3m oeis.org/b${1:1}.txt|sed "s/^$2 //p;d"

Thanks to @EamonOlive for golfing off 3 bytes!
Example run
$ bash oeis.sh A172141 7
980

How it works
w3m is a text-based web browser, which displays both HTML and plain text in readable format. Unlike curl, it follows redirects by default (this is required, since oeis.org/bxxxxxx.txt redirects to oeis.org/Axxxxxx/bxxxxxx.txt), doesn't produce any stray output to STDERR, and has a three-byte name.
The command
w3m oeis.org/b${1:1}.txt

the desired URL, where ${1:1} is the first command-line argument without its first character.
The output is piped to the command
sed "s/^$2 //p;d"

which extracts the desired output. s/^$2 //p attempts to replace ^$2  (start of line, followed by the second command-line argument, followed by a space) with the empty string. If the substitution is successful, p prints its result. Afterwards, d unconditionally deletes the pattern to prevent sed from printing the entire input.

You can save a few bytes by using oeis.org/b${1:1}.txt instead of oeis.org/$1/b${1:1}.txt

Heh, I would normally have used sed -n ..., but that would be one more character.

@Vatine With -n, the double quotes could be replaced with an escaped space, for the same byte count.

Mathematica + OEIS.m, 31
(OEISFunction@ToString@#;#@#2)&

example usage: %[A172141,36]

Mathematica, 85
#2/.Rule@@@Import["http://oeis.org/b"<>#~StringDrop~1<>".txt","Data"]~DeleteCases~{}&

example usage: %["A002206",-1]

Perl, 59 bytes
($_,$v)=@ARGV;/./;say`curl oeis.org/$_/b$'.txt`=~/$v (.*)/m

Needs -M5.010 or -E to run. For instance :
$ cat oeis.pl
($_,$v)=@ARGV;/./;say`curl oeis.org/$_/b$'.txt`=~/$v (.*)/m
$ perl -M5.010 oeis.pl A178932 5 2>&-
27

Saved 8 bytes thanks to @Dennis answer, by removing http://, as he did.

Python 3, 153 146 135 bytes
7 bytes thanks to FryAmTheEggman.
6 bytes thanks to Eamon Olive.
5 bytes thanks to Rod.
from urllib.request import*
def f(a,n):
 for l in urlopen("http://oeis.org/b%s.txt"%a[1:]):
  p,q=l.split()
  if n==p.decode():return q

Call it like this:
print(f("A000796","314"))

Run on a machine where the default is utf-8.

In my opinion requiring a string for one argument, and a byte array for another is too lenient an input format, and you should just add the bytes required to encode into bytes yourself. Nothing about this challenge makes it reasonable to require raw bytes as input.

Can’t you change A%s to %s and then the first a[1:] to a?

@orlp Alright, done.

@Lynn Yes, because apparently I'm stupid.

@FryAmTheEggman Yes and no. The default is the environment's locale.

@Dennis Right, my mistake. Adding "run on a machine where the default is utf-8" should make it valid.

the "http://oeis.org/%s/b%%s.txt"%a%a[1:] can be shortened to "http://oeis.org/b%s.txt"%a[1:].

You don't need the variable "d", you can iterate over the urlopen itself.

Python 2, 125 118 113 bytes
7 12 bytes saved thanks to Lynn
import re,urllib2 as u;lambda x,y:re.findall("(?<=%d ).*"%y,u.urlopen("http://oeis.org/b%s.txt"%x[1:]).read())[0]

Well heres my go at my own problem. It is likely suboptimal but I think I did a pretty decent job. It creates an anonymous function that takes a string and integer as arguments and returns a string as the result or throws an error if the index is out of range.
This can be made into a 124 bytes full program.
import re,urllib2 as u;print re.findall("(?<=%d ).*"%input(),u.urlopen("http://oeis.org/b%s.txt"%raw_input()[1:]).read())[0]

This prompts the user for the input.  First asking for the index and then the A-number of the sequence.

Some tiny saves: import re,urllib2 as u;lambda x,y:re.search("%d (.*)\n"%y,u.urlopen("http://oeis.org/b%s.txt"%x[1:]).read()).group(1)

And lambda x,y:re.split("%d (.*)"%y,u.urlopen("http://oeis.org/b%s.txt"%x[1:]).read())[1] is shorter still!

CJam, 36 bytes
"oeis.org/b"r1>+".txt"+gN%Sf%z~\ra#=

Example run
$ cjam oeis.cjam <<< 'A172141 7'
980

R, 94 89 bytes
t=read.table(paste0("http://oeis.org/b",substring(scan(,""),2),".txt"));t[t$V1==scan(),2]

Using sprintf instead of paste0 results in the same bytecount:
t=read.table(sprintf("http://oeis.org/b%s.txt",substring(scan(,""),2)));t[t$V1==scan(),2]

Five bytes saved thanks to plannapus.

Too bad you can library(stringr) for free and use str_sub for -2 bytes ^^

@AlexR I don't think I can import a library for free ;-)

Oops, there was a typo in my comment -- Too bad you can't. It was just a first thought for golfing, because stringr is one of my default packages loaded in the .Rprofile of all my projects.

You don't need to use url, argument file of read.table can be the URL as a character string.

@plannapus Indeed, that's right. Thanks!

PHP 5.6, 93 92 bytes
function f($i,$l){echo explode(' ',file('http://oeis.org/b'.substr($i,1).'.txt')[--$l])[1];}

This one is pretty straight forward. Pull the page with file(), get the line at $line - 1 (0-index), explode on the space and print out the second array element from that.

Nim, 123 115 113 bytes
import httpclient,nre,future
(a,n)=>get getContent("http://oeis.org/b"&a[1..^0]&".txt").find re "(?<="&n&r" )\d+"

This is a lambda expression; to use it, it must be passed as an argument to a testing procedure. A complete program that can be used for testing is given here:
import httpclient,nre,future
proc test(x: (string, string) -> RegexMatch) = echo x("A172141", "7") # Your input here
test((a,n)=>get getContent("http://oeis.org/b"&a[1..^0]&".txt").find re "(?<="&n&r" )\d+")

Expects input as two strings. Example usage:
$ nim c oeis.nim
$ ./oeis
980

We use httpclient's getContent proc to get the OEIS b-file, then use a regex to find the line with the index. find returns an Option[RegexMatch], so we use get to retrieve the value from the Option. echo automatically stringifies, so we leave stringification out.

R, 87 bytes
f=function(A,n)(R<-read.table(gsub("A(\\d+)","http://oeis.org/b\\1.txt",A)))[R$V1==n,2]

Build the URL string with regexes instead of paste or sprintf.

Clojure, 103
#(read-string((re-find(re-pattern(str %2" (\\d+)"))(slurp(str"http://oeis.org/b"(subs % 1)".txt")))1)))

re-find finds a vector of first matche's regex groups, it is used as a function and 1 gets the string at position 1. read-string converts string to int. I'm not 100% sure if this regex always finds the correct row.

Node.js + request, 109 bytes
x=>n=>require('request')(`http://oeis.org/b${x.slice(1)}.txt`,(a,b)=>console.log(b.body.match(n+` (.+)`)[1]))

Takes the sequence ID and a number.

Julia, 88 bytes
x\y=match(Regex("$y (.*)"),readall(Requests.get("http://oeis.org/b$(x[2:end]).txt")))[1]

Golfed with some help from @Dennis!
Make sure you have Requests.jl installed before running.

ListSharp, 266 bytes
STRG a=READ[<here>+"\\a.txt"]
ROWS x=ROWSPLIT a BY [","]
STRG a=GETRANGE x[0] FROM [2] TO [a LENGTH]
NUMB y=<c#int.Parse(x[1])c#>
STRG a=DOWNLOAD["http://oeis.org/b"+a+".txt"]
ROWS x=ROWSPLIT a BY [<newline>]
STRG a=GETLINE x [y]
ROWS x=ROWSPLIT a BY [" "]
SHOW=x[1]

Its sad when a language made for web scraping needs so many lines because nesting statements in ListSharp is taboo

05AB1E, 29 bytes
¦’ÏÁ€ˆ.µÔ/bÿ.í¼t’.w¶¡€#˜DIk>è

Beats all other answers.
¦’...’.w¶¡€#˜DIk>è  # trimmed program
                 è  # 0-based...
               k    # 0-based index of...
              I     # input...
               k    # in...
            ˜D      # flattened list of...
      .w            # content of response from url...
                    # (implicit) "http://" concatenated with...
 ’...’              # "oeis.org/bÿ.txt"...
                    # (implicit) with ÿ replaced by...
                    # implicit input...
¦                   # excluding the first character...
         ¡          # split by...
        ¶           # newlines...
          €         # with each element...
           #        # split by spaces...
                >   # plus 1...
                 è  # th element in...
            ˜       # flattened list of...
      .w            # content of response from url...
                    # (implicit) "http://" concatenated with...
 ’...’              # "oeis.org/bÿ.txt"...
                    # (implicit) with ÿ replaced by...
                    # implicit input...
¦                   # excluding the first character...
         ¡          # split by...
        ¶           # newlines...
          €         # with each element...
           #        # split by spaces

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Dyalog's International Problem Solving Competition (Phase I) – Code Golf Edition
Every year, Dyalog Ltd. holds a student competition. The challenge there is to write good APL code. However, this is a multiple-holes (common theme is manipulation of data of any type and structure, especially special handling of empty data) code-golf version of the Phase I problems – open to any language. Enjoy!
Objective
Write ten complete programs (or functions, etc.) to solve the below problems using any one language. The point is that you must select a language that is good at various tasks, as opposed to the common golfing strategy of choosing the right tool for the (single) task. You may not use one solution as subroutine in another solution, and your score is the total byte count of all ten programs together.
Passing all the test cases is sufficient to be a valid submission.
Closing Date
18 August 2016.
Related: possibility of real world prizes
If you chose to use Dyalog APL (free download), you may also want to participate in the original competition, but note that the objective there is to submit quality code – not necessarily short code. If you are a student, you can win USD 100 for Phase I. Phase II (not included here) can win you up to USD 2000 and a free trip to Scotland.
The problems
Problem 1 – Statistics - Mean
Write a program that takes a numeric array and gives the mean (average) of the array.
Test cases:
[1,2,3,4,5,6] → 3.5
[] → 0
17 → 17
[[1,2,3,4],[5,9]] → 4
Problem 2 – Statistics - Median
Write a program that takes numeric data and gives the median of the data. The median is the number separating the higher half of the data from the lower half. The median can be found by arranging all the observations from lowest value to highest value and picking the middle one. If there is an even number of observations, then there is no single middle value; the median is then defined to be the mean of the two middle values.
Test cases:
[1,2,3,4,5,6,7,8,9] → 5
[[1,8,2],[7,3,6,4,5]] → 4.5
[] → 0
7 → 7
[1,1,1,9,1] → 1
[1,3,9,1] → 2
Problem 3 – Statistics - Mode
Write a program that takes a numeric list and gives the mode, most common value, of the list. If more than one number occurs the greatest number of times, return all such numbers.
Test cases:
[2,2,1,4,3,2,5,1,2] → 2 or [2]
[] → []
[1,2,3,4,1,2] → [1,2]
Problem 4 – Just Meshing Around
Write a program that takes strings or two numeric lists and gives the inputs shuffled into a string/list formed by alternately taking successive elements from each input. (This is known as a Faro shuffle.) The inputs do not have to be the same length. Begin with the first input.
Test cases:
'MENS' 'EKES' → 'MEEKNESS'
'Dyalog' 'APL' → 'DAyPaLlog'
'APL' 'Dyalog' → 'ADPyLalog'
[1,3,5,7] [2,4,6,8] → [1,2,3,4,5,6,7,8]
'' 'Hello' → 'Hello'
'Hello' ''→ 'Hello'
'' '' → ''
Problem 5 – You're Unique, Just Like Everyone Else
Write a program that takes a list or string and gives elements or characters that occur only once in the input.
Test cases:
[1,2,3,4,5] → [1,2,3,4,5]
[1,2,3,4,5,4,3,2,1] →[5]
'hello world' → 'he wrd'
'aabbcc' → ''
'' → ''
Problem 6 – Shorter Ones to the Front
Write a program that takes a list and sorts it by the length of each element. Note: an element of the list can be single number, in which case it must be counted as length 1.
Test cases:
['one','two','three','four','five','six'] → ['one','two','six','four','five','three']
[[2,4,3],[4,5],1,[7,3]] → [1,[4,5],[7,3],[2,4,3]] (sorting is not necessary)
[] → []
[[],[2,2],1] → [[],1,[2,2]]
Problem 7 – 3's and 5's
Write a program that takes a numeric list and returns all elements that are divisible by 3 or 5.
Test cases:
[1,2,3,4,5,6,7,8,9,10] → [3,5,6,9,10]
[] → []
[-1,-2,-3,-4,-5,-6,-7,-8,-9,-10] → [-10,-9,-6,-5,-3] (sorting is not necessary)
Problem 8 – Separating Out the Negative
Write a program that takes a numeric list and gives a two element list whose first element contains the values less than 0 (zero) in the input and the second element contains all values greater than or equal to 0 (zero).
Test cases:
[0,1,-2,3,-4,-5,6,7,8,-9,10] → [[-2,-4,-5,-9],[0,1,3,6,7,8,10]]
[1,2,3,4,5] → [[],[1,2,3,4,5]
[-1,-2,-3,-4,-5] → [[-1,-2,-3,-4,-5],[]]
[] → [[],[]]
Problem 9 – Delimited Text
Write a program that takes two strings where the first string is delimiters in the second string. The program should give the delimited text as a list of strings.
Test cases:
',' 'comma,delimited,values' → ['comma','delimited','values']
' ' 'break up words' → ['break','up','words']
',' ',' → ['','']
',' 'hello world' → ['hello world']
',' '' → ['']
',;' 'multi,delimited;values' → ['multi','delimited','values']
Order Total
Write a program which takes list of prices and a list which indicates the count ordered of each corresponding item and gives the total cost for the order.
Test cases:
[2.99,4.99,1.99] [5,0,2] → 18.93
[2.99,4.99,1.99] [0,0,0] → 0
[123.00] [0] → 0
[2.00 0.00] [3,4] → 6
[] [] → 0

I have explicit permission to post this challenge here from the original author of the competition. Feel free to verify by following the provided link and contacting the author. I gave the original competition author the link to this page within the minute I posted it, so they can check if I submit someone's answer as my own.

Multi-part challenge and duplicates...

@LeakyNun The point is that you must select a language that is good at various tasks, as opposed to the common golfing strategy of choosing the right tool for the (single) task.

@LeakyNun common theme is manipulation of arrays of any type

Really? Nested array and non-array in Task 2?

@LeakyNun Yep. That's part of the challenge to handle multiple structures.

In some of your test cases, the input is not an array. Also, for at least the first couple, the expected output is 0 for an empty array, which is mathematically inaccurate, IIRC(Should be undefined, I think).

@Jeremy I never stated that it had to fit with mathematics. I provided the specific test cases to cover edge cases like that.

@Jeremy What would be a more appropriate term for data of any structure, of array isn't good?

@Adám I would just refer to it as numeric data. Calling [[1,2,3],[4,5]] an array is confusing

The consensus so far has been that multiple unrelated tasks are off-topic

@Jeremy Done as you typed :-)

@DJMcMayhem As the author said in a previous comment, and in the post itself, the challenges are related by a common theme.

@LeakyNun Typo. Fixed. Sorry.

I've written in an additional connection between the problems: Special handling of empty input is required in all sub-problems.

The challenges all say "Write a program..." Must each solution be a complete program (rather than, say, a function that returns an array or string)? What are the rules for input/output?

@Jordan Write ten complete programs (or functions, etc.)

10/10 your array format that is half APL and half Python has made it useful in neither APL nor Python.

@Jordan I intentionally was not specific about input, as that is then left to the PPCG defaults, as widely discussed in meta.

@LeakyNun You want commas?

@Adám Requiring the mean and median of [] to return 0 seems arbitrary. Something like NaN would make more sense. Also, I fail to see what the common theme to all tasks is

Each challenge is poorly specified, as a result of having a multi-part challenge.

@LeakyNun You've got commas (ouch). What's unclear?

NOTE: I've spent half an hour fixing things. I'll take a break now for an hour, and then I'll be back to answer/fix more issues.

@Adám If I wrote a list of what's unclear it would take me a day.

@LeakyNun Not so clear that you couldn't answer...

@Adám I only aimed to pass all test-cases.

@LeakyNun I thought hard about the test cases. If you pass them, then you're fine.

Does not make the specs clear.

@LeakyNun What if I include that?

If I create 10 different functions as my answer, would it be possible for me to share include (or its equivalent) between the functions (i.e. have them exist in the same program/file)?  Or do I need to duplicate the include for each function that uses it?

@StevenH. They need to stand alone.

Does the mean challenge need to accept 2d arrays too? im slightly confused

@downrep_nation Yes, as in the last test case.

@Rainbolt, Adám, If there is no sort of interaction between the individual parts, a common theme is no sufficient relation to justify a multi-part challenge. For the full reasoning, see the meta post linked by DJMcMayhem. There is no good reason not to split this into multiple challenges.

I'm closing this question as off-topic because it consists of multiple independent sub-challenges.

@MartinEnder Would you suggest splitting or do you think that would just give rise to 10 closed-as-duplicates?

@Adám At a quick glance I'm pretty sure we've already done a few of them (which is exactly why these multi-part challenges are disallowed), you could check if some of them are new though and post those.

FWIW; I think some of the individual challenges really deserve posting

@MartinEnder How is this?

@LuisMendo Most are incorporated here.

Pyth, 88 86 84 bytes
Problem 1: Mean (6 bytes)
.O.n]Q

Test suite.
Problem 2: Median (23 21 bytes)

.O,hJ.x.<S*2K.n]QlK]0eJ
.O<.x.<S*2K.n]QtlK]02

Test suite.
Problem 3: Mode (7 bytes)
{.x.M/Q

Test suite.
Problem 4: Interleave (3 bytes)
.iF

Test suite.
Problem 5: Unique (7 bytes)
fq1/QTQ

Test suite.
Problem 6: Sort (6 bytes)
ol.n]N

Test suite.
Problem 7: Divisibility (10 bytes)
f!*%T3%T5Q

Test suite.
Problem 8: Separate (10 bytes)
,Jf<T0Q-QJ

Test suite.
Problem 9: Split (12 bytes)

AQu.ncRHGG]H
u.ncRHGQ]E

Test suite.
Problem 10: Dot-product (4 bytes)
s*VF

Test suite.


text:
Input ∩ Source Code
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

May the output contain duplicate characters?

@DigitalTrauma From examples #1, #2 and #3 it appears not

@DigitalTrauma Sorry for the ambiguity, sets (in the mathematical sense) ignore order and have no repetition.

Is a trailing newline acceptable when printing the output?

@Dennis Yes, a trailing newline is acceptable.

Congratulations for coming up with a generalised quine where the best solutions are not based on the language's standard quine. :)

If a set should not have repetition, shouldn't the input sets also not contain repetition? Or is the input actually not a set?

@user81655 When I said "Let I be the input set" I meant that I is the set of the input not that the input is a set

Are sets typically ordered or not? that is, does the order of the output matter?

@cat Sets are unordered so the order of the output does not matter.

TBH, the definition of "set" is not ambiguous in any way.

@Andrea I'm sorry, did you mean the English definition is unambiguous or the mathematical definition? :P

Are they different? A set is an unordered collection of non repeating elements. The problem defined in the Q was clear before adding the clarification. :) Especially for people who write code which are expected to know the definition of a "set" in any programming language.

@AndreaLazzarotto The duplicate knives in my 40-piece silverware set beg to differ...

@NonlinearFruit eheh... That is another kind of set that has nothing to do with math or programming. I guess a Hollywood movie set could beg to differ as well. :)

Jelly, 10 6 bytes
“Ṿf”Ṿf

Try it online!
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.

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)

'eroticpuns\()&\'' is shorter than adding the strings. (escaped the ' but then you need a additional \\) Why is the dot there?

woops, the . was a relic from less golfed code. Using backslash doesn't work because then the output from \\ is \\\, and duplicating the input character isn't allowed, I think.

Your lambda is missing the :.

Thanks @Dennis. My eyes start clouding over after trying to find all the characters in the program ;)

@KarlKastor is that letters configuration really random?
@Jeremy Am I missing something or c and o aren't needed in the first set?

thjx @Dada! The reason I've had these random chars still in there is because my first crack used set.intersection instead of the ampersand.

@KarlKastor ahah, you're pretty good at that. Not sure if it's really appropriate on SE/PPCG tho

@Dada: If you'd prefer, it could be inspectour, nicestupor, poeticurns, nopictures, recountspi, or inputscore. Or for the new one you might use prunesit (an accurate description of what code golfers do!), ipunster, or nursepit among others.

You can get down to 40 with set unpacking print({*'''printu()&'{}*'''}&{*input()}).

Or 36 with a lambda lambda a:{*''' lambda&':{}*'''}&{*a}.

@MorganThrapp thanks! That's quite a significant improvement, I don't feel it's right for me to take credit for it.

@Jeremy Up to you. It's the same algorithm, which is usually what I use to determine if I feel okay with taking a suggestion or not.

With implicit string concatenation, you can take out both of the +s: print(set("printseu()&'"'"')&set(input())). If you put two string literals next to each other, they're concatenated: "here and " 'there' == 'here and there'

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).
TryAPL online!

GolfScript, 6 bytes
"`&"`&

Try it online!
How it works
        # (implicit) Push the input on the stack.
"`&"    # Push the string '`&' on the stack.
   `    # Inspect; turn the string into '"`&"'.
     &  # Perform set intersection.

So that's how you can get quotes into the string without having to add backslash.

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")

Doesn't $*PROGRAM access the source code of the program, and thus violate the rules?

@celtschk I should have re-read the question before posting, fixed. ( Technically the compiler could see that $*PROGRAM is read from and store the entire source as a string in the compiled program, which would have put it into a grey area )

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))

I like this, but it returns two backslashes on \\\ instead of just one.

Also, i think you can save a byte by changing the name of the lambda to a

@Jeremy Thanks for tip, '\\' is just Python's way of representing a backslash in string form, because a single one would escape the end quote, so you have to escape the backslash with a backslash to make it work. Type print '\\' and you'll see that it is just the representation for one backslash.

You can get to 36 with lambda a:{*''' lambda&':{}*'''}&{*a}.

@MorganThrapp 35 lambda a:{*' lambda&\\\':{}*'}&{*a}

@MorganThrapp: Which Python version are you using? Even in Python3 i get a SyntaxError: invalid syntax

It only works in 3.5 and on.

MATL, 8 bytes
'X&'''X&

Try it online!
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

Actually, 6 bytes
`∩è`è∩

Try it online!
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

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);}

Try it on ideone.

An ungolfed version and/or explanation would be great!

You could have used sizeof a instead of strlen(a) for one byte saved, but even better is to give the array a known size: a[99]="...", and replace strlen(a) by 99 to shave off 5 bytes.

Another 3 or 4 bytes can be saved by replacing (i=getchar())>=0 with read(0,&i,1). This works on little-endian machines. i is initialized to 1 if you don't run the program with any arguments. If you want it to work on big-endian machines as well, remove i from the argument list of main() and declare it inside the body as a char (but then you save only 3 bytes). read() conveniently returns 0 on EOF.

Haskell (30 bytes)
This is such a boring solution... But I couldn't do better. :(
filter(`elem`"f(term)\"i`l\\")

Brachylog, 23 bytes
:{e.~e":{}e~\"fd\."}fd.

Try it online!
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 ")

Can you have a look at our chatroom?

+1 for moustache man :{ and surprised moustache man :{}

05AB1E, 11 bytes
Code:
"'ÃJÙ"'"JÃÙ

Uses the CP-1252 encoding. Try it online!.

Pyth, 9 8 bytes
1 byte thanks to Sp3000
@Q"\Q@\"

Try it online!
@Q"\Q@\"
@Q"\Q@\""   implicit string ending

@Q           intersect the input with
  "\Q@\""   the string containing '\', 'Q', '@', '"'.

@z"z\"@ is 1 byte shorter.

@drobilc That would miss out the \.

oh, yeah, totally forgot about that.

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-]

Try it online!

Don't you only need one grep command?

@GeoffReedy The first grep command splits the input into one character per line.

Right but couldn't the -o be put on to the second grep

You're right, and that saves having to check for the '.'. Thanks!

grep -o '[] [|\'\'greposrtu-]|sort -u should work.

Is there something wrong with my suggestion? It seems to save 2 bytes over your current approach.

@Titus I'm not sure what you mean.

Your expression contains backslashes. Are backslashes matched in the filtering process?

@Titus After BASH does it's thing, grep gets -o and [] [|\'grepouniq-]. So it is looking for anything of these: [ ] {space} [ | {slash} ' g r e p o u n i q - ].

@Titus does that help?

why uniq is used? uniq filters only adjacent matching lines (if sorted for example)

I'm not sure why I had uniq. Input will only have 1 of each character (because it's a set), so I don't need remove duplicates. Thanks!

CJam, 8 bytes
"`q&"`q&

Try it here.
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.

C#, 36 bytes
s=>s.Intersect("s=>.Interc(\"\\);");

Intended cast is Func<string, IEnumerable<char>> (string input, IEnumerable<char> output).

@Kobi Intersect enumerates first, collecting all distinct elements of that sequence. It then enumerates second, marking those elements that occur in both sequences.. second is already distinct therefore Intersect will return only distinct elements.

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].

Retina, 21 20 bytes
Removes characters not in the source code, then removes duplicate characters.
[^Ds.n\n[-a_-]

Ds`.

Try it online

Your source code contains a linefeed (your output doesn't).

I had basically the same solution earlier but forgot to post it. You can save a few bytes with the range [-a (and then include an underscore and a hyphen and drop the backtick on the second line). But for future reference, ] wouldn't need escaping if you put it as the first character. Oh and for niceness, you can swap the two stages to avoid the trailing linefeed.

@MartinEnder This still doesn't deduplicate line feeds, is that a problem?

Oh you're right, I didn't notice that. You'll have to add s to the options of D and the character class then.

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

Backslash is in your code but doesn´t seem to be in your string.

Isn't it the third?

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.

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.

f=s=>[...new Set(f+'')]... could save bytes.

Or even shorter: f=s=>[...s].filter(c=>(new Set(f+'')).has(c))

@user81655 At least in Firefox, f+'' works by reading f's source code. (In certain cases you could get Firefox to crash by changing the source file and then attempting to stringify a function loaded from it.)

@user81655 Your second example fails when s has repeated elements, and indexOf is shorter than new Set anyway.

In that case, you could try saving chars (like changing the c parameter to a character that is already in the list).

As far as I'm aware, the input set follows the same set rules (no duplicates).

@user81655 Thanks for that c tip, but check the test cases for duplicates, I think you might find some.

Ah, that's interesting. The comments clarifying that a set does not contain duplicates seem to contradict the test cases. If the input is in fact a set, you could even take it as a Set then do s.has(c) inside the filter. You can change the s to another character as well by the way.

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.

Which version of sed is this? GNU sed says sed: -e expression #1, char 47: unterminated `s' command.

43 bytes including 1 for -r: sed -r ':;ss[^][str().*\12;:^]ss;ss(.)(.*\1)s\2s;t'    i wrote it before noticing yours and it turned out to be very similar

@Dennis fixed; turned out having a : after the [ caused it to try and parse a character class

@izabera nice, I'm quite surprised that the : command doesn't actually need a label and that it changes the meaning of t without a label

yeah it's a gnuism

Hm, that works well for a single line, but it breaks if there's more than one.

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),')

You should've used an anonymous function...beat you by 5 bytes

Hehe, I guess that wasn't my best golf...

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.

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.

If jsfk is the language, you should use that in the header instead of Javascript.

@NonlinearFruit jsfk is a programming style. It is valid javascript

q (38 bytes)
Reads from stdin
"readint0\\\" "inter read0 0

edit: was missing backslash

I'm not familiar with q, could you add a link?

sure, http://code.kx.com

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.

you haven't visited the site in almost a year, but f=function(s)cat(instersect(strsplit(s,"")[[1]],strsplit("f=unctio(s)aerpl,\\\"[1]","")[[1]]),sep="") is 101 bytes, and I think the I/O format can be simpler, without cat...

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

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

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.

Rename in to be a single letter like a

@NonlinearFruit you're right :O how could I forget about that?!

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

Pyth, 6 8 Bytes
{@"{@\"\

Expects input as a string.
Try it online!
Explanation:
 @     Q    Intersect implied input with:
  "{@\"\     The string containing {@"\
{          and then remove duplicates.

Unfortunately, that doesn't remove duplicates.

Fixed!  Unfortunately, that costs two additional bytes, tying it with the other Pyth answer.

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').

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:
Try it here.
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

Brachylog (newer), 18 bytes
{∈"{∈\\\"&}ˢd"&}ˢd

Try it online!
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.

Perl 6, 38 bytes
<say .comb∩$*IN.comb#<>~EVAL>~~.EVAL

Try it online!
The generalised quine still manages to beat out  the trivial program by a few bytes
Perl 6, 41 bytes
say <$*. <>INabcmosy∩>.comb∩$*IN.comb

Try it online!

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

Python 3, 33 bytes
lambda a:{*"\"\lambd* :{}&"}&{*a}

Try it online!

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)\&\"")

Is this 40 bytes?

doesn't work for input \\

@Jeremy You're right, I forgot to update that. It's 47.

@KarlKastor Fixed

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.

Java (OpenJDK 8), 58 bytes
s->s.filter("s->.filter(\"\\:cona)d"::contains).distinct()

Try it online!
Accepts the input as Stream<String>, whereas each character of the input is a stream element, and returns a filtered, distinct stream.

Japt, 14 15 bytes
My very first "proper" quine. At long fecking last!
oQ+"oQ+ ¬â"Q ¬â

Try it

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)

Try it online!

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

Try it online!

It's easier to see where your code ends and the explanation begins if you put the explanation in a separate programming puzzle. Also, consider adding a try it online link to your answer so that users can test your submission. Besides that, great first post and welcome to PPCG!

Husk, 7 bytes
n"n\\\"

Try it online!
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:'

Try it online!
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

Try it online!
u          Without duplicate elements,
 n         the intersection of
  s        the string representation of
   "nsu    the string n, s, u
           with the input.

Burlesque, 10 bytes
#QupIN#Qvv

Try it online!
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

@a'_' Do you mean because it produces an extra ""? If so, then adding a "Q" cures it. Try it online!

brainfuck, 150 bytes
,[[>+>+<<-]>>[-[->>+<<]+>>]+>+[--<[-<<]>.>+>[-]]-<[-<<]>[-]<,] !"#$%&'()*/0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\^_`abcdefghijklmnopqrstuvwxyz{|}~

Try it online!
Support 32-126
main code(set remove dup) 62