text:
Exit code string output
You must write a program or function that, when given a nonempty string S of N printable ASCII characters†, outputs a program that will exit with exit code C, where C is the ASCII codepoint at position 0 in S. This program you write will additionally output a program P, such that, when run, it exits with exit code C′, where C′ is the ASCII codepoint at position 1 in S. Program P will output another program P′. This process repeats until there are no characters left in S. After this is done, you must output nothing, followed by an optional newline; and should exit with exit code 0.
†The characters between 0x20 and 0x7e inclusive.
Some more rules:

Self-modifying programs are not allowed: you must output the source to STDOUT (or, return value initially)
You may not read your own source code.

The shortest such program in bytes will win.
For some rudimentary testing, this ruby script can be used. (The first argument is the way you invoke the script, the second is the program, and the third is the input string.)
Hypothetical Example
Say the program is FOO. When given the string "ABC", it outputs BARA. This program exits with code 65 and outputs BARB. This in turn exits with code 66 and ouputs BARC. This program exits with code 67 and outputs BAR!. This outputs nothing, and exits with code 0.

Would doing this count as exit codes in Forth? Change the parameter to see other OS errors. 0 is Success. https://tio.run/nexus/forth-gforth#@2@lkFpUpGBqaKSgrZCXmp5YkqpQklGUX65gzWVobACS/P8fAA

@mbomb007 I don't know much about Forth. Is that how one would conventionally use an "error code" in Forth?

It depends if your goal is to have OS-level error codes. If only the number matters, you can just do something like 33 throw to throw an arbitrary number. You use negatives for OS-level, and the offset is -512. Idk much either, but I'm looking here: https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Exception-Handling.html

Python 2, 126 101 94 bytes
In the process of making this, I found that Python code may not contain literal NUL bytes.
lambda i,s='''i=%r;s=%r
try:print s%%(i[1:],s,i[0])
except:0
exit(ord(%r))''':s%(i[1:],s,i[0])

Try it online (shows the exit code in the Debug info)

Note that each of the non-empty programs below has a trailing linefeed.
For input Hello, the above outputs:
i='ello';s='i=%r;s=%r\ntry:print s%%(i[1:],s,i[0])\nexcept:print s%%(0,s,"\\0")*(i>0)\nexit(ord(%r))'
try:print s%(i[1:],s,i[0])
except:0
exit(ord('H'))

which prints
...
which prints
i='o';s='i=%r;s=%r\ntry:print s%%(i[1:],s,i[0])\nexcept:print s%%(0,s,"\\0")*(i>0)\nexit(ord(%r))'
try:print s%(i[1:],s,i[0])
except:0
exit(ord('l'))

which prints
i='';s='i=%r;s=%r\ntry:print s%%(i[1:],s,i[0])\nexcept:print s%%(0,s,"\\0")*(i>0)\nexit(ord(%r))'
try:print s%(i[1:],s,i[0])
except:0
exit(ord('o'))

which prints nothing (the empty program)

which prints nothing and exits with code 0.

Python 3, 77 bytes
p='exit(0)'
for c in input()[::-1]:p='print(%r);exit(ord(%r))'%(p,c)
print(p)

This code takes input from STDIN and outputs the first program to STDOUT.
If the input is ABCDE, the results are
 0 print('print(\'print(\\\'print("print(\\\\\\\'exit(0)\\\\\\\');exit(ord(\\\\\\\'E\\\\\\\'))");exit(ord(\\\\\\\'D\\\\\\\'))\\\');exit(ord(\\\'C\\\'))\');exit(ord(\'B\'))');exit(ord('A'))
65 print('print(\'print("print(\\\'exit(0)\\\');exit(ord(\\\'E\\\'))");exit(ord(\\\'D\\\'))\');exit(ord(\'C\'))');exit(ord('B'))
66 print('print("print(\'exit(0)\');exit(ord(\'E\'))");exit(ord(\'D\'))');exit(ord('C'))
67 print("print('exit(0)');exit(ord('E'))");exit(ord('D'))
68 print('exit(0)');exit(ord('E'))
69 exit(0)
 0

where each line contains the exit code and the output of the previously executed program (the first line is the first program).

Your answer is like mine... just that you did it in the opposite direction... I'm facepalming myself for that.

67 bytes

@LeakyNun yeah, but I did not use your answer as a starting point, if that's what you mean

I'm just saying I should have thought of that.

@vaultah You going to golf yours to 67 bytes, or should I post it as a separate answer?

Python 3, 115 108 100 bytes
i=input()
r="%s"
k=""
for c in i:r%="print(%s\"%%s%s\");exit(%i)"%(k,k,ord(c));k+=k+"\\"
print(r%"")

Try it online!

For the input Hello, the program prints:
print("print(\"print(\\\"print(\\\\\\\"print(\\\\\\\\\\\\\\\"\\\\\\\\\\\\\\\");exit(111)\\\\\\\");exit(108)\\\");exit(108)\");exit(101)");exit(72)

The program above prints:
print("print(\"print(\\\"print(\\\\\\\"\\\\\\\");exit(111)\\\");exit(108)\");exit(108)");exit(101)

and exits with code 72.
Try it online!

The program above prints
print("print(\"print(\\\"\\\");exit(111)\");exit(108)");exit(108)

and exits with code 101.
Try it online!

The program above prints:
print("print(\"\");exit(111)");exit(108)

and exits with code 108.
Try it online!

The program above prints:
print("");exit(111)

and exits with code 108.
Try it online!

The program above prints nothing and exits with code 111.
Try it online!

The empty program prints nothing and exits with code 0.
Try it online!

A TIO link for the empty program? That's dedication for you!

Python 2, 67 bytes
Based on this answer, but modified to use Python 2, with a trivial program 0 to print nothing and exit.
p=0
for c in input()[::-1]:p='print %r;exit(ord(%r))'%(p,c)
print p

Try it online

C, 156 bytes
char*s="char*s=%c%s%c;n=%d;char*t=%c%s%c;main(){n<strlen(t)&&printf(s,34,s,34,n+1,34,t,34);return t[n];}";main(i,t)char**t;{printf(s,34,s,34,0,34,t[1],34);}

Try it online! (Open the debug-tab to see the exit code.)
Takes input as a command line argument.
For input "ABC", this outputs the program
char*s="char*s=%c%s%c;n=%d;char*t=%c%s%c;main(){n<strlen(t)&&printf(s,34,s,34,n+1,34,t,34);return t[n];}";n=0;char*t="ABC";main(){n<strlen(t)&&printf(s,34,s,34,n+1,34,t,34);return t[n];}

which returns 65 and outputs
char*s="char*s=%c%s%c;n=%d;char*t=%c%s%c;main(){n<strlen(t)&&printf(s,34,s,34,n+1,34,t,34);return t[n];}";n=1;char*t="ABC";main(){n<strlen(t)&&printf(s,34,s,34,n+1,34,t,34);return t[n];}

which returns 66 and outputs
char*s="char*s=%c%s%c;n=%d;char*t=%c%s%c;main(){n<strlen(t)&&printf(s,34,s,34,n+1,34,t,34);return t[n];}";n=2;char*t="ABC";main(){n<strlen(t)&&printf(s,34,s,34,n+1,34,t,34);return t[n];}

which returns 67 and outputs
char*s="char*s=%c%s%c;n=%d;char*t=%c%s%c;main(){n<strlen(t)&&printf(s,34,s,34,n+1,34,t,34);return t[n];}";n=3;char*t="ABC";main(){n<strlen(t)&&printf(s,34,s,34,n+1,34,t,34);return t[n];}

which outputs nothing and returns 0.

@mbomb007 Thanks, it's fixed now (and it got shorter in the process).

Gotta love it when that happens.

RPL, 73 bytes
With hp8 code page.
Turn on your HP48 or similar, or fire droid48. Do not forget to -52 SF for better visualization of the stack.
I assume you have already pushed the string, e.g. "ABC", on the stack. Then key in the following function:
→ x«{LAST}x{DUP NUM 3ROLLD 2OVER SIZE DUP{SUB 2SWAP PUT}{4DROPN}IFTE}+ +»

(For convenience I suggest to push the α key twice before typing anything, hence locking alpha input mode. Latter just use the DEL key to cancel the automatically inserted closing delimiters. Simply use the ENTER key to validate. Do not forget the space after the stab operator.)
This function immediately pushes on the stack a self-modifying program, under the form of a list. (But the function above does not modify itself). As the L in RPL originally stands for LISP, pressing the EVAL key will indeed evaluate this program. It returns the exit code on stack level two, and leaves itself, modified (yes, here it is questionable), for a latter EVAL. So press EVAL repeatedly until the program finally stops to drop itself on stack level one. The final exit code 0 thus appears on level one, with past exit codes above. If you forgot to -52 SF, you can navigate in the stack after each EVAL by pressing the ▴ key (leave this navigation mode with the ON key). The above function does accept strings with 0x0 chars inside, to create such strings 0 CHR and + are your friends. The self modification consists of removing the used char from the embedded string (the SUB 2 SWAP PUT branch). Hence the dropped program is shorter after each EVAL. The 4 DROPN branch ensures the output nothing instruction from the OP is respected, dropping among others the program itself. Of course all this assumes your note a -55 SF adept. Users of -55 SF shall be banned. Forever.
I assume an RPL/2 solution exists, and could feature a real unix exit code, but afaik RPL/2 has limited introspection, and cannot evaluate lists.

I don't think using self-modifying code counts as a valid quine according to our consensus, since it has access to its own source code. I'll ask the OP in a comment. See related meta posts: What counts as a proper quine?; Does using SMBF count as a cheating quine? <- this one is the one that applies

Only the generated program is self-modifying, not the function that answers the challenge. But I agree, this is questionable !  Added some edits to highlight this.

PowerShell, 172 156 bytes.
param($i)
$s=@'
if($i='{0}'){{
$s=@'
{1}'@
$s-f($i-replace'^.'-replace"'","''"),"$s`n"
$host.setshouldexit($i[0])
}}
exit
'@
$s-f$i.replace("'","''"),"$s`n"

The h3l}'{l0 input will result the next output
Try it online!
if($i='h3l}''{l0'){
$s=@'
if($i='{0}'){{
$s=@'
{1}'@
$s-f($i-replace'^.'-replace"'","''"),"$s`n"
$host.setshouldexit($i[0])
}}
exit
'@
$s-f($i-replace'^.'-replace"'","''"),"$s`n"
$host.setshouldexit($i[0])
}
exit

Which in the own turn will output
Try it online!
if($i='3l}''{l0'){
$s=@'
if($i='{0}'){{
$s=@'
{1}'@
$s-f($i-replace'^.'-replace"'","''"),"$s`n"
$host.setshouldexit($i[0])
}}
exit
'@
$s-f($i-replace'^.'-replace"'","''"),"$s`n"
$host.setshouldexit($i[0])
}
exit

The last run will output nothing and exit code will be 0.
Try it online!
if($i=''){
$s=@'
if($i='{0}'){{
$s=@'
{1}'@
$s-f($i-replace'^.'-replace"'","''"),"$s`n"
$host.setshouldexit($i[0])
}}
exit
'@
$s-f($i-replace'^.'-replace"'","''"),"$s`n"
$host.setshouldexit($i[0])
}
exit

sed, 467 461 bytes
Character codes are hard:
s:^:Y:
:b
s:ZY[ (2<FPZdnx]:0_Y:
s:ZY[ )3=GQ[eoy]:1_Y:
s:ZY[ *4>HR\fpz]:2_Y:
s:ZY[]!+5?ISgq{]:3_Y:
s:ZY[",6@JT^hr|]:4_Y:
s:ZY[-#7AKU_is}]:5_Y:
s:ZY[$.8BLV`jt~]:6_Y:
s:ZY[%/9CMWaku]:7_Y:
s:ZY[&0:DNXblv]:8_Y:
s:ZY['1;EOYcmw]:9_Y:
s:Y[ -']:3Z&:
s:Y[(-1]:4Z&:
s:Y[2-9:;]:5Z&:
s:Y[<=>?@A-E]:6Z&:
s:Y[F-O]:7Z&:
s:Y[P-Y]:8Z&:
s:Y[]Z\-`abc]:9Z&:
s:Y[d-m]:10Z&:
s:Y[n-w]:11Z&:
s:Y[xyz{-~]:12Z&:
tb
s/([^_]+)_Y$/ q\1/
:
s/[/\]/\\&/g
s/([^_]+)_ (.*)/ s\/^\/\2\/;q\1/
/^\S/b

Try it online!
Otherwise, the logic is rather straightforward: (1) escape special characters (there're two), (2) wrap in an additional s/^/…/;q\1 layer, (3) repeat.
Here's the output for hello:
 s/^/s\/^\/s\\\/^\\\/s\\\\\\\/^\\\\\\\/q111\\\\\\\/;q108\\\/;q108\/;q101/;q104

And a little script that I used:
#!/bin/bash
set -uo pipefail
IFS=$'\n'

P=$(echo $1 | sed -rf q.sed)
echo $P

echo $1 | od -An -tuC

for char in $(echo $1 | sed 's:.:&\n:g'); do
    P=$(echo | sed $P)
    printf ' %3d' $?
done

You don't need to worry about newlines, as the post says you'll only be given characters between 0x20 and 0x7E. Nice solution! :)

@ConorO'Brien Oh, right. Thanks!


text:
Calculate Wind Chill
The Australian Apparent Temperature (aka, wind chill) in °C AT is given by this algorithm from the Australian Bureau of Meterology (wp, source):

AT = Ta + (0.33 * e) - (.7 * ws) - 4.0
Where:

Ta = Dry bulb temperature (°C)
e = Water vapour pressure (hPa)
ws = Wind speed (m/s) (at an elevation of 10 meters)

The water vapour pressure in hectoPascals e is given by this algorithm:

e = (rh / 100) * 6.105 * exp( ( 17.27 * Ta ) / ( 237.7 + Ta ) )
Where:

Ta = Dry bulb temperature (°C)
rh = Relative humidity [%]
exp  represents the exponential function

The domain of:

Ta is -273.15°C to 2e7°C.

e is the real numbers

ws is 0 m/s to 2e7 m/s

rh is 0% to 100%

For inputs outside these domains, your code can do anything, including give the right answer.

Output
Given a dry bulb temperature in °C, a wind speed in metres / second, and a relative humidity in %, your code should give the Apparent Temperature in °C, accurate to 0.1°C.
Assuming your platform or language can represent reals, for correct functions correct_func,

or in C, fabsl( correct_func(Ta, rH, ws) - expected ) < 0.1.
Test cases

1 value for Ta, rh, ws -> output

0 -> -4
2 -> -3.35346
4 -> -2.69275
6 -> -2.01507
8 -> -1.31719
10 -> -0.595428
12 -> 0.154404
14 -> 0.937065
16 -> 1.75793
18 -> 2.62308
20 -> 3.5393
22 -> 4.51423
24 -> 5.55638
26 -> 6.67525
28 -> 7.88137
30 -> 9.18643

49, 99, 67 -> 36.268

Repl.it for any test case: https://repl.it/H9xL/0
You can use a builtin function for the exponential function,
ex, if you like.
This is code-golf, so the shortest code wins!

Is there a single input to the program or are the test cases just weird?

@JonathanAllan The algorithm takes three inputs, but I was lazy in creating the test cases, using one value for three args.

This challenge doesn't really have much room for golfing.

Without any bound on the inputs, a finite precision on e makes it impossible to be within 0.1 degree on all onputs. Or is this only on the test cases?

@xnor The inputs have bounds. "For inputs outside these domains, your code can do anything, including give the right answer."

@xnor the point of that was to say that results should be accurate to the .1s (tenths) place and that following, more precise digits do not matter. did i say it in an unclear way?

This isn't a problem with the people. There's little room for creativity when the algorithm is straight-up the simplest way to solve it.

My mistake. So I guess golfers would need to figure out how much precision is needed in each constant by looking at how much inaccuracy the rounding causes on extremal cases.

Python 3, 76 bytes
t=lambda T,r,V:.0201465*r*2.718281828459045**(1727*T/(100*T+23770))+T-.7*V-4

Try it online!

Welcome to PPCG!

Python, 78 72 66 bytes
Pretty much a direct implementation of the algorithm provided in the challenge description.
lambda T,r,w:T+.0201465*r*2.7182818284**(17.27*T/(237.7+T))-.7*w-4

Try it online
This was specifically tested with the maximum value of T to find how many digits of Euler's constant were required for the error to be within the allowed amount.

TI-BASIC, 41 bytes
:Prompt T,R,W
:T-.7W-4+.02014565Re^(17.27T/(237.7+T

Surprisingly, a calculator is really good at crunching numbers.

Javascript, 56 bytes
(a,r,w)=>a+.0201465*r*Math.exp(17.27*a/(237.7+a))-.7*w-4

var f = (a,r,w)=>a+.0201465*r*Math.exp(17.27*a/(237.7+a))-.7*w-4
var expected = [-4, -3.35346, -2.69275, -2.01507, -1.31719, -0.595428, 0.154404, 0.937065, 1.75793, 2.62308, 3.5393, 4.51423, 5.55638, 6.67525, 7.88137, 9.18643]; for (var i = 0; i < 16; i++) {var g = f(2*i,2*i,2*i); var diff = expected[i] - g; document.getElementById('w').innerHTML += '\n' + ((diff > 0.1 || diff < -0.1) ? 'KO' : 'OK') + '   ' + (expected[i] - g) + '   ' + g + '   ' + expected[i];}

Passed  |  Diff  |  Actual result  |  Expected

Octave, 54 49 bytes
@(T,r,V).0201465*r*e^(17.27*T/(237.7+T))+T-.7*V-4

Try it online!

(17.27*T/(237.7+T) is shorter.

Japt, 40 38 bytes
U+.0#É465*V*MEp17.27*U/(#í.7 +U)-.7*W-4

Try it online!
This is my first Japt answer, so please don't judge it too harshly ;-)

Hey, thanks for using Japt :-) You can save a couple bytes by replacing 201 and 237 with #É and #í, respectively. (It's an odd trick, but it works...)

@ETHproductions: that's odd indeed. Thanks though!

Perl 6, 52 (possibly non-competing)
{$^a+.0201465*$^c*exp(17.27*$a/(237.7+$a))-4-.7*$^b}

This can't be evaluated by itself. You either have to pass in arguments, or store the block into a variable.

What do you mean, “This can't be evaluated by itself”? As I see, it can be called as any anonymous function. (Maybe you should specify that it expects parameters in Ta, ws, rh order.)

If you type it by itself in the REPL, you'll get an error. You either have to pass in the arguments, or assign the block to a variable.

Sure you have to pass it arguments, but no need to assign to variable. https://pastebin.com/7W3cJSrX This is the same as calling anonymous functions in other languages.

What I meant was that if you typed the expression alone without either, you got an error.

source: Stack Exchange

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

sort: votes


text:
Find the indices of values in one list in another
You must take two lists of positive integers as input, let's call these n and m.
You may assume that:

All integers in n are part of m
All integers in m are unique
The lists are non-empty

Challenge: Return the indices of where you find the values in n, in m.
That might be confusing, but I think the test cases will make the task pretty clear. The examples are 1-indexed, you may choose 0-indexed if you want to (please specify).
n = 5 3 4 1
m = 6 8 4 1 2 5 3 100
output: 6 7 3 4    // 5 is in the 6th position of m
                   // 3 is in the 7th position of m
                   // 4 is in the 3rd position of m
                   // 1 is in the 4th position of m

n = 5 3 4 9 7 5 7
m = 3 4 5 7 9
output: 3 1 2 5 4 3 4

n = 1 2 3 4 5 6
m = 1 2 3 4 5 6
output: 1 2 3 4 5 6

n = 16 27 18 12 6 26 11 24 26 20 2 8 7 12 5 22 22 2 17 4
m = 15 18 11 16 14 20 37 38 6 36 8 32 21 2 31 22 33 4 1 35 3 25 9 30 26 39 5 23 29 10 13 12 7 19 24 17 34 27 40 28
output: 4 38 2 32 9 25 3 35 25 6 14 11 33 32 27 16 16 14 36 18

n = 54
m = 54
output: 1

The winners will be the shortest solutions in each language.

This is a very nice meta-post by the way!

This might be a strange question, but would it be OK to assume the input will have a trailing space?

Curious why you ask, but yeah, sure...

V, 26 bytes
jòdf kÄ/-
DÓÓ
ÒC1@"Gòdk

Try it online!
This is a very strange and hacky solution, because V has little to no concept of numbers. Input comes in this format:
6 8 4 1 2 5 3 100
5 3 4 1

With a trailing space on each line.
Hexdump:
00000000: 6af2 6466 206b c42f 122d 0a44 d3d3 0ad2  j.df k./.-.D....
00000010: 0143 311b 4022 47f2 646b                 .C1.@"G.dk

Explanation:
j                   " Move down one line (to N) (1)
 ò                  " Recursively:
  df                "   (d)elete until you (f)ind a space. This will be saved into
                    "   register '-' (2)
     k              "   Move up one line (to M)
      Ä             "   Duplicate line M (3)
       /<C-r>-      "   Move the cursor forward until the next occurence of register '-'
                    "   (the number we deleted from N)
                    "   (4)
D                   "   Delete every character *after* the cursor (5)
 ÓÓ                 "   Remove everything on this line except for whitespace
Ò<C-a>              "   Replace every character on this line with `<C-a>`, which is the
                    "   command for incrementing a number (6)
      C             "   Delete this line into register '"', and enter insert mode
       1<esc>       "   Enter a '1' and return to normal mode
             @"     "   Run register '"' as V code (7)
               G    "   Go to the last line (1)
                ò   " End recursion
                 dk " Delete the last two lines (m and n)

If this doesn't make it clearer, here are examples of the buffer during the various stages the loop goes through:
Stage 1 (| is the cursor)
6 8 4 1 2 5 3 100
|5 3 4 1

Stage 2:
6 8 4 1 2 5 3 100
|3 4 1

Stage 3:
|6 8 4 1 2 5 3 100
6 8 4 1 2 5 3 100
3 4 1

Stage 4:
6 8 4 1 2 |5 3 100
6 8 4 1 2 5 3 100
3 4 1

Stage 5:
6 8 4 1 2 |
6 8 4 1 2 5 3 100
3 4 1

Stage 6:
|<C-a><C-a><C-a><C-a><C-a>
6 8 4 1 2 5 3 100
3 4 1

Stage 7:
|6
6 8 4 1 2 5 3 100
3 4 1

Back to stage 1:
6
6 8 4 1 2 5 3 100
|3 4 1

Python 2, 25 bytes
lambda a,b:map(a.index,b)

Try it online!
Note that this uses 0-indexing.

APL (Dyalog), 1 byte
⍳

Try it online!
Note: the ⍳ function does not take scalars as its left argument, so to give it a left argument like 54, you have to make it into an array using , like so (,54).

Mathematica, 25 bytes
#&@@@PositionIndex@#/@#2&

Takes two inputs m and n, and returns the 1-based indices of n in m.

Retina, 32 31 30 bytes
1 byte saved thanks to Kritixi Lithos and 1 byte thanks to Martin Ender
(\d+)(?=.*¶(\d+ )*\1 )
$#2
G1`

Uses 0-indexing. Input has a trailing space on each line.
Try it online!
Explanation
(\d+)(?=.*¶(\d+ )*\1 )
$#2

Here we replace every number on the first line by the number of numbers before the same number on the second line.
G1`

Then, we delete the second line, leaving only the new first line as the output.

Java, 104 81 bytes
1 byte thanks to Business cat.
void f(int[]a,int[]b){for(int i=0,j=0;i<b.length;)j=a[j++]==b[i]?0*(b[i++]=j):j;}

Try it online!

C#, 32 Bytes
(n,m)=>n.Select(i=>m.IndexOf(i))

This is the code as a lambda expression, so it should be valid.
The solution is with a 0 based index. I think it's pretty straigt forward how it works - it simply takes the items of n and selects the indices of the items in m.

Octave, 25 bytes
@(n,m)([x,~]=find(n==m'))

Try it online!

Haskell, 32 bytes
a%b=[length$fst$span(/=x)b|x<-a]

Try it online! One-indexed.
Other attempts:
q(h:t)x|x==h=0|1>0=1+q t x;map.q
f b=map$length.fst.($b).span.(/=)
a%b=[until((==x).(b!!))(+1)0|x<-a]
a%b=[until(\y->x==b!!y)(+1)0|x<-a]
import Data.List;map.flip elemIndex

k, 1
This is a built-in operator in k and uses zero-based indexing.
?

Example:
k)6 8 4 1 2 5 3 100 ? 5 3 4 1
5 6 2 3

Jelly, 3 bytes
iÐ€

Try it online!
Specs

Input: two arguments, the first being m, and the second being n.
Output: one array

05AB1E, 5 bytes
v²yk,

Try it online!
v     # For each value in n (call it y)
 ²    # Push m
  y   # Push y
   k, # Print the 0-indexed index of y in m

JavaScript (ES6), 28 bytes
Takes the arrays in currying syntax (n)(m). 0-indexed.

let f =

n=>m=>n.map(v=>m.indexOf(v))

console.log(JSON.stringify(f([5,3,4,1])([6,8,4,1,2,5,3,100])))
console.log(JSON.stringify(f([5,3,4,9,7,5,7])([3,4,5,7,9])))
console.log(JSON.stringify(f([1,2,3,4,5,6])([1,2,3,4,5,6])))
console.log(JSON.stringify(f([16,27,18,12,6,26,11,24,26,20,2,8,7,12,5,22,22,2,17,4])([15,18,11,16,14,20,37,38,6,36,8,32,21,2,31,22,33,4,1,35,3,25,9,30,26,39,5,23,29,10,13,12,7,19,24,17,34,27,40,28])))
console.log(JSON.stringify(f([54])([54])))

Perl 6, 31 bytes
->\n,\m{n.map:{m.first($_,:k)}}

Try it
Expanded:
-> \n, \m {  # pointy block lambda

  n.map: {            # map over the values in ｢n｣
    m.first( $_, :k ) # return the key ｢:k｣ of the first occurrence
  }
}

0 indexed

R, 20 5 bytes
1-indexed; match is the builtin function that finds the indices in the second input of the elements of the first, i.e., match(n,m) gives the desired answer
match

thanks to @flodel for pointing out that returning a function is perfectly acceptable as an answer!
Try it online!

I think match (5 bytes) alone would be an acceptable solution.

you are correct, updated.

MATL, 2 bytes
&m

This uses 1-indexing. Try it online!
Explanation
The meta-function & indicates that the next function will use a (function-specific) secondary default in/out specification. For function m (ismember), & specifies that its second output will be produced. This contains the index of (the first occurrence of) each entry of the first input in the second input.

Japt, 4 bytes
m!bV

Test it online!
Explanation
There's not much to explain here, but it shows off an interesting feature of Japt. Normally, you would pass a function to m, like so:
mX{VbX}

This is basically U.map(X => V.indexOf(X)) (the U is implicit). However, when you're just performing one operation between two values (b here, on V and X), you can just give the operator and the other value and Japt will make a function out of it. This means mX{X+2} can be golfed to m+2.
However, this doesn't work when the values are in the wrong order (mbV would be short for mX{XbV}). To get around this, you can prepend an exclamation mark to the operator, which tells Japt to swap the operands. This costs an extra byte, but it's still a couple bytes shorter than the alternative. And now you know a little more about Japt.

Haskell, 34 bytes
n#m=[i|a<-n,(i,e)<-zip[1..]m,e==a]

Usage example: [5,3,4,9,7,5,7] # [3,4,5,7,9] -> [3,1,2,5,4,3,4]
The built-in elemIndex is in Data.List and therefore longer than the version above. The outer loop goes through n and the inner loop through pairs of (i,e) where i is the index of e in m. Keep the i where e equals the current element of n.

Clojure, 25 bytes
#(map(zipmap %2(range))%)

0-indexed.

Pyth, 4 bytes
xLQE

Try it online!
Note that this uses 0-indexing.

J, 2 bytes
i.

This is not a complete program, but a built-in function.
Use it as such:
echo 6 8 4 1 2 5 3 100 i. 5 3 4 1

Try it online!
Note that this uses 0-indexing.

CJam, 4 bytes
{f#}

Anonymous block that expects arguments on the stack and leaves the result on the stack.
Uses 0-indexing.
Try it online!

PHP, 56 Bytes
Online Versions
0 Indexing
output as String

<?foreach($_GET[0]as$v)echo" ".array_flip($_GET[1])[$v];

PHP, 65 Bytes
Output as array

<?foreach($_GET[0]as$v)$r[]=array_flip($_GET[1])[$v];print_r($r);

PHP, 78 Bytes
workaround with array_map

<?print_r(array_map(function($v){return array_flip($_GET[1])[$v];},$_GET[0]));

for not unique arrays replace with array_flip($_GET[1])[$v] array_search($v,$_GET[1])

Haskell, 43 bytes
a*b=[[fst x|x<-zip[0..]b,y==snd x]!!0|y<-a]

a*b=                                         -- define function * with 2 args
    [                                |y<-a]  -- for each elt in first arg
               zip[0..]b                     -- match elts in second arg w/ idxs
                                             -- [a,b,c] -> [[0,a],[1,b],[2,c]]
     [fst x|x<-                  ]           -- take first element in each pair
                        ,y==snd x            -- if the index matches
                                  !!0        -- first element (always only 1)

Perl 5, 38 34 bytes
4 bytes saved thanks to Dada
sub{map$x{$_}//($x{$_}=++$x)x0,@_}

1-indexed. Takes the lists m and n as a single list, like f(@m,@n). The x0 is just to keep the output from starting with 1,2,3,4,5, etc.

Nice answer. Note that anonymous functions are allowed, so sub{...} can save you 2 bytes. Also, you can use x0 instead of &&() to save two more bytes.

Uiua, 1 byte
⊗

Try it!
0-indexed.

Java 7, 80 bytes
void c(int[]a,java.util.List b){for(int i=0;i<a.length;a[i]=b.indexOf(a[i++]));}

0-indexed
Explanation:
void c(int[]a,java.util.List b){  // Method with integer-array and List parameters
  for(int i=0;i<a.length;         //  Loop over the integer-array
    a[i]=b.indexOf(a[i++])        //   And change every value to the index of the List
  );                              //  End of loop (no body)
}                                 // End of method

Test code:
Try it here.
import java.util.Arrays;
class M{
  static void c(int[]a,java.util.List b){for(int i=0;i<a.length;a[i]=b.indexOf(a[i++]));}

  public static void main(String[] a){
    int[] x = new int[]{ 5, 3, 4, 1 };
    c(x, Arrays.asList(6, 8, 4, 1, 2, 5, 3, 100));
    System.out.println(Arrays.toString(x));

    x = new int[]{ 5, 3, 4, 9, 7, 5, 7 };
    c(x, Arrays.asList(3, 4, 5, 7, 9));
    System.out.println(Arrays.toString(x));

    x = new int[]{ 1, 2, 3, 4, 5, 6 };
    c(x, Arrays.asList(1, 2, 3, 4, 5, 6));
    System.out.println(Arrays.toString(x));

    x = new int[]{ 16, 27, 18, 12, 6, 26, 11, 24, 26, 20, 2, 8, 7, 12, 5, 22, 22, 2, 17, 4 };
    c(x, Arrays.asList(15, 18, 11, 16, 14, 20, 37, 38, 6, 36, 8, 32, 21, 2, 31, 22, 33, 4, 1, 35, 3, 25, 9, 30, 26, 39, 5, 23, 29, 10, 13, 12, 7, 19, 24, 17, 34, 27, 40, 28));
    System.out.println(Arrays.toString(x));

    x = new int[]{ 54 };
    c(x, Arrays.asList(54));
    System.out.println(Arrays.toString(x));
  }
}

Output:
[5, 6, 2, 3]
[2, 0, 1, 4, 3, 2, 3]
[0, 1, 2, 3, 4, 5]
[3, 37, 1, 31, 8, 24, 2, 34, 24, 5, 13, 10, 32, 31, 26, 15, 15, 13, 35, 17]
[0]

Bash + coreutils, 51
for n in $1
do grep -wn $n <<<"$2"
done|cut -d: -f1

Try it online.

Previous answer:
s()(sort -$1k2)
nl|s|join -j2 - <(nl<<<"$1"|s)|s n|cut -d\  -f3

Try it online.

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

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


text:
Decompose a number into triangles
Given an integer n, decompose it into a sum of maximal triangular numbers (where Tm represents the mth triangular number, or the sum of the integers from 1 to m) as follows:

while n > 0,

find the largest possible triangular number Tm such that Tm ≤ n.
append m to the triangular-decomposition representation of n.
subtract Tm from n.

For example, an input of 44 would yield an output of 8311, because:

1+2+3+4+5+6+7+8 = 36 < 44, but 1+2+3+4+5+6+7+8+9 = 45 > 44.

the first digit is 8; subtract 36 from 44 to get 8 left over.

1+2+3 = 6 < 8, but 1+2+3+4 = 10 > 8.

the second digit is 3; subtract 6 from 8 to get 2 left over.

1 < 2, but 1+2 = 3 > 2.

the third and fourth digits must be 1 and 1.

Use the digits 1 through 9 to represent the first 9 triangular numbers, then use the letters a through z (can be capitalized or lowercase) to represent the 10th through 35th triangular number. You will never be given an input that will necessitate the use of a larger "digit".
The bounds on the input are 1 ≤ n < 666, and it will always be an integer.
All possible inputs and outputs, and some selected test cases (listed as input, then output):
1 1
2 11
3 2
4 21
5 211
6 3
100 d32
230 k5211
435 t
665 z731

An output of ∞ for an input of -1/12 is not required. :)

But does an input of ∞ need to have an output of ∞?

JavaScript (ES6), 52 bytes
f=(n,t=0)=>t<n?f(n-++t,t):t.toString(36)+(n?f(n):'')

How?
Rather than explicitly computing Ti = 1 + 2 + 3 + … + i, we start with t = 0 and iteratively subtract t + 1 from n while t < n, incrementing t at each iteration. When the condition is not fulfilled anymore, a total of Tt has been subtracted from n and the output is updated accordingly. We repeat the process until n = 0.
Below is a summary of all operations for n = 100.
 n  |  t | t < n | output
----+----+-------+--------
100 |  0 | yes   | ""
 99 |  1 | yes   | ""
 97 |  2 | yes   | ""
 94 |  3 | yes   | ""
 90 |  4 | yes   | ""
 85 |  5 | yes   | ""
 79 |  6 | yes   | ""
 72 |  7 | yes   | ""
 64 |  8 | yes   | ""
 55 |  9 | yes   | ""
 45 | 10 | yes   | ""
 34 | 11 | yes   | ""
 22 | 12 | yes   | ""
  9 | 13 | no    | "d"
----+----+-------+--------
  9 |  0 | yes   | "d"
  8 |  1 | yes   | "d"
  6 |  2 | yes   | "d"
  3 |  3 | no    | "d3"
----+----+-------+--------
  3 |  0 | yes   | "d3"
  2 |  1 | yes   | "d3"
  0 |  2 | no    | "d32"

Test cases

f=(n,t=0)=>t<n?f(n-++t,t):t.toString(36)+(n?f(n):'')

console.log(f(1))   // 1
console.log(f(2))   // 11
console.log(f(3))   // 2
console.log(f(4))   // 21
console.log(f(5))   // 211
console.log(f(6))   // 3
console.log(f(100)) // d32
console.log(f(230)) // k5211
console.log(f(435)) // t
console.log(f(665)) // z731

Jelly, 18 17 bytes
Ḥ‘½+.Ḟ©ịØB2®cạµ¹¿

This is a monadic link that prints to STDOUT. It's return value is 0 and should be ignored.
Try it online!

dc, 74 bytes
?sa[2k_1K/1 4/la2*+v+0k1/dlardd*+2/-sadd10<t9>ula0<s]ss[87+P]st[48+P]sulsx

This is awful.
?sa             stores the input
[2k             sets precision to 2 so dc doesn't truncate 1/4
_1K/1 4/la2*+v+ uses the quadratic formula to find k, the next value to print
0k1/d           truncates k to an integer
lardd*+2/-sa    subtracts kth triangular number from the input
dd10<t9>u       determines whether to print k as a letter or a digit
la0<s]ss        loops when a is greater than 0
[87+P]st        prints k as a letter
[48+P]su        prints k as a digit (not p, as that leaves a trailing newline)
lsx             starts the main loop

JavaScript (ES6), 61 57 bytes
Saved 4 bytes thanks to @Arnauld
f=(n,p=q=0)=>n?p-~q>n?q.toString(36)+f(n-p):f(n,++q+p):''

I had f=(n,t=0)=>n?t+1>n?t.toString(36)+f(n):f(n-++t,t):1

@Arnauld Oh wow, that's way better. You should post it yourself...

Alright. In your version, would it be safe to do f=(n,p=q=0) and f(n,++q+p)?

@Arnauld Yes, thanks!

Retina, 115 108 38 34 bytes
.+
$*¶
(\G¶|¶\1)+
0$1
+T`_w¶`w_`.¶

[Try it online!] (Includes test suite) Uses uppercase letters. Edit: Saved 70 74 bytes by shamelessly adapting @MartinEnder's answer to Is this number triangular? Explanation: The number is converted into unary, then the largest possible triangular number is repeatedly matched until the number is exhausted. Each match is then converted into base 36.

Java 7, 81 bytes
int i=0;String c(int n){return i<n?c(n-++i):Long.toString(i,36)+(n>(i=0)?c(n):"");}

Port from @Arnauld's amazing JavaScript (ES6) answer.
My own approach was almost 2x as long..
Try it here.
Explanation:
int i=0;                  // Temp integer `i` (on class level)
String c(int n){          // Method with integer parameter and String return-type
  return i<n?             //  If `i` is smaller than the input integer
    c(n-++i)              //   Return a recursive call with input minus `i+1` (and raise `i` by 1 in the process)
   :                      //  Else:
    Long.toString(i,36)+  //   Return `i` as Base-36 +
     (n>(i=0)?            //   (If the input integer is larger than 0 (and reset `i` to 0 in the process)
      c(n)                //    Recursive call with the input integer
     :                    //   Else:
      "");                //    an empty String)
}                         // End of method

PHP, 74 Bytes
for(;$n=&$argn;$t.=$i>10?chr($i+86):$i-1)for($i=0;$n>=++$i;)$n-=$i;echo$t;

Online Version

R, 87 bytes
Originally, I tried to preset the possible Triangular numbers. This led to this code with 105 bytes:
pryr::f(n,{l=cumsum(1:35)
k=''
while(n){y=tail(which(l<=n),1)
n=n-l[y]
k=paste0(k,c(1:9,letters)[y])}
k})

This required more indexing so I tried the methodology from @Arnauld to reduce the bytes down to 87.
pryr::f(n,{k='';while(n){t=0;while(t<n){t=t+1;n=n-t};k=paste0(k,c(1:9,letters)[t])};k})

Both codes made use of the preset letters, since their I couldn't find a short way to convert to base 36.


text:
Print a quine that contains the input
Task
You will be given a string in the input consisting only of the characters from a to z, i.e. the input will match the regex /^[a-z]*$/.
Your output should be a complete program in the same language, whose source code contains the input, and is a proper quine.
Example
Your program would receive the input abc and output:
...abc...

The above should be a complete program in the same language which takes no input and outputs:
...abc...

i.e. it outputs itself.
Scoring
This is code-golf. Shortest answer in bytes wins.
References

What counts as a proper quine?

Hmm.. So like a 'quat' (quine + cat)?

Python 3, 57 61 bytes
lambda x:"s='s=%r;print(s%%s)';print(s%s)".replace('s',x+'x')

Takes a basic python 3 quine from here and replaces the variable name with the input.
Note: As pointed out by Hyper Neutrino in comments, this does not work for reserved keywords like for, if, etc.
Appending a character that none of the reserved keywords ends with such as 'x' or any number fixes this. (Ørjan Johansen).

Very creative to use the variable name.

Doesn't work for input "for", or any other reserved word in Python.

Can confirm. It doesn't work for all possible inputs. Try it online

@HyperNeutrino, Noted, also no idea how to get around it

You could append an extra character that isn't at the end of any keyword, such as 'x'.

@ØrjanJohansen Can't believe I didn't think of that, thanks!

Jelly, 9 bytes
Generator
;“¶Øv”ṾØv

Try it online!
How it works
;“¶Øv”ṾØv  Main link. Argument: s (string of letters)

;“¶Øv”     Concatenate s and the string "\nØv".
      Ṿ    Uneval; get its string representation.
           (implicit) Print the previous return value since the next link is an
           otherwise unparsable nilad.
       Øv  Set the return value to "Ṙv".

Quine
If the input is quine, the following program is generated.
“quine
Øv”Ṙv

Try it online!
How it works
This is the standard Jelly quine. First,
“quine
Øv”

sets the left argument and the return value to the string "quine\nØv".
Then, Ṙ prints a string representation (the code from the previous block) and returns the unaltered string.
Afterwards, v takes the left argument and passes it as input to the Jelly program
quine
Øv

In all Jelly programs, only the main link (defined on the last line) is executed, so the first line is ignored entirely.
Finally, Øv sets the return value to "Ṙv", which is printed implicitly when the outer program finishes.

8 bytes

Haskell, 51 bytes
q takes a string and returns a string.
q s|t<-"main=putStr$fst`mappend`show$"=t++show(t,s)

Try it online!
Example output for putStr$q"test":
main=putStr$fst`mappend`show$("main=putStr$fst`mappend`show$","test")

Try it online!

Puts the main quine text and the desired string in a tuple.
Uses fst to extract the main text.
Uses show to turn the whole tuple into a string.
Uses mappend to combine the two previous functions. Conveniently mappend on two functions gives a function that applies each function to its argument and combines the results with mappend for the result type (here string concatenation).

Underload, 14 bytes
(~aSaS(:^)S):^

Try it online!
Use as (test)(~aSaS(:^)S):^ – which is itself a quine.
How it works

Underload is a concatenative (stack-based) esoteric language. It doesn't support reading input, so any arguments are put on the stack initially.
(test) and (~aSaS(:^)S) are string literals, so place themselves on the stack, with the latter on top.
: duplicates the (~aSaS(:^)S) string on top of the stack, then ^ runs its contents as a subprogram.
~ swaps the top two elements on the stack, so now (test) is uppermost.
a wraps (test) in extra parentheses.
S takes the string ((test)) on top of the stack, and prints it without the outer parentheses (which are just literal syntax).
Now aS prints the remaining (~aSaS(:^)S) on the stack similarly (with the parentheses).
At last, (:^)S prints the final :^.

Doesn't really work for )( as the input, I think.

@Riker True, Underload unfortunately doesn't support mismatched parentheses. But the question specifies a-z.

Ah, okay. Didn't notice that.

Underload, 14 bytes
a(aS(:^)S)~*:^

Try it online!
A different approach from the other Underload answer; rather than itself being a quine, this constructs a quine. Interestingly, it comes out to the same number of bytes. This is a function that takes its argument from the stack and outputs to standard output.
Explanation
a(aS(:^)S)~*:^
a               Generate a string literal containing the input
 (aS(:^)S)~*    Prepend "aS(:^)S"
            :^  Mockingbird: run the resulting function with itself as argument

The resulting function looks like this:
aS(:^)S(input)
aS              Print a string literal containing the argument
  (:^)S         Print ":^"
       (input)  Push "input" onto the stack

In other words, it prints a string literal containing itself, followed by :^. This is clearly a quine (because what was just printed is the same as the code we executed to run it in the first place).

It looks like in TIO, you can drop the initial a, as long as you don't mind the segmentation fault error printed to stderr when the input contains a.

I didn't even think of just executing the string literal that the user gives, on the basis that the program's work is already finished at that point and without ( being a character that appears in the input, all programs will necessarily do nothing or crash. I don't even think that's specific to TIO; the program is invalid, but it's already produced the desired output at the time it crashes.

Python 2, 38 bytes
Though input is only required to support a-z, this should work with any single-line input that doesn't contain NUL bytes.
s='s=%r;print s%%s#'+input();print s%s

Try it online
For input abc the resulting quine is:
s='s=%r;print s%%s#abc';print s%s#abc

Try it online

V, 9 bytes
ñ"qPxÉÑ~j

Try it online!
This is a modification of the standard V quine, and I'm proud that this is only one byte longer.
Hexdump:
00000000: f122 7150 78c9 d17e 6a                   ."qPx..~j

Explanation:
ñ           " Record the following commands into register 'q'
 "qP        " Paste register 'q' before all input
    x       " Delete the last character of what we just pasted (this will be a 'ÿ')
     ÉÑ     " Insert 'Ñ' at the beginning of this line
       ~    " Toggle the case of this character
        j   " Move down a line. During playback, this will cancel playback of the current macro,
            " So everything after here is a NOOP

Then, the recording implicitly stops and is played back. This will generate the following output:
ñ"qPxÉÑ~jHello

Since j will break playback of the macro, nothing in Hello will ever get run.

RProgN 2, 15 bytes
"{']C'.%q[}]C"F

Explained
Using the format
{']C'.%q[}]C}

where %q is the qouted input, builds a quine of the flavour
{']C'."Some Text"[}]C

which is a standard RProgN2 quine, {']C'.}]C That, before finished, appends and destroys the inputted string.
Try it online!

Retina, 14 bytes
Byte count assumes ISO 8859-1 encoding.
\(\`^
¶\(*S1`|

Try it online!
For input x, this outputs:

\(*S1`|x
\(*S1`|x

Explanation
The output is a minor modification of the standard quine. We simply use the regex |x instead of the empty regex. Since the | still allows (and prioritises) and empty match, the functionality itself is not affected, and since x will only ever contain letters, it's guaranteed to be valid regex syntax itself.
Printing this actually uses a technique which is similar to the quine itself. To avoid the duplication of the quine, we insert ¶\(*S1`| only once into the beginning of the string. That's exactly half the source code. To print it twice without a linefeed, we use the configuration \(\, which wraps the entire program in a group and makes both the stage itself as well as the group containing it print the result without a linefeed.

Japt, 14 bytes
"\"iQ ²ª`"+U ²

Test it online! For an input of abc, outputs
"iQ ²ª`abc"iQ ²ª`abc

which outputs itself. Test it online!
Explanation
This is an extension of the standard payload-capable Japt quine:
"iQ ²"iQ ²

"iQ ²"      // Take this string.  iQ ²
      iQ    // Insert a quote.    "iQ ²
         ²  // Repeat this twice. "iQ ²"iQ ²
            // Implicit: output result of last expression

The only difference is that we append ª`abc at the end, which in JavaScript is basically ||"abc". Since the result of the first part is always a non-empty string (truthy), the || never gets run.
There are several alternative versions of the same length:
"iQ ²ª`abc"iQ ²ª`abc   quine||"abc"
"iQ ²ª$abc"iQ ²ª$abc   quine||abc
"iQ ²ª{abc"iQ ²ª{abc   quine||function(){ ... }
"iQ ²ªXabc"iQ ²ªXabc   quine||X.a(...) (X could be any uppercase letter or digit)
"iQ ²//abc"iQ ²//abc   quine//abc      (// is a comment in JS/Japt)
"iQ ²;[abc"iQ ²;[abc   quine;          (unmatched [ causes a parsing error)

CJam, 16 14 bytes
"`_~"q`';++`_~

Try it online!
How it works
"`_~"           e# Push "`_~"
     q`         e# Push a string representation of the input (input wrapped in quotes)
       ';       e# Push a semicolon
         ++     e# Concatenate all this together
           `    e# Get the string representation of the resulting string
            _~  e# Duplicate it and eval it (pushing the original string on the stack again)

Which outputs something like "`_~\"test\";"`_~"test";.

JavaScript, 21 bytes
$=_=>`$=${$}/*${_}*/`

A bit late to say this (it just came up now in the review queue because of CommonMark migration), but this doesn't appear to output a full program.

It works for me. If you run it with input abc, you get $=_=>`$=${$}/*${_}*/`/*abc*/

I don't actually know JavaScript, but this appears to only be a function, and none of the four JavaScripts on TIO seem to automatically execute it. The challenge spec specifically specifies that "your output should be a complete program". (note that there is no such restriction on the solution itself)

Perl 5, 35 bytes
$_=q{say"\$_=q{$_};eval"#}.<>;eval

Try it online!


text:
Tell me my screen resolution!
Output the device's screen resolution in the specific format of [width]x[height](without the brackets). For example, an output could be 1440x900.
Here's an online tester that you can use to check your own screen resolution.

So for all screens or only the primary screen?

@MetaColon only the primary. I forgot that secondary screens existed.

The specific output format is no fun, but it's probably too late to change now

What should the behaviour be if multiple displays are connected?

I suppose we're not allowed to first change your resolution and then tell you those values, right?

APL\360 (can only be run on IBM/360 typewriter environment), 5 bytes: '0x0'

What if you code for a device that only supports one screen resolution?

The edit by @Riker removed the wording To clarify, If it's equivalent to the output from What is my screen resolution, It's valid. That website reports 1920 x 1080 rather than 1920x1080. Can answers separate width, height, and the x by spaces?

Commodore 64 Basic: PRINT "40x25"

I like that this one disqualifies most golfing languages and encourages people to explore the limits of practical ones.

go to http://www.whatismyscreenresolution.com/ . now zoom out a few times (ex if on windows and firefox: ctrl+mouse_wheel_down), and press F5 : you will now "have" a much higher resolution ! ;)   I went from 1024x768 to 4267x3413 by this simple easy trick ... I wonder if that site is not tricking me into believing this

@Mark that's the text size, not resolution in pixels...

The resolution checker link from the question gives wrong resolution. 412x732 on my Nexus 5X with 1080x1920...

JavaScript (ES6), 32 bytes
(_=screen)=>_.width+"x"+_.height

Outputs as function return. Add f= at the beginning and invoke like f(). Uses parameter-initializing to initialize the parameter _ to screen object. The rest is self-explanatory.

f=(_=screen)=>_.width+"x"+_.height
console.log(f())

Note: Passing an argument to this function will cause it to fail.

JavaScript (Previous Solution), 35 bytes

with(screen)alert(width+"x"+height)

Never thought I will one day use with! I don't think this can be golfed further.

If REPLs are allowed, s=screen,s.width+"x"+s.height (29 characters) also works.

Oooh. Good use of default argument value.

The 35-byte solution can save five bytes by not bothering to alert: with(screen)(width+'x'+height) just returns the appropriate string.

@SIGSEGV Thank you! :)

This answer is fundamentally flawed. I can cheat it by zooming my browser in and out!

@Arjun I just did. Are you calling me a liar?

@Arjun I'm using the zoom feature in the browser itself and getting anywhere from a few hundred to 4000 in width. Intriguingly the ratio seems to stay the same.

@Arjun your answer isn't giving the resolution of the PC monitor. It's giving the ratio of the browser window based on the current zoom level. At least, that's what Mozilla Firefox is doing.

@TheGreatDuck It must be a bug in Firefox. The specification defines screen.width as the width of user's screen, and the same goes for screen.height. (And I was not calling you a liar, I was just saying that there  must be a misunderstanding :) ) (I advise you to check the solution in some another browser as this works perfect form me)

@Arjun nope. It seems to be a bug all over the place: https://www.quirksmode.org/blog/archives/2013/11/screenwidth_is.html Here's the chart backing that article https://www.quirksmode.org/mobile/tableViewport.html

@TheGreatDuck That's an old post. New browsers tend to work fine. Try upgrading your browser and then running this. Probably, that will fix the problem! :)

@Arjun my browser is already upgraded to the current version. If you read that post, you'd see that the variable you are describing is being phased out as the role you expect it to be. Newer browsers are trying to make it be the resolution of the window when in full screen mode rather than the pixel count of the monitor viewing it. The point behind that is to make websites scale properly when zooming in and out.

from the article "screen.width should return the dimensions of the ideal viewport. The older implementation returns the number of physical device pixels, but that’s now seen as wrong.". Note: you are relying upon the "older implementation". Also, the charts page has this note: "Last major update on 16 October 2016.". That's only 6 months ago.

Can confirm, zooming messes things up in current versions of Firefox.

Eyy dudes use chrome firefox sux

Come on, are you guys even trying: _=screen,_.width+"x"+_.height, 29 bytes

_=>outerWidth+'x'+outerHeight for 29 bytes, only works in browser JS environments

@BassdropCumberwubwubwub That returns the browser width and height, not the monitor resolution.

TI-BASIC, 30 32 29 bytes (non-competing?)
*sigh* TI-BASIC takes an extra byte for every lowercase letter.
+2 thanks to @Timtech
-3 thanks to @Timtech
:If ΔX>.1
:Then
:Disp "96x64
:Else
:Disp "320x240

This only works because TI-BASIC can only be run on calculators with two different screen resolutions: 96 by 64 and 320 by 240. I just test to see which screen I have by setting the Zoom to something that is different depending on screen resolution then outputting the correct resolution.
I'm marking this as non-competing for now, since it is hard coded.

Thats a clever abuse ;)

You can save by not using ZDecimal and then using a different Xmax comparison, at least one byte. Also, I think you need to use lowercase x which is two bytes (x2) instead of the one-byte uppercase equivalent.

@Timtech I have to use a two byte Zoom (like ZDecimal) because the default zoom (ZStandard) is the same on both calculators. I'll fix the capitalization, though.

Oh, I see what you mean. If you use ZStandard though, would ΔX be different then between the calculators? Also, ZDecimal is only one byte, so this is 31 bytes.

Ah. You're right. ΔX is different on the calculators. Thanks!

For some reason, my instant reaction is "that's valid, but wouldn't be valid if there were only one possible screen resolution", but that point of view seems internally inconsistent. So I'm really unsure as to whether this is cheating or not.

You don't have to use the lowercase 'x' since lowercase letters aren't usable out of the box (at least for TI-83/84, which I assume this answer applies to).

@Jakob Lowercase letters are possible on TI 84 CE's, they're just two bytes apiece. OP specified that this challenge is case sensitive.

JavaScript (ES6), 32 bytes
_=>(s=screen).width+'x'+s.height

console.log((_=>(s=screen).width+'x'+s.height)())

the lambda version is acceptable

_=>(s=screen).width+'x'+s.height saves a byte

@FelipeNardiBatista Thanks, the thought just occurred to me as well :)

Good job! +1 :)

I love how all the JS entries have been consistently shorter than a large number of the other answers. Almost never happens.

macOS, bash, awk, grep, tr, 51 52 bytes
/*/*/sy*r SPDisplaysDataType|awk '/so/{print$2$3$4}'

Runs system_profiler, gets the SPDisplaysDataType information, searches for the first so in Resolution, and prints the screen resolution. For multiple screens, this prints all resolutions.

The prior, malcompliant variant:
/*/*/sy*r SPDisplaysDataType|grep so|tr -d 'R :a-w'

I just ran this on my MacBook Pro with a second display attached. I got 2880x1800\n1920x1080@60Hz (two lines). I don't know if that disqualifies this... or?

@Floris did OP specify how to behave when there are multiple screens?

No - but the format @60Hz is clearly not in spec.

I guess you could tack on a |sed 1q, bringing the byte count up to 58 bytes.

I fixed the non-compliance by switching to awk and having one extra byte. :)

Javascript, 36 bytes

s=screen;alert(s.width+"x"+s.height)

Processing 3, 37 bytes
fullScreen();print(width+"x"+height);

fullScreen() causes the app to launch with the maximum dimensions - the display resolution.
One byte less than the obvious
print(displayWidth+"x"+displayHeight);

AutoHotKey, 34 bytes
SysGet,w,0
SysGet,h,1
Send,%w%x%h%

Save this in a file with extension .AHK and run it from a command prompt

Why not use Send rather than MsgBox?

@EngineerToast thanks! That saved two bytes

PowerShell, 67 60 55 Bytes
-7 thanks to Martin Ender
-5 (actually 12!) from Leaky Nun , Regex wizardry is beyond me.
This is long but not longer than the horrendous System.Windows.Forms.SystemInformation.PrimaryMonitorSize solution
(gwmi win32_videocontroller|% v*n)-replace" |x \d+\D+$"

first we Get-WmiObject(gwmi) to retrieve the Win32_VideoController object, which contains a member named VideoModeDescription, which is a string in the format of 1920 x 1080 x 4294967296 colors, then I run a regex replace to get correct format.
PS H:\> (gwmi win32_videocontroller|% v*n)-replace" |x \d+\D+$"
1920x1080

I think (gwmi win32_videocontroller|% v*n)-replace" |x[^x]+$" shaves a couple of bytes by tweaking the regex.

C (Windows), 79 78 77 bytes
Thanks to @Johan du Toit for saving a byte!
#import<windows.h>
#define G GetSystemMetrics
f(){printf("%dx%d",G(0),G(1));}

I was still messing around with 'GetDeviceCaps' until I saw your answer :-) You can still save 1 byte by using the following: #define G GetSystemMetrics f(){printf("%dx%d",G(0),G(1));}

Bash + xrandr, 44 characters
read -aa<<<`xrandr`
echo ${a[7]}x${a[9]::-1}

xrandr belongs to the X server, on Ubuntu is provided by x11-xserver-utils package.
Sample run:
bash-4.3$ read -aa<<<`xrandr`;echo ${a[7]}x${a[9]::-1}
1920x1080

xrandr + grep + util-linux, 30 characters
xrandr|grep -oP '\d+x\d+'|line

Thanks to:

Markasoftware for the regular expression (-11 characters)

Sample run:
bash-4.3$ xrandr|grep -oP '\d+x\d+'|line
1920x1080

I have no bash with a display, would xrandr|grep * work?

Sure. But for now the my grep and sed attempts to parse xrandr's output (https://pastebin.com/uTVcjWCq) were longer.

Maybe xrandr|grep *|cut -d' ' -f1? (using the matching line from your paste @TIO)

Ah, you mean to pick the resolution from the list by the “*” mark? Thought to that possibility, but I am not sure whether would work with multiple displays connected. As I remember, that would list each connected display's current resolution.

Ah yes it would, not sure what the OP wants in such a scenario though!

@JonathanAllan No, it wouldn't. An unescaped * is a glob that the shell expands to all files in the CWD.

...update xrandr|grep * will "work" if the  CWD is empty.

34 chars: xrandr|grep -oP '\d+x\d+(?=.+\*)' or xrandr|grep -oP '\d+x\d+'|head -1

Thank you, @Markasoftware, but actually those are 33 characters. ☺

And thank you, @manatwork, for letting me learn about line :)

Java 7, 123 114 bytes
String f(){java.awt.Dimension s=java.awt.Toolkit.getDefaultToolkit().getScreenSize();return s.width+"x"+s.height;}

This method will not work in a headless installation of Java (like on TIO) because it uses the awt libraries. Under the hood, calling getScreenSize uses the Java Native Interface to call out (typically into a C library) for the screen width and screen height.
-9 bytes thanks to Olivier Grégoire for reminding me that I can return the string instead of printing it.

I was just about to post...

@LeakyNun You and me both. +1 Poke.

Too bad the output is restricted to ...x..., because void f(){System.out.print((java.awt.Toolkit.getDefaultToolkit().getScreenSize()+"").replaceAll("[^\\d,]",""));} which outputs 1920,1200 is shorter..

@KevinCruijssen yeah I did try playing with that as well. The real "too bad" is that using regex in java is so heavy in terms of byte count.

@Poke You're indeed right. I have been able to use that what I show above with an x instead of , by using some regex replacement, but it's five bytes more than your current answer: void f(){System.out.print((java.awt.Toolkit.getDefaultToolkit().getScreenSize()+"").replaceAll("[^\\d,]","").replace(",","x"));} or void f(){System.out.print((java.awt.Toolkit.getDefaultToolkit().getScreenSize()+"").replaceAll(".*?(\\d+).*?(\\d+).*","$1x$2"));} Ah well, what isn't heavy in Java.. ;p

If you return a String instead of printing it, you could reduce it to 114 bytes. Going Java 8? The regex solution is the shortest with 103 bytes. I don't get why you limit yourself to Java 7 and printing on standard output: the challenges accept both Java 8's lambdas and value-returning functions. You should embrace them instead of gimping yourself with older versions.

@OlivierGrégoire Good point on returning... Not sure why I went with printing. Also I did forget to include the version!

@OlivierGrégoire I'm not a big fan of Java lambdas in golfing because it's not something you can drop into any old class and have it work. It's similar to imports which we as a community agree are required to be explicitly stated. I know there are meta posts on the subject but if I just stick to Java 7 then I can avoid the situation all together.

C#, 101 95 89 bytes
_=>{var s=System.Windows.Forms.Screen.PrimaryScreen.Bounds;return s.Width+"x"+s.Height;};

-6 bytes thanks to @TheLethalCoder by reminding me OP didn't mention about printing, so returning a string is also fine. And an additional -6 bytes by changing it to a lambda.

You can save 11 bytes by compiling to a Func<string>: ()=>{var s=System.Windows.Forms.Screen.PrimaryScreen.Bounds;return s.Width+"x"+s.Height;};. However, you have a return of void but you are returning a string so you need to add 2 bytes for that.

The challenge also doesn't state that you can't take input so you could add an unused input to save another byte i.e. _=>{var s=System.Windows.Forms.Screen.PrimaryScreen.Bounds;return s.Width+"x"+s.Height;};

Oh ignore the return comment you're writing the result out, you can save 6 bytes by returning it.

And unless you can think of a way to get it shorter var s=System.Windows.Forms.Screen.AllScreens[0].Bounds; would also be the same count but you could golf it with that idea in mind.

Mathematica, 51 bytes
SystemInformation[][[1,5,2,1,2,1,2,2,;;,2]]~Infix~x

This may not work for you depending on what devices you have connected (I don't know). This should always work (assuming you have at least one screen hooked up):
Infix[Last/@("FullScreenArea"/.SystemInformation["Devices","ScreenInformation"][[1]]),x]

Explanation
SystemInformation[] returns an expression of the form
SystemInformationData[{
  "Kernel" -> {__},
  "FrontEnd" -> {__},
  "Links" -> {__},
  "Parallel" -> {__},
  "Devices" -> {__},
  "Network" -> {__},
}]

We are interested in "Devices", which can be accessed directly as SystemInformation["Devices"] or as SystemInformation[][[1,5,2]]. The result will be a list of the form
{
  "ScreenInformation" -> {__},
  "GraphicsDevices" -> {__},
  "ControllerDevices" -> {__}
}

We want "ScreenInformation", which can be accessed either as SystemInformation["Devices","ScreenInformation"] or more succinctly as SystemInformation[][[1,5,2,1,2]]. The result will be of the form
{
  {
  "ScreenArea" -> {__},
  "FullScreenArea" -> {{0,w_},{0,h_}},
  "BitDepth" -> _,
  "Resolution" -> _
  },
  ___
}

The length of the list will be the number of screens you have connected. The first screen is SystemInformation[][[1,5,2,1,2,1]] and the width and height can be extracted as SystemInformation[][[1,5,2,1,2,1,2,2,;;,2]] Then we just insert an Infix x for the output format.

Octave, 41 bytes
Thanks to @Arjun and @StephenS for corrections.
fprintf('%ix%i',get(0,'ScreenSize')(3:4))

0 is a handle to the root graphics object. Its property 'ScreenSize' contains the coordinates of the screen in pixels. The third and fourth entries give the desired information.

APL (Dyalog), 23 bytes
' '⎕R'x'⍕⌽⊃⎕WG'DevCaps'

⎕WG'DevCaps' Window Get Device Capabilities
⊃ pick the first property (height, width)
⌽ reverse
⍕ format as text
' '⎕R'x' Replace spaces with "x"s

"substitute with an "x" at position 5 (the space)" this would cause problems on a small screen, e.g. 640x480 (which VMs use)

Python 2, 73 bytes
from ctypes import*
u=windll.user32.GetSystemMetrics;
print u(0),'x',u(1)

print u(0),'x',u(1) is smaller and his example (link) allows it

To clarify, If it's equivalent to the output from What is my screen resolution, It's valid. in that website, there is space between each part

@FelipeNardiBatista Updated, thanks.

Japt, 24 bytes
Ox`ØP(s×Çn)±d+"x"+ight

Test it online!
The compressed string represents with(screen)width+"x"+height. Ox evaluates this as JavaScript, and the result is implicitly printed.

C (SDL2 library) 113 88 84
(-4 chars due to @AppleShell 's help)
Yes. it compiles.
m[3];main(){SDL_Init(32);SDL_GetDesktopDisplayMode(0,m);printf("%dx%d",m[1],m[2]);}

Run with : gcc snippet.c -lSDL2 && ./a.out

I think you can shorten this by making m global and omitting int: m[3];main(){...

accessing by m+1 should be shorter than m[1] right? or isn't that possible in C but only in C++? surely printf has some dereference token

@gizmo unfortunately AFAIK there is no printf specifier that does such thing ..

xrandr + awk, 25 bytes
xrandr|awk /\*/{print\$1}

This doesn't work. grep * expands the asterisk to all files in the directory.

@Jens Corrected. Thanks for pointing out

Thanks; another hint: the proper spelling for grep|cut is awk.

It still doesn't work. It outputs *0. My xrandr output is *0   3360 x 1050   ( 889mm x 278mm )  *0.

@Jens then you need -f2 Btw, Can you check xrandr|awk '/\*/{print $2}'?

That only outputs 3360. It works only with xrandr|awk '/*/{print $2 $3 $4}'.

@Jens That's because your xrandr output 3360x1050 contains white spaces.

Python 2, 61 49 bytes
Thanks @Jonathan-allan, @felipe-nardi-batista
from Tkinter import*
print'%sx%s'%Tk().maxsize()

For single display setups, this matches the output from the site. This gives entire resolution for multiple displays.

print'x'.... saves a byte

v=Tk().maxsize(), print'%sx%s'%v saves 9 bytes.

oops, and then print'%sx%s'%Tk().maxsize() saves another 4 >_<

ZX Spectrum Basic, 10 bytes
just for completeness:
PRINT "256x192"

outputs 256x192. The Spectrum has a fixed hardwired screen resolution.

...and uses a single byte for keywords like PRINT.

bash + xdpyinfo  42  31 bytes
xdpyinfo|grep dim|cut -d' ' -f7

From man page:
xdpyinfo - is  a utility for displaying information about an X server.

@Floris @manatwork Thanks for saving a few bytes!

Crossed out 4 is still 4 :(

There is no need for spaces around the pipes; I think is safe to search for “dim” only; you can write -d\  instead of -d' '. Then when it comes to both grep for a line and cut a part of that line, usually is shorter with a single awk call: xdpyinfo|awk '/dim/&&$0=$2'.

I suspect you can grep something shorter than dimensions but I don't have xdpyinfo on my system...

Processing, 51 bytes
void setup(){fullScreen();print(width+"x"+height);}

This outputs in this format: width height. Also, the program creates a window that is the size of the screen you are using (because every Processing program creates a window by default) and this program just outputs the height and the width of this window/sketch.

Oh, the format is WIDTHxHEIGHT.

@SIGSEGV Just noticed it

Racket, 73 bytes
#!racket/gui
(let-values([(x y)(get-display-size #t)])(printf"~ax~a"x y))

Just discovered the (discouraged) shorthand for #lang. Saves a few bytes! Documentation for get-display-size.

xdpyinfo + awk, 28 bytes
$ xdpyinfo|awk /dim/{print\$2}
3360x1050

Tested on Cygwin with dual heads.

xdpyinfo|awk /dim/{print\$2} takes 28 bytes not 24

@Pandya I need new glasses :-)

Tcl/Tk, 40
puts [winfo screenw .]x[winfo screenh .]

Batch, 218 208 206 bytes
I can't golf....
@for /f %%# in ('"@wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution /format:value"')do @set %%#>nul
@echo %CurrentHorizontalResolution%x%CurrentVerticalResolution%

Ruby + xrandr, 37 bytes
puts `xrandr`.split[7..9].join[0..-2]

Alternate solution (52 bytes):
puts `xrandr`.match(/t (\d+) (x) (\d+),/)[1..3].join

Batch, 128 125 124 123 bytes
@for /f "tokens=1,2delims=x " %%A in ('wmic path Win32_VideoController get VideoModeDescription^|find "l"')do @echo %%Ax%%B

Basically the same thing as SteveFest's answer, except I grab a slightly shorter chunk of Wim32_VideoController and then I use something vaguely resembling regex to get the one line that contains the data that I want.
I have no idea why the wmic string needs to be inside of double quotes to work I needed the quotes so that I didn't need to escape the pipe, but ^ is shorter than "", and I can't believe that I can't shorten the wmic command at all.
How It Works
Ordinarily, wmic path Win32_VideoController get VideoModeDescription will display something like this:
VideoModeDescription
3440 x 1440 x 4294967296 colors

I can use findstr's super rudimentary attempt at regex find to find the letter "l," which only matches the line with the word "colors." From there, that line is delimited on spaces and the letter "x." %%A contains the first token and %%B contains the second token. After that, I just display the values.

Aw.. I've been looking for ways to shorten my code... Nice answer anyways

Red, 26 Bytes
system/view/screens/1/size

Outputs for example:
1920x1080

The code is pretty self explanatory. The 1 refers to the first screen

Bash + xdotool + tr, 35 bytes
-1 thanks to @manatwork
xdotool getdisplaygeometry|tr \  x

There are two spaces after the \
Gets geometry, then uses tr to replace spaces with x

Is enough to just escape the space, is shorter than quoting it: tr␠\␠␠x. (Used ␠ to mark spaces here just because HTML rendering collapses consecutive whitespaces.)

Python 3, 54 bytes
Python 2, 52 51 bytes
from PIL.ImageGrab import*;print'%dx%d'%grab().size

Saved 2 bytes by executing in Python 2
Saved 1 byte by changing import

Welcome to the site! I don't have PIL installed, so I can't test, but could you just do i.grab().size instead of the string formatting? I don't think it has to be exactly in the WxH format

@DJMcMayhem Hello! I thought the same thing, but OP says specific format of [width]x[height]. i.grab().size prints out a tuple as (1920, 1080). Granite that would save me 8 bytes, I'd rather go for accuracy to OPs requirements

Javascript, 42 bytes
console.log((k=screen).width+'x'+k.height)

Hello and welcome to our site! Make sure to include a byte count in your title for [tag:code-golf] questions.

Okay, thank you! Sorry, I didn't know it was a requirement.

Lithp, 116 bytes
((import html-toolkit)
(htmlOnLoad #::((var S(index(getWindow)screen))
(print(+(index S width)"x"(index S height))))))

(Line breaks added for readability)
Try it online!
Finally, my html-toolkit module gets some use! Only works in the Try it Online link, will not work from command line.
A few bytes could be saved if 1024 x 768 could be valid output. We just use (+ .. "x" .. ) to avoid print's implicit spacing.

Hmm. I tried it online, but it says 2048x1080 for a true 4K screen that's actually 4096x2160. Any idea why? Firefox 52.0 on FreeBSD 11.

No idea. I'm merely grabbing window.screen and getting the width and height attributes from it. I imagine if you opened up the Firefox console and typed in window.screen you'll see the apparently incorrect 2048x1080.

Lua (löve framework),116 bytes
f,g=love.window.setFullscreen,love.graphics function love.draw()f(1)w,h=g.getDimensions()f(0>1)g.print(w.."x"..h)end

The programm changes first to fullscreen then it gets the width and height and prints it then :)

xrandr and sh, 23 bytes
$ set `xrandr`;echo $6x$8
3360x1050

Tested on a CentOS 5 box with display redirected to a Cygwin machine with two monitors. Here the full xrandr output is
$ xrandr
 SZ:    Pixels          Physical       Refresh
*0   3360 x 1050   ( 889mm x 278mm )  *0
Current rotation - normal
Current reflection - none
Rotations possible - normal
Reflections possible - none

8th, 32 bytes
0 hw:displaysize? swap . "x" . .

Returns the device's screen resolution of the first display (0) in pixels in the required format.
Output:
1536x864

Javascript, 46 bytes
var s=screen;console.log(s.width+'x'+s.height)

I wanted to write it in the comment but I don't have reputation yet. Can someone explain to me why other solutions don't count bytes for console.log()? If they were counted then this solution would be the shortest.

MATLAB, 42 byte
a=get(0,'ScreenS');fprintf('%dx%d',a(3:4))

Uses property shortening. Other than that, this is a nice showcase of the inflexibility of MATLAB indexing, requiring a temporary variable a. fprintf prints to stdout by default.

Clojure, 86 bytes
Shameless port of this Java answer
(#(str(.width %1)"x"(.height %1))(.getScreenSize(java.awt.Toolkit/getDefaultToolkit)))

PHP + GTK 2.0, 69 bytes
This whole answer was written based on http://php-gtk.eu/en/code-hints/grabbing-a-screenshot-with-gdk
<?list($W,$H)=Gdk::get_default_root_window()->get_size();echo$W,x,$H;

Basically, fetches the "root" window (entire screen) and gets it's size.

Another way (based on http://www.kksou.com/php-gtk2/sample-codes/get-the-size-of-display-screen.php):
<?$w=(new GtkWindow())->get_screen();echo$w->get_width(),x,$w->get_height();

Gets the screen where the window was created, displaying it's dimentions.

Python 2, 60 bytes
from win32api import*
u=GetSystemMetrics
print u(0),'x',u(1)

C#, 90 Bytes
()=>{var b=System.Windows.Forms.Screen.PrimaryScreen.Bounds;return b.Width+"x"+b.Height;};

This actually is quite a similiar answer to that one, which already exists, however, I'd like to add a few things. This solution acutally needs a reference to System.Windows.Forms and one to System.Drawing. Those references are not normally added for a console application, so I'm not sure wether it's valid. Therefore I wrote a solution without references, however this has 580 287 Bytes:
using System;using System.Runtime.InteropServices;class P{static void Main()=>Console.Write(G().Item1+"x"+G().Item2);static(int,int)G()=>(GetSystemMetrics(0),GetSystemMetrics(1));[DllImport("User32.dll",ExactSpelling=true,CharSet=CharSet.Auto)]static extern int GetSystemMetrics(int n);}

Here's the solution with line breaks:
using System;
using System.Runtime.InteropServices;

class P
{
    static void Main() => Console.Write(G().Item1 + "x" + G().Item2);
    static (int, int) G() => (GetSystemMetrics(0), GetSystemMetrics(1));

    [DllImport("User32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
    static extern int GetSystemMetrics(int n);
}

This solution was created with the huge help of AdamSchiavone on Stackoverflow.
I also wrote a C# Interactive programm with 123 Bytes, which automatically adds the references, so it can be executed on every machine without problems and without having the reference problems:
#r "System.Windows.Forms"
#r "System.Drawing"
var b=System.Windows.Forms.Screen.PrimaryScreen.Bounds;b.Width+"x"+b.Height

This basically is the same as the first one, but it adds the reference automatically and as it is executed in the interactive, you don't need the return statement, you can simply leave away the semicolon.

Your missing the ; on the end of your func.

Side note: Those references aren't added normally for a Console application, they are for a Windows Forms one. Either way they don't need adding into the byte count.

@TheLethalCoder You're right, edited my answer.

In your large solution you can change internal static class Program to just class P, you could probably remove static from the methods and use new P(), you can change IntPtr to int I believe, Move the i() out of the struct probably, change the struct to a class and probably a couple of other things.

@TheLethalCoder I'll update my answer. Unfortunately, I won't have time to do this till tomorrow.

C#, 89 bytes
_=>{var s=System.Windows.Forms.Screen.PrimaryScreen.Bounds;return s.Width+"x"+s.Height;};

VBA (32-Bit), 110 Bytes
Locally declared windows function and anonymous VBE immediate window function that takes no input and outputs to the VBE Immediate window.
Note: The below may be made into a 64-bit compatible function by the addition of PtrSafe  following Declare
Declare Function GetSystemMetrics Lib"user32.dll"(ByVal i&)As Long

?GetSystemMetrics(0)&"x"&GetSystemMetrics(1)

VBScript, 201 bytes
For Each x in CreateObject("WbemScripting.SWbemLocator").ConnectServer(".","root\cimv2").ExecQuery("SELECT * FROM WIN32_VIDEOCONTROLLER")
a=Split(x.VideoModeDescription," x ")
msgbox a(0)&"x"&a(1)
Next

Connection to Local WMI is eating up all the bytes.....

VB6, 57 bytes
Sub a:Msgbox Screen.Width/15&"x"&Screen.Height/15:End Sub

Bash, 21 bytes
tr , x</*/*/*/fb0/v*

If the device has frame buffer you can query /sys/class/graphics/fb0/virtual_size to get resolution.
Width and Height are delimited by , so tr translates to x.
Path to the file is shortened by using * to the point there are no ambiguities.

On my machine that glob also matches 4 files + 1 symlink in /usr/share/games/fortunes/vi, so I have to specify …/0/… instead of …/f/… (not sure whether you can count on that “0”, I'm not framebuffer fan).

That depends upon directories.

several upvoted answers do it as well, edited for a less likely to hapen option

Note that this gives the size of the console frame buffer, which for X11 is often quite different from the size of the screen you are sitting in front of when logged in over the network.

console framebuffer is fbcon, not fb0. This outputs resolution of screen connected as framebuffer device fb0.


text:
Zero an arbitrarily large cell in Brainf***
Your task is to write a piece of code that zeros the current cell in the Brainfuck variant that, each cell can contain a signed integer of arbitrarily large magnitude, instead of the normal 0 to 255.
You may assume there are l cells to the left and r cells to the right of the current cell that are initially zero. You program may only access these l+r+1 cells. After your code ends it should leave the l+r extra cells zero and the pointer to the current cell at the original position.
You may not use any input/output.
The code with smallest l+r wins. If there is a tie, the shortest code wins. It is recommended to also state the time complexity of your program for reference, where n is the absolute value of the original integer in the current cell.
Useful tools
You can test a Brainfuck program in this variation using this interpreter on TIO by mbomb007.
You can also use the interpreter in this answer by boothby (other Python answers probably also work, but I didn't test).

I have tagged it code-golf because I think we will reach the optimal l+r quickly.

It sounds like from your comment, you meant arbitrarily large magnitude integer, which may be positive or negative. This is a difference in english dialect for some people, so it might be helpful to clarify that it can be very positive or very negative.

@jimmy23013 Do you have a BF interpreter with signed cells we can use for this?

@mbomb007 https://codegolf.stackexchange.com/a/3085/25180 but probably too golfy...

This is a code challenge, not code golf. The length of the code does not play any part in the scoring.

@Mego It is the tiebreaker. I don't think it is that challenging to reduce l+r. So after we got the optimal l+r it would be the real challenge, which is code-golf.

Then this is a chameleon challenge, where the l+r is a distraction from the "real" challenge of golfing the code. Regardless, the primary winning condition is not shortest code, so this isn't code golf, regardless of the fact that the secondary winning condition is shortest code and will probably play more of a part in deciding the winner.

@Mego Why? In the "real" challenge, you must also get the optimal l+r, which will probably make it more difficult to reduce the code size.

@Mego I had no idea what is the best tag. So I'll leave it code-challenge as you edited until someone disagrees.

@mbomb007 The default tiebreaker is first answer to reach the tied score.

l+r = 0+2 = 2, 55 53 51 bytes
[>+[-<+>>+<]<[>]>[+[-<+<->>]<[->+<]]>[-<+>]<<]>[-]<

l+r = 1+2 = 3, 46 44 bytes
[[>+[-<+<+>>]<[<+[->->+<<]]>]>[>]<[-]<<[-]>]

My own algorithm. The pointer should begin at the number that needs to be zeroed. The time complexity is O(n^2).
How it works:

We start with the number n.
We increment one, so the number becomes n+1.
We decrement two, so the number becomes n+1-2 = n-1
We increment three, so the number becomes n-1+3 = n+2.
We decrement four, so the number becomes n+2-4 = n-2.

We repeat the process, increasing the in-/decrement each step, until we get zero.

Exactly the algorithm I thought of after I got past the "this isn't even possible" stage :P

l + r = 0 + 2 = 2; 58 bytes
>+<[>[<->>+<-]>+<<[>]>[<<+>+>-]<[->+<]>[<]>+[-<+>]<<]>[-]<

The complexity is O(n^2).
The following is my testing program generator, so you can see that I actually tried to test it in case it doesn't work...
p='''
>+<
[
>
[<->>+<-]
>+<
<[>]>
[<<+>+>-]
<
[->+<]
>[<]>
+ [-<+>]
<<
]
> [-] <
'''

p = ''.join(p.split())

cpp = '''
#include <bits/stdc++.h>
using namespace std;
void test(int q) {
long long t[3] = {q, 0, 0};
int i = 0;
ZZZ
printf("q=%d %lld %lld %lld\\n", q, t[0], t[1], t[2]);
}
int main() {
while(true) {
    int q; cin >> q; test(q);
}
}
'''

d = {
'>': '++i; assert(i<3);',
'<': '--i; assert(i>=0);',
'+': '++t[i];',
'-': '--t[i];',
'[': 'while(t[i]){',
']': '}',
}

print cpp.replace('ZZZ', ''.join(d[c] for c in p))

You can test it using the interpreter I just made. See comment

It looks like it works to me.

This has got to be the optimal l+r. Quick proof that 1 is impossible: at each point at which the spare cell hits zero, you can only store a finite amount of data in addition to the value of the original cell (in the tape head position and instruction pointer), which means that you're limited in how far you can adjust the main cell from that point in at least one direction.

@ais523 There could be other equivalent ones. It'd be interesting if someone creates l+r = 1+1.