text:
Sum the rows of the concatenated triangle
Consider the following triangle.

1
23
456
7891
01112
131415
1617181
92021222
324252627
2829303132
33343536373
839404142434
4454647484950
51525354555657
585960616263646
5666768697071727
37475767778798081

As you probably noticed, the first row is of length 1, and each row thereafter is 1 digit longer than to the previous one and that it contains the digits of the positive integers concatenated.
You will be given an integer N. Your task is to find the sum of the digits that lie on Nth row of the above triangle.
Rules

You can choose either 0 or 1 indexing. Please specify that in your answer.

Default Loopholes apply.

You can take input and provide output by any standard mean, and in any reasonable format.

This is OEIS A066548, and this sequence is the triangle itself (except that we do not remove leading zeros).

This is code-golf, so the shortest code in bytes (in every language) wins. Have fun golfing!

Test Cases
Input  |  Output

0  |  1
1  |  5
2  |  15
3  |  25
4  |  5
5  |  15
6  |  25
7  |  20
8  |  33
9  |  33
10 |  43
11 |  46
12 |  64

Note that the above are 0-indexed. If you are looking for 1-indexed test cases, increment the input by 1.
On a quite unrelated note, I recently changed my profile picture and that inspired me to write this challenge.

Husk, 7 bytes
1-indexed
Σ!CNṁdN

Try it online!
Explanation
    ṁ     Map then concatenate
     d    Integer digits
      N   Over the natural numbers
  CN      Cut into lists of lengths corresponding to the natural numbers
 !        Index it
Σ         Sum

Python 2, 69 bytes
This could probably be quite a bit shorter.
1-indexed
Edit: -7 bytes thanks to @Mr.Xcoder
lambda n:sum(map(int,"".join(map(str,range(1,n*n+1)))[~-n*n/2:][:n]))

Try it online!

n**2 is n*n.

69 bytes. Using Gauss' formula, sum(range(n)) = ~-n*n/2 = (n - 1) * n / 2

@Mr.Xcoder I think he does...

@EriktheOutgolfer You're right, my bad

05AB1E, 8 bytes
nLS¹L£θO

Try it online!
-1 thanks to Emigna.
1-indexing.

You can remove your S if you replace J with S.

@Emigna duh....

Perl 6, 47 45 42 bytes
{[~](1..$_²).substr(:1[^$_],$_).comb.sum}

Try it online!
1-indexed

Haskell, 69 64 bytes
n%x=sum[read[d]|d<-take n x]:(n+1)%drop n x
f=(1%(show=<<[1..])!!)

Try it online.
Saved 5 bytes thanks to Laikoni!
Here's the less golfed version:
-- continuous stream of digits representing
-- the concatenation of positive integers in
-- order: 1234567891011...
digitstream = show=<<[1..]

-- sequence that yields the rows of the triangle
triangle n xs |(a,b)<-splitAt n xs=a:triangle(n+1)b

digitSum xs = sum[read[d]|d<-xs]

-- sequence that sums up the digits in each row
rowSumSequence = map digitSum (triangle 1 digitstream)

-- the final function that just shows the value
-- at a given index
g=(rowSumSequence!!)

n%x=sum[read[d]|d<-take n x]:(n+1)%drop n x is some bytes shorter.

@Laikoni Thanks! Edited. I don't know why I thought the splitOn would save bytes.

Haskell, 57 bytes
f n=sum[read[d]|d<-take n$drop(div(n*n-n)2)$show=<<[1..]]

Try it online!

Mathematica, 96 bytes
(d=Flatten[IntegerDigits/@Range[#^2]];Last@Table[Tr@Take[d,{i(i+1)/2+1,(i+1)(i+2)/2}],{i,0,#}])&

Try it online!  (in order to work on mathics "Tr" has to be replaced with "Total")

Jelly, 11 bytes
²RDFṁRS$ṫCS

Try it online!
Uses 1-based indexing.
Explanation
²RDFṁRS$ṫCS  Input: n
²            Square
 R           Range, [1, n^2]
  D          Decimal digits
   F         Flatten
    ṁ        Reshape to
       $     Monadic chain
     R         Range, [1, n]
      S        Sum
        ṫ    Tail
         C   Complement, 1-n
          S  Sum

R, 119 109 108 93  88 bytes
starting to golf.... 1-indexed
function(n){for(i in 1:n+n*(n-1)/2){F=F+strtoi(substr(paste(1:n^2,collapse=""),i,i))};F}

thanks @Zachary. your presumption is correct :)
shaved 1 byte tnx to @Andrius and 15 more tnx to @user2390246
@Giuseppe - tnx for the strtoi. new to me. 5 bytes down :)

I don't think you need the y=, nor the parens around n*(n-1)/2+1, and the language's name presumably isn't [R].

you can save 1 byte by changing as.integer with as.double

wicked @AndriusZ tnx.

Rather than x, use F as this is already initialised to 0.

Also, 1:n+a-1 gives the same as a:(a+n-1). In that case, you don't need to define a in advance, you can just put it straight in the for expression. That will also allow you to cancel out a +1/-1.

strtoi instead of as.double, 1:n^2 instead of 1:(n^2) because ^ has precedence over :

79 bytes. Used substring instead of substr since really this is just a sum over the indices of the substring. Also, it's always good to include a TIO link for your solutions :) +1, great work.

@Giuseppe this is great - I tried to figure our how to get rid of the for loop.......

Emojicode, 182 bytes
©a➡l➗✖a➕a 1 2ti 0▶lt➕i 1tti 10s 0gt➖l a a➕s g 10s

Defines a method called © that takes a  and returns a . 1-indexed.
Try it online!
Explanation:
Note: a lot of emoji choice doesn't make much sense in Emojicode 0.5. It's 0.x, after all. 0.6 will fix this, so if you want to learn this (because who wouldn't want to), I recommend waiting a moment.
Emojicode is an object-oriented programming language featuring generics, protocols, optionals and closures, but this program uses no closures, and all generics and protocols can be considered implicit.
The program operates on only a few types:  is the integer type and  is the string type. Additionally s appear in conditions, which can take a value of either  (true) or  (false).
There are currently no operators in Emojicode, so addition, comparsions and other operations that are normally operators are implemented as functions, effectively making the expressions use prefix notation. Operators are also planned in 0.6.
©a➡

© takes one  called a and returns a .
 l➗✖a➕a 1 2

Declare a frozen ("constant") l equal to the a-th triangular number (formula in prefix notation). This represents the length of the string of numbers we need to generate.
 t

Assign an empty string to the variable t.
 i 0

Assign i = 0.
 ▶lt

While the l is greater than the length of t
  ➕i 1

i += 1
  tti 10

Append the textual representation of i in base 10 to t.

End loop
 s 0

Assign s = 0
 gt➖l a a

Take a substring of t starting at l - a (a - 1th triangular number) of length a, iterate over all characters
  ➕s g 10

Convert the character to string, parse integer in base-10, unwrap the optional (nothingness is returned if the string is not a number) and add to the s variable.

End loop
 s

Return s

End method.

PHP, 66+1 bytes
for($p=($n=$argn)*-~$n/2;$n--;)$r+=join(range(1,$p))[--$p];echo$r;

Run as pipe with -nR or try it online.
requires PHP 5.4 or later for indexing the expression.

Pyth, 24 bytes
u+GsH<>jkS+*QQ2/*QhQ2hQ0

Try it here: http://pyth.herokuapp.com/

APL, 28 26 25 bytes
{+/⍎¨⍵↑⌽(+/⍳⍵)↑∊,/⍕¨⍳⍵×⍵}

Uses 1-based indexing
Try it online!
How?

⍳⍵×⍵, 1 through the input squared
⍕¨, turn each element into a string
∊,/, concatenate them together
(+/⍳⍵)↑, grab the rows up to the input
⍵↑⌽, grab the desired row
⍎¨, turn each element into a number
+/, sum

Clojure v1.8, 154 bytes
1-indexed
(fn[n](loop[i 1 s(clojure.string/join""(take(* n n)(iterate inc 1)))](if(= i n)(apply +(map #(Character/digit % 10)(take n s)))(recur(inc i)(subs s i)))))

Try it online!
Explanation
(take(* n n)(iterate inc 1))  Take the first N*N numbers
(clojure.string/join""...)    Combine them into a string
(loop[i 1 ...](if(= i n)...)  Loop N times
(apply +(map #(Character/digit % 10)(take n s)))  Take N characters from the string, convert to integers and add them
(recur(inc i)(subs s i))      Increment iterator, remove i characters from string

Java 8, 116 98 bytes
n->{String t="";int r=0,i=0;for(;i++<n*n;t+=i);for(i=0;i<n;r+=t.charAt(i+++~-n*n/2)-48);return r;}

1-indexed
-18 bytes thanks to @Nevay
Explanation:
Try it here.
n->{                             // Method with integer as both parameter and return-type
  String t="";                   //  Triangle-String
  int r=0,                       //  Result-integer
      i=0;                       //  Index-integer
  for(;i++<n*n;                  //  Loop (1) from 0 to `n^2` (exclusive)
    t+=i                         //   And append String `t` with all the numbers
  );                             //  End of loop (1)
  for(i=0;i<n;                   //  Loop (2) from 0 to `n` (exclusive)
    r+=t.charAt(i+++~-n*n/2)-48  //   And raise the sum `r` by the digits
  );                             //  End of loop (2)
  return r;                      //  Return the resulting sum of digits
}                                // End of method

98 bytes: n->{String r="";int i=0,x=0;for(;x++<n*n;r+=x);for(x=0;x<n;)i+=r.charAt(x+++~-n*n/2)-48;return i;}.

R, 99, 105, 97 bytes
a=diag(N<-scan());a[upper.tri(a,T)]=strtoi(strsplit(paste(1:N^2,collapse=""),"")[[1]]);sum(a[,N])

1-indexed
ungolfed version
a <- diag(N<-scan())
a[upper.tri(a, diag=TRUE)] <- strtoi(strsplit(paste(1:N^2,
                                                  collapse=""),
                                            "")[[1]])
sum(a[,N])

Try it here!
thanks to @Giuseppe for saving 8 bytes

@Giuseppe in the description is mentioned: "You will be given an integer N." and this N is used in my solution. Or maybe I misunderstood something.

See the linked "any standard mean" in the description :)

@Giuseppe change and used your suggestion about strtoi

97 bytes, with a warning message. It's always good to include a link to TIO in your description so others can test it!

@Giuseppe I don't know no R, but maybe a function would use less bytes?

@Giuseppe the same warning message I have too. thanks for saving me 8 bytes

@NieDzejkob see for example Zahiro Mor's response for proof of that suggestion.

Perl 6, 44 bytes
{[+] (1..*).flatmap(*.comb).rotor(1..*)[$_]}

Test it
Expanded:
{
  [+]        # reduce the result of the following using &infix«+»

  ( 1 .. * ) # infinite range starting at 1

  .flatmap(  # map, then flatten
    *.comb   # split into digits (100 ⇒ 1,0,0)
  )

  .rotor(    # break the sequence into pieces
    1 .. *   # start with 1 value, then 2 values, then 3, etc.
  )\

  [$_]       # index into that infinite sequence
}

Jelly, 16 bytes
Ṭ€Ẏ0;œṗ²D€Ẏ$$⁸ịS

Try it online!
1-indexed.

SOGL V0.12, 15 13 bytes
²Δr∑.δ∑⌡kmčr∑

Try it Here!
1-indexed.
While working on this I fixed a bug that made ∑ not work on number arrays and that m incorrectly took implicit input.
Explanation:
²              square the input
 Δ             get a range from 1 to that
  r∑           join as a string
    .δ         create a range 0 - input-1
      ∑        sum that
       ⌡       that many times do
        k        remove the 1st character of the joined string
         m     mold to the length of the input
          č    chop into characters
           r∑  convert to numbers and sum

JavaScript (ES6), 78 65 bytes

f=
n=>eval([...(g=n=>n?g(n-1)+n:``)(n*n).substr(n*~-n/2,n)].join`+`)
<input type=number min=1 oninput=o.textContent=f(this.value)><pre id=o>

1-indexed. Edit: Saved 13 bytes thanks to @tsh.

n=>eval([...(g=n=>n?g(n-1)+n:'')(n*n)].join<+>.substr(~-n*n-1,2*n))

@tsh Still golfier to put the join`+`  at the end...

C++, 180 bytes
-17 bytes thanks to Zacharý
Index start at 1
#include<string>
int s(int n){std::string t;int i=0,p=0;for(;i<=n;)p+=i++;for(i=0;t.size()<p;t+=std::to_string(++i));t=t.substr(0,p).substr(p-n);i=0;for(auto&a:t)i+=a-48;return i;}

Changing the last line to this should save two bytes: int s(int n){++n;std::string t;int i=0,p=0;for(;i<=n;)p+=i++;for(i=0;t.size()<p;t+=std::to_string(++i));t=t.substr(0,p);t=t.substr(t.size()-n);i=0;for(auto&a:t)i+=a-48;return i;}

Also, if you're currently taking input as 0-indexed, you can convert it to 1-index and drop the ++n;

@Zacharý Thanks. Btw, your code contains invisible unicode character for some reasons

Which one, my C++ suggestion, or my APL? APL uses its own codepage, and will probably not show up right if you do not have the right font.

@Zacharý The C++ suggestion you wrote in the comment. There's like 2 unicode characters before a zero, making errors like "0" identifier is unknown in visual studio. Same thing for to_string and size. You can see it if you copy-paste the code in notepad++, and convert encoding to ANSI, you will see some ?? in the editor

Would it be possible to combine the substr statements into this?
t=t.substr(0,p).substr(p-n)? (If the size of t.substr(0,p) isn't p, replace p with the appropriate value)

@Zacharý I've tested, and no, it does not produce the same results.

You sure about that? It's producing the same result with g++ for me: https://tio.run/##vZFNTsQwDIXX9BSWkFCsUFQQi1aGdzCU4AAptGFmaplHjbBjN2UvSoQt2rNjk5zl@/uwMMbanYVjXew7DOY/eJFk4nI4NB4Gk6hrwkmTs@1sEhKrItnuMtqPPeVHExgbCqC1rvSklSvKU@MsrNJFE281B5vebidKaEUlseZQ/iqaK26/7nt0GJP6p47LMD64XZG1d@3qgxUteAjBdN9y3/8Xdz/GvjM0@ZDA8l0zvpmOTU6UMbvIpusFDqUxbN5PjoPDS3G2EtQew8ExlM/DSUWFHGOYsYAyo8lMI1tYRIFbFh/FMzXVdvwE

I get that, with MSVC : 1 | 1, 2 | 5, 3 | 15, 4 | 18, 5 | 5, 6 | 15, 7 | 24, 8 | 11, 9 | 33, 10 | 33, 11 | 40, 12 | 38, 13 | 64

Does replacing t.size() with p work?

@Zacharý Yes it does. Your TIO link is undecodable, btw. After thinking about it, it's normal that doing t.substr(0,p).substr(t.size()-n) doesn't work, it's because t is not reassigned before the 2nd substr method call

Oh, whoops. What I meant to do was combine the two substr statements into t.substr(0,p).substr(p-n)! Which is what you just did. Also, sorry for the spam, but I have one more golf: t=t.substr(0,p).substr(p-n);i=0; => t=t.substr(i=0,p).substr(p-n);.

Pyth,  15 14  13 bytes
s<>sMjkS^Q2sU

Try it here! or Check out the test suite.
13 bytes alternatives:
ssM<>jkS^Q2sU
ssM<>jkS*QQsU
s<>sMjkS^Q2sU

How?
s<>sMjkS^Q2sU    Full program. Q means input.

       S^Q2      The range [1, Q^2].
     jk          Join as a String.
   sM            Convert each character to integer.
  >              All the elements of the above, but the first Q*(Q-1)/2.
 <               All the element of the above but the last Q.
s                Sum.
                 Output implicitly.

><>, 141+2 Bytes
::1+* 2,01\
@}})?/:0$\>$:@{{:
:%a:/?(1:< ,a-]{+1[4
  /~/     \+1~\
1:<]{+1[+4@:-1\?(
{1-}>{:}1(?\@1-@+
    \0}~{{\\n;
@:{{:<-1~$\!?)}}
     ~

1-Indexed
+2b for -v flag
Tio.run really doesn't seem to like my ><> programs recently... It can still be verified on https://fishlanguage.com though. Input goes in 'initial stack'.
Edit: It turns out tio.run doesn't like it because it handles '[' and ']' differently to fishlanguage.com. fishlanguage.com reverses the stack when creating or removing a new stack, but tio.run doesn't.

Perl 5, 62 + 1 (-p) = 63 bytes
$_=eval(substr((join'',1..$_*$_),($_**2-$_)/2,$_)=~s/./+$&/gr)

Try it online!
Result is 1 indexed.
How?
Concatenate more than enough digits together, then skip the irrelevant ones at the beginning (length of skip is sum of integers from 1 to n-1).  Take the next n digits, place a + in front of each one, then evaluate that equation.

Ruby, 64 bytes
->n{s=[*1..n*n]*""
eval (1..n).map{s.slice!(0,_1).chars}[-1]*?+}

Attempt This Online!

Japt -x, 13 12 bytes
1-indexed
ogU²õ ¬sUo x

Try it
ogU²õ ¬sUo x     :Implicit input of integer U
o                :Range [0,U)
 g               :Index each into (0-based)
  U²             :  U squared
    õ            :  Range [1,U²]
      ¬          :  Join
       s         :  Slice from 0-based index
        Uo       :    Range [0,U)
           x     :    Reduced by addition
                 :Implicit output of sum of resulting array


text:
Calculate the area of a regular polygon
Task
Given an integer, n, where 3 <= n < 2^32, calculate the area of a regular n-gon, with an apothem of 1, using the formula A = n * tan(π / n).

The apothem of a regular polygon is a line segment from the center to the midpoint of one of its sides.

Output the area of this regular polygon as a floating point value showing no fewer than eight decimal places (i.e. 1.24217000, 3.14159265).
Tests
In: 3
Out: 5.1961524227

In: 6
Out: 3.4641016151

In: 10
Out: 3.2491969623

In: 20
Out: 3.1676888065

In: 99
Out: 3.1426476062

In: 1697
Out: 3.1415962425

In: 15000
Out: 3.1415926995

Note: The output values in the sample cases above each show ten decimal places -- two more than required.

Mathematica, 16 bytes
N[Tan[Pi/#]#,9]&

Try it online!
of course mathematica has built-ins for this
Area@*RegularPolygon

Area@RegularPolygon should be Area@*RegularPolygon; as it is now, it cannot be captured in a variable. That is, f = Area@RegularPolygon; f[3] does not work. Relevant meta discussion

@JungHwanMin ok, I fixed it.(although I didn't post it as an answer.I was just showing the built-ins for fun)

Actually, 5 bytes
╦/Tß*

Try it online!

How?

╦/Tß*   Full program.

╦       Push Pi.
 /      Divide ^ by the input.
  T     Tangent.
   ß*   Multiply by the input.
        Output implicitly.

Alternative: ß╦/T*. o_O Actually actually beats Jelly!!!

2-byte builtin names...

yes, I know... @EriktheOutgolfer 3 byte built-ins in Pyth though >.<

+1 for "Actually actually beats Jelly!!!" That pun never gets old. ;)

Java (OpenJDK 9), 24 bytes
i->i*Math.tan(Math.PI/i)

Try it online!

x87 Machine Code, 11 bytes
D9 EB
DA 31
D9 F2
DD D8
DA 09
C3

The above bytes of code define a function that calculates the area of a regular n-gon with an apothem of 1. It uses x87 FPU instructions (the classic floating-point unit on the x86 processors) to do this computation.
Following a standard x86 register-based calling convention (in this case, __fastcall), the function's argument is a pointer to the integer, passed in the ECX register. The function's result is a floating-point value, returned at the top of the x87 floating-point stack (register ST0).
Try it online!
Ungolfed assembly mnemonics:
D9 EB  fldpi                  ; load constant PI at top of FPU stack
DA 31  fidiv DWORD PTR [ecx]  ; divide PI by integer input (loaded from pointer
                              ;   in ECX), leaving result at top of FPU stack
D9 F2  fptan                  ; compute tangent of value at top of FPU stack
DD D8  fstp  st0              ; pop junk value (FPTAN pushes 1.0 onto stack)
DA 09  fimul DWORD PTR [ecx]  ; multiply by integer input (again, loaded via ECX)
C3     ret                    ; return control to caller

As you can see, this is basically just a straightforward computation of the given formula,
     result = n * tan(π / n)
Only a couple of interesting things bear pointing out:

The x87 FPU has a dedicated instruction for loading the constant value PI (FLDPI). This was rarely used, even back in the day (and obviously much less so now), but it's shorter in size than embedding a constant into your binary and loading that.
The x87 FPU instruction to calculate tangent, FPTAN, replaces the value of the input register (the top of the FPU stack) with the result, but also pushes a constant 1.0 onto the top of the FPU stack. This is done for backwards compatibility with the 8087 (I have no idea why this was done on the 8087; probably a bug). That means we need to pop this unneeded value off of the stack. The fastest and shortest way to do that is a simple FSTP st0, like we use here. We could have also done a multiply-and-pop, since multiplying by 1.0 won't change the result, but this is also 2 bytes (so no win in code size), will probably execute more slowly, and may introduce unnecessary indeterminacy into the result.

Although a modern programmer or compiler would use the SSE (and later) instruction set, rather than the aging x87, this would require more code to implement, as there's no single instruction to compute a tangent in these newer ISAs.

Jelly, 6 bytes
ØP÷ÆT×

Try it online!
Jelly's π builtin has >8 decimal places.

Nice. I was trying to figure this out (and Jelly in its entirety), right now. :-)

Brachylog, 9 bytes
;π/₍*₄;?×

Try it online!

JavaScript (ES6), 24 bytes
x=>x*Math.tan(Math.PI/x)

Try it

o.innerText=(f=
x=>x*Math.tan(Math.PI/x)
)(+i.value);oninput=_=>o.innerText=f(+i.value)
<input id=i min=3 type=number value=3><pre id=o>

Sakura, 4 bytes
*ĳ/π

This is expanded to *ĳ/π⓪⓪, which is
*              *
 ĳ     tan(   )
  /         /
   π       π
    ⓪        n
     ⓪          n

Non-competing isn't a thing any more.

@Shaggy what do you mean? Since when?

See this Meta, Tux.

R, 25 bytes
cat((n=scan())*tan(pi/n))

Input from stdin, output to stdout.
Try it online!

Works without cat(). 5 bytes less.

Japt, 7 bytes
*MtMP/U

Test it

Explanation
Just implements the forumla, where Mt is tan, MP is pi and U is the input.

MATL, 7 bytes
YPy/Z,*

Try it online!

Ohm v2, 7 bytes
απ/ÆT³*

Try it online!

How?

απ/ÆT³*   Full Program

απ        Push Pi.
  /       Divided by the input.
   ÆT     Tangent.
     ³*   Multiplied by the input.
          Implicitly output.

Perl, 14 + 16 = 30
perl -MMath::Trig -ple'$_*=tan(pi/$_)'

14 bytes for the program proper, and 16 for the command line switches

var'aq, 51 bytes
'Ij latlh HeHmI' tam boqHa''egh qojmI' boq'egh cha'

Explanation
'Ij        - read from STDIN
latlh      - duplicate top of stack
HeHmI'     - push PI onto stack
tam        - swap first 2 elements on stack
boqHa''egh - divide
qojmI'     - take tangent
boq'egh    - multiply
cha'       - print

Common Lisp, 29 bytes
(lambda(n)(* n(tan(/ pi n))))

Try it online!

Python 2, 45 bytes
from math import*
n=input()
print n*tan(pi/n)

Try it online!

38 bytes

In challanges like this I really dislike using lambda to save bytes by just putting the print in the footer...
Therefore: 44 bytes

@Simon why? Functions are a valid submission - you can either output a value, or return it from a function. The print in the footer isn't required.

Pyth, 9 bytes
*.tc.n0Q2

Test suite.

How?

*.tc.n0Q2    Full program. Q means input.

    .n0      Pi.
   c         Divided by:
       Q     The input.
 .t     2    Tangent.
*        Q   Multiply by the input.
             Output implicitly.

Gaia, 5 bytes
₵P÷ṫ×

Try it online!

How?

₵P÷ṫ×   Full program.

₵P      Push Pi.
  ÷     Divided by the input.
   ṫ    Tangent.
    ×   Multiply by the input.

Swift, 35 bytes
With compiler warnings:
import Foundation
{tan(M_PI/$0)*$0}

Try it here!
Without compiler warnings, 40 bytes:
import Foundation
{tan(Double.pi/$0)*$0}

Excel, 16 bytes
=A1*TAN(PI()/A1)

Pari/GP, 14 bytes
n->tan(Pi/n)*n

Try it online!

RPNGolf 0.6/0.7, 12 bytes
tbp-1mBsdmcc

My first post using RPNGolf, my new stack-based language!
This is a full program that reads an integer from standard input and prints the output to standard output (without a trailing newline).
Explanation:
tb              # push user input from STDIN as int
  p             # duplicate top of stack
   -1           # push -1
     mB         # pop i, push inverse cosine of i
       s        # swap top two items on the stack
        d       # pop b, pop a, push a/b
         mc     # pop i, push tangent of i
           c    # pop b, pop a, push a*b
# RPNGolf implicity prints the stack upon normal exit

Prolog (SWI), 25 bytes
f(X,Y):-X is Y*tan(pi/Y).

Try it online!
This is my first submission to codegolf, hope I'm doing alright. Written as a function.

IBM/Lotus Notes Formula Language, 13 bytes
a*@Tan(@Pi/a)

Input taken via a field named a on the same form as the field containing the formula. No TIO available so screenshot of all test cases shown below:

PowerShell, 38 bytes
param($n)$n*[math]::tan([math]::pi/$n)

Try it online!
Does exactly what it says on the tin, just takes a little longer due to the lengthy [math]:: .NET calls.

Ruby, 27 bytes
->n{n*Math.tan(Math::PI/n)}

Try it online!

C# (Mono C# compiler), 24 bytes

=>n*Math.Tan(Math.PI/n)

Try it online!

Unfortunately, this is neither a complete program, not a function. Instead it is a snippet, which isn't allowed here. However, I think that you can add n=> to the start to make this into an arrow function (take this with a pinch of salt, I don't know C#) which is valid.

You can place the snippet into a System.Func<T, T>, which would take a float as input and another one as output. The declaration would look like this: System.Func<float, float> f = n=>n*Math.Tan(Math.PI/n);, where the bytecount would start at n=>. In my example i omitted two of your brackets to save 2 bytes ;)

Factor, 19 bytes
[ pi over / tan * ]

Try it online!

05AB1E, 7 bytes
žqI/Å¼*

Try it online or verify all test cases.
Explanation:
žq       # Push PI (3.141592653589793)
  I/     # Divide it by the input
    Å¼   # Get the tangent of this
      *  # Multiply it by the (implicit) input
         # (after which the result is output implicitly)

Pyt, 6 bytes
Đπ/⅟ť*

Try it online!
Đ            implicit input (n); duplicate on stack
 π           push pi
  /          divide n by pi
   ⅟         take the reciprocal
    ť        tan(pi/n)
     *       multiply by n; implicit print

source: Stack Exchange

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

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

sort: votes


text:
Help! My calculator malfunctions!
Introduction
My calculator is behaving weird. Sometimes when I type in an 8 it displays a 2. And sometimes when I type in a 6 it displays a +. Some buttons are mixed up!
Could anyone help me determine which?
Challenge:
Input: List of incorrect equations, with correct results.
Output: The two buttons that are swapped.
For example:
An input could be:
123    = 3
8423   = 252
4+4    = 8
4*7-10 = 417
9/3    = 3
42-9   = -36

For which the expected outputs are: 2 and *.
Why? Because ALL the equations would be correct if we swap the 2's and *'s:
1*3    = 3
84*3   = 252
4+4    = 8
427-10 = 417
9/3    = 3
4*-9   = -36

Challenge rules:

Input can be in any reasonable format. Can be a single string with space delimited; a string-list or -array; a list with equations and another list with the correct results. Your call. Please state which input format you've used!
NOTE: This also means you are allowed to input the test case -5--15 as -5- -15 or -5 - -15. However, a number resulting in -- should either be inputted without spaces or with a space between every digit. So test case 9119 can be inputted like 9119 or 9 1 1 9 (reason 91 19 isn't allowed is because you can then be guided by the space for finding - -). So spaces are (somewhat) optional and allowed.
Output format can be in any reasonable format as well. Can be two characters; a single two-character string; a string-list containing the two characters. Your call. Again, please state which output format you've used!
You are allowed to use any distinct 14 outputs that map to 0123456789+-*/. So you are even allowed to output two distinct integers if you want to (again, please specify the mapping you've used, if any).
You only have to support integers. So there won't be any test cases like 1/8=0.125 or 1/8=0.
Arithmetic operands you'll have to support: addition (+); subtraction (-); multiplication (* or × or ·); division (/ or ÷). (NOTE: Characters between parenthesis are only added as clarification.)
You'll have to support negative numbers. This means - can be interpreted in the equation as both a mathematical operand or a negative indicator.
You can assume the given incorrect equations and supposed correct equations are always valid (so there won't be things like 4-/2 or 9+-+8 for example).
The incorrect input-equations can contain a division by 0, but the corrected and expected equations will never contain division by 0.
The incorrect input-equations can already be correct even if you swap the intended buttons back.
A given input equation can be irrelevant for the buttons  to swap (like the 4+4=8 and 9/3=3 equations, with the swapped buttons 2 and *).
You can assume there will always be only one possible swap that can be made with the given test cases.
Both buttons to swap will always be present in at least one of the incorrect equations.

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code.
Also, please add an explanation if necessary.

Test cases:
Input:
123    = 3
8423   = 252
4+4    = 8
4*7-10 = 417
9/3    = 3
42-9   = -36

Output: 2 *

Input:
4/2   = 6
3/0   = 3
0/8+2 = 4
95-5  = 90
4+2   = 2

Output: + /

Input:
7+4    = 11
5-15   = 46
212-23 = -2121

Output: 1 -

Input:
4+8/2-9*1 = -5
99/3-13   = 20
1+2+3+4   = 10
4-3-2-1   = -6

Output: 2 4

Input:
18/18  = 1
98-8   = 90
55*88  = 4840
-5--15 = 10

Ouput: 5 8

Input:
9119    = 18
5-3     = 513
8*-9    = 152
13116/3 = -1

Output: 1 -

"real division" means we have to support floats?

@EriktheOutgolfer Oops.. Copied that from a previous arithmetic challenge of mine. Removed, and as answer to your question, no you only have to deal with integers.

Oh, so we'll never have to deal with something like 4/3=1 right?

@EriktheOutgolfer That's right. I'll specify that more clearly in the challenge.

I'd suggest a test case where a correct equation contains --. For example 1991 = 2, -/3 = 3. (Many languages confuse this with the decrement operator.)

@nwellnhof Added a test case with 9119=18 -> 9--9=18. And also specified that you are allowed to input the test cases with spaces, since I've seen multiple people add code to change -5--15 to -5- -15 programmatically, while just inputting it with a space is perfectly allowed.

Is it also allowed to input 9119 as 91 19?

@nwellnhof Hmm.. Why not. If you want you can even add spaces between every number. I was doubting for a moment, since technically 9119 is one number, and you don't know beforehand if it should be replaced with --. If I had a test case like 9119=9229 and 2+2=2 [1 2], it would be weird to input it like 91 19. On the other hand, you don't need to output 92 29, but only 1 2 (the pair to swap), so yes, you are allowed to input it like 91 19.

The problem is that adding a space in 91 19 if the solution is 9--9 and no space in 9119 if the solution is 9229 requires knowledge about the solution when creating the test cases. If this were allowed, I could simply add a space only before the swapped characters and the solution could be immediately derived from the test case.

@nwellnhof Hmm, good point, hadn't thought of that. I actually meant you should either always add a space in numbers like 9119, or never. Not sometimes based on the test case. Will have to think about it for a moment, but maybe 9119 as single number is a more natural input-format (although spaces between every character would still be allowed).

Maybe we can say that your calculator just has a display problem but it still formatting the input correctly with a space before the unary -, no matter what character is shown instead? ;-)

Is evaluation left-to-right, or * and / before + and binary -?

@aschepler It's * and / before + and -. So you'd input the entire equation, and then click = to get the result.

@Arnauld I can understand why you'd say that. ;) But there are a few minor problems: you always know it's - - when a space is present between two equal characters/digits. And if I would add spaces between every mathematical operand (+-*/), you can be guided by the spaces regarding solving the swaps, as nwellnhof mentioned above. So I thought about it carefully, but 9119 should be either 9119 or 9 1 1 9. (You can easily alter your answer anyway by adding a .replace('--','- -').) Sorry that I said it was allowed in my comment before.. I wish these things were said in the Sandbox :(

Perl 6, 132 113 bytes
Thanks to Jo King for -19 bytes.
->\e,$r {first {($!=e.trans($_=>.flip))ne e&&try "all {$!.&{S:g/\-/- /}} Z==$r".EVAL},[X~] (|^10,|<+ - * />)xx 2}

Try it online!
Input is a comma-separated string of equations and a comma-separated string of results (hope this is OK). Output is a string containing the two swapped buttons.
Correctly handles --. Might product false positives for ---, ++, **, or //, but I couldn't come up with a test case.

You don't have to handle ---;++;**;//; or other things like *+ etc. The only double adjacent non-digit you'll have to support is --. Also, if I understand your code correctly, you won't need .subst('-','- ', since inputting the test case -5--15 with a space is allowed. You aren't the first to add code to add this space programmatically, so I'll specify this more clearly in the challenge description.

@KevinCruijssen I might have to handle things like ** because they have a meaning as Perl 6 expressions and might cause false positives. 1992 = 1 could be 1**2 = 1 or 1//2 = 1, for example. The subst is for cases where the correct equation contains --, for example the new test case you added.

Your answer is currently the one with the least amount of bytes, so I'll accept it for now. If someone comes up with something shorter, the check might shift again.

113 bytes

JavaScript (ES7), 159 158 bytes
Edit: new version to comply with the updated rules regarding --
Saved 1 byte thanks to @Shaggy
Takes input in currying syntax (e)(r) where e is the array of equations and r is the array of expected results. Returns an array of characters.
e=>r=>(l=[...2**29+'4+-*/']).filter(x=>l.some(y=>eval("try{eval((S=(s=`[${e}]`).replace(/./g,c=>c==x?y:c==y?x:c)).split`--`.join`+`)+''==r&S!=s}catch(e){}")))

Test cases

let f =

e=>r=>(l=[...2**29+'4+-*/']).filter(x=>l.some(y=>eval("try{eval((S=(s=`[${e}]`).replace(/./g,c=>c==x?y:c==y?x:c)).split`--`.join`+`)+''==r&S!=s}catch(e){}")))

console.log(JSON.stringify(f
  ([ '123', '8423', '4+4', '4*7-10', '9/3', '42-9' ])
  ([ 3, 252, 8, 417, 3, -36 ])
));

console.log(JSON.stringify(f
  ([ '4/2', '3/0', '0/8+2', '95-5', '4+2' ])
  ([ 6, 3, 4, 90, 2 ])
));

console.log(JSON.stringify(f
  ([ '7+4', '5-15', '212-23' ])
  ([ 11, 46, -2121 ])
));

console.log(JSON.stringify(f
  ([ '4+8/2-9*1', '99/3-13', '1+2+3+4', '4-3-2-1' ])
  ([ -5, 20, 10, -6 ])
));

console.log(JSON.stringify(f
  ([ '18/18', '98-8', '55*88', '-5--15' ])
  ([ 1, 90, 4840, 10 ])
));

console.log(JSON.stringify(f
  ([ '9119', '5-3', '8*-9', '13116/3' ])
  ([ 18, 513, 152, -1 ])
));

Formatted and commented
e => r =>                                  // given e and r
  (l = [...2 ** 29 + '4+-*/'])             // generate l = [...'5368709124+-*/']
  .filter(x =>                             // for each character x of l
    l.some(y =>                            // for each character y of l
      eval("try {                          // we need to 'try', because we don't know
        eval(                              // whether the following expression is valid
          (S = (s = `[${e}]`).             // s = list of equations coerced to a string
            replace(/./g, c =>             // S =
              c == x ? y : c == y ? x : c  //   s with x and y exchanged
            )                              // end of replace()
          ).split`--`.join`+`              // replace '--' with '+'
        ) + '' == r                        // does the resulting list match r?
        & S != s                           // and was at least one character modified?
      } catch(e){}")                       // if we try, we oughta catch
    )                                      // end of some()
  )                                        // end of filter()

I think you can save a byte by evaling the try / catch: https://codepen.io/anon/pen/rzRrLp.

@Shaggy Ah yes, nice one. Thanks!

It looks like this might work for 139 bytes.

Yeah, I just ran a full test suite and spotted that.

Doesn't work for 1991 = 2. The solution should be 1--1 = 2 with 9 and - swapped.

Oracle SQL & PL/SQL, 458 Bytes

Input can be in any reasonable format. [...] a list with equations and another list with the correct results.

Compile the PL/SQL function (210 bytes):
CREATE FUNCTION f(x CHAR,y CHAR)RETURN NUMBER IS o NUMBER;BEGIN EXECUTE IMMEDIATE 'BEGIN :1:='||REPLACE(x,'--','- -')||';END;'USING OUT o;RETURN CASE o WHEN y THEN 1 END;EXCEPTION WHEN OTHERS THEN RETURN 0;END;

Run the SQL (248 bytes):
WITH r(v)AS(SELECT SUBSTR('1234567890-+*/',LEVEL,1)FROM DUAL CONNECT BY LEVEL<15)SELECT r.v,s.v FROM T,r,r s WHERE r.v<>s.v GROUP BY r.v,s.v HAVING SUM(f(TRANSLATE(x,r.v||s.v,s.v||r.v),y))=(SELECT COUNT(1)FROM T)AND SUM(INSTR(x,r.v)+INSTR(x,s.v))>0

After having create a table T with the test data:
CREATE TABLE T(X,Y) AS
  SELECT '123',    3     FROM DUAL UNION ALL
  SELECT '8423',   252   FROM DUAL UNION ALL
  SELECT '4+4',    8     FROM DUAL UNION ALL
  SELECT '4*7-10', 417   FROM DUAL UNION ALL
  SELECT '9/3',    3     FROM DUAL UNION ALL
  SELECT '42-9',   -36   FROM DUAL

Output:
V V_1
- ---
2 *
* 2

Previous Version:
Assumed a string input like '123  = 3':
Same PL/SQL function and the SQL (322 bytes):
WITH r(v)AS(SELECT SUBSTR('1234567890-+*/',LEVEL,1)FROM DUAL CONNECT BY LEVEL<15),y(x,y)AS(SELECT REGEXP_SUBSTR(t,'[^=]+'),REGEXP_SUBSTR(t,'-?\d+$')FROM T)SELECT r.v,s.v FROM y,r,r s WHERE r.v<>s.v GROUP BY r.v,s.v HAVING SUM(f(TRANSLATE(x,r.v||s.v,s.v||r.v),y))=(SELECT COUNT(1)FROM T)AND SUM(INSTR(x,r.v)+INSTR(x,s.v))>0

After having create a table T with the test data:
CREATE TABLE T(T) AS
  SELECT '123    = 3'   FROM DUAL UNION ALL
  SELECT '8423   = 252' FROM DUAL UNION ALL
  SELECT '4+4    = 8'   FROM DUAL UNION ALL
  SELECT '4*7-10 = 417' FROM DUAL UNION ALL
  SELECT '9/3    = 3'   FROM DUAL UNION ALL
  SELECT '42-9   = -36' FROM DUAL;

Output:
V V_1
- ---
2 *
* 2

Update - Testing:
SQL Fiddle
Oracle 11g R2 Schema Setup:
CREATE FUNCTION F(x CHAR,y CHAR)RETURN NUMBER IS o NUMBER;BEGIN EXECUTE IMMEDIATE 'BEGIN :1:='||REPLACE(x,'--','- -')||';END;'USING OUT o;RETURN CASE o WHEN y THEN 1 END;EXCEPTION WHEN OTHERS THEN RETURN 0;END;
/

CREATE TABLE A(X,Y) AS
  SELECT '123',    3     FROM DUAL UNION ALL
  SELECT '8423',   252   FROM DUAL UNION ALL
  SELECT '4+4',    8     FROM DUAL UNION ALL
  SELECT '4*7-10', 417   FROM DUAL UNION ALL
  SELECT '9/3',    3     FROM DUAL UNION ALL
  SELECT '42-9',   -36   FROM DUAL
/

CREATE TABLE B(X,Y) AS
  SELECT '4/2',    6     FROM DUAL UNION ALL
  SELECT '3/0',    3     FROM DUAL UNION ALL
  SELECT '0/8+2',  4     FROM DUAL UNION ALL
  SELECT '95-5',   90    FROM DUAL UNION ALL
  SELECT '4+2',    2     FROM DUAL
/

CREATE TABLE C(X,Y) AS
  SELECT '7+4',    11    FROM DUAL UNION ALL
  SELECT '5-15',   46    FROM DUAL UNION ALL
  SELECT '212-23', -2121 FROM DUAL
/

CREATE TABLE D(X,Y) AS
  SELECT '4+8/2-9*1', -5 FROM DUAL UNION ALL
  SELECT '99/3-13',   20 FROM DUAL UNION ALL
  SELECT '1+2+3+4',   10 FROM DUAL UNION ALL
  SELECT '4-3-2-1',   -6 FROM DUAL
/

CREATE TABLE E(X,Y) AS
  SELECT '18/18',  1     FROM DUAL UNION ALL
  SELECT '98-8',   90    FROM DUAL UNION ALL
  SELECT '55*88',  4840  FROM DUAL UNION ALL
  SELECT '-5--15', 10    FROM DUAL
/

CREATE TABLE G(X,Y) AS
  SELECT '9119',    18   FROM DUAL UNION ALL
  SELECT '5-3',     513  FROM DUAL UNION ALL
  SELECT '8*-9',    152  FROM DUAL UNION ALL
  SELECT '13116/3', -1   FROM DUAL
/

Query 1:
WITH r(v)AS(SELECT SUBSTR('1234567890-+*/',LEVEL,1)FROM DUAL CONNECT BY LEVEL<15)SELECT r.v,s.v FROM A,r,r s WHERE r.v<>s.v GROUP BY r.v,s.v HAVING SUM(f(TRANSLATE(x,r.v||s.v,s.v||r.v),y))=(SELECT COUNT(1)FROM A)AND SUM(INSTR(x,r.v)+INSTR(x,s.v))>0

Results:
| V | V |
|---|---|
| 2 | * |
| * | 2 |

Query 2:
WITH r(v)AS(SELECT SUBSTR('1234567890-+*/',LEVEL,1)FROM DUAL CONNECT BY LEVEL<15)SELECT r.v,s.v FROM B,r,r s WHERE r.v<>s.v GROUP BY r.v,s.v HAVING SUM(f(TRANSLATE(x,r.v||s.v,s.v||r.v),y))=(SELECT COUNT(1)FROM B)AND SUM(INSTR(x,r.v)+INSTR(x,s.v))>0

Results:
| V | V |
|---|---|
| + | / |
| / | + |

Query 3:
WITH r(v)AS(SELECT SUBSTR('1234567890-+*/',LEVEL,1)FROM DUAL CONNECT BY LEVEL<15)SELECT r.v,s.v FROM C,r,r s WHERE r.v<>s.v GROUP BY r.v,s.v HAVING SUM(f(TRANSLATE(x,r.v||s.v,s.v||r.v),y))=(SELECT COUNT(1)FROM C)AND SUM(INSTR(x,r.v)+INSTR(x,s.v))>0

Results:
| V | V |
|---|---|
| 1 | - |
| - | 1 |

Query 4:
WITH r(v)AS(SELECT SUBSTR('1234567890-+*/',LEVEL,1)FROM DUAL CONNECT BY LEVEL<15)SELECT r.v,s.v FROM D,r,r s WHERE r.v<>s.v GROUP BY r.v,s.v HAVING SUM(f(TRANSLATE(x,r.v||s.v,s.v||r.v),y))=(SELECT COUNT(1)FROM D)AND SUM(INSTR(x,r.v)+INSTR(x,s.v))>0

Results:
| V | V |
|---|---|
| 2 | 4 |
| 4 | 2 |

Query 5:
WITH r(v)AS(SELECT SUBSTR('1234567890-+*/',LEVEL,1)FROM DUAL CONNECT BY LEVEL<15)SELECT r.v,s.v FROM E,r,r s WHERE r.v<>s.v GROUP BY r.v,s.v HAVING SUM(f(TRANSLATE(x,r.v||s.v,s.v||r.v),y))=(SELECT COUNT(1)FROM E)AND SUM(INSTR(x,r.v)+INSTR(x,s.v))>0

Results:
| V | V |
|---|---|
| 5 | 8 |
| 8 | 5 |

Query 6:
WITH r(v)AS(SELECT SUBSTR('1234567890-+*/',LEVEL,1)FROM DUAL CONNECT BY LEVEL<15)SELECT r.v,s.v FROM G,r,r s WHERE r.v<>s.v GROUP BY r.v,s.v HAVING SUM(f(TRANSLATE(x,r.v||s.v,s.v||r.v),y))=(SELECT COUNT(1)FROM G)AND SUM(INSTR(x,r.v)+INSTR(x,s.v))>0

Results:
| V | V |
|---|---|
| 1 | - |
| - | 1 |

No need for ||REPLACE(x,'--','- -')||, input/output format is flexible, so you are allowed to input -5--15 as -5- -15 if you want to. Also, what would be the easiest way for me to verify all the test cases work, especially the last one? Is a TIO-link somehow possible?

Or is the ||REPLACE(x,'--','- -')|| used for an expected correct equation, like the last test case I've added?

@KevinCruijssen -- starts a comment in SQL, so either the test cases need to be formulated so that -- never occurs in the equation (replacing it with - -) or it needs some defensive coding to militate for that.

So for the last test case 13116/3 = -1 would need to be written as 131 16/3 = -1 to remove that call to REPLACE.

Ah ok, so the replace is indeed used for the expected correct equations. Thanks for adding the SQL fiddle, +1 from me.

+1 for using a language that's terribly useless for this kind of challenge.

Python 2, 204, 199, 193, 173, 165 bytes

From 199 bytes to 193 bytes thanks to Mr. Xcode
From 193 bytes to
173 bytes thanks to Halvard Hummel

s=input()
r=str.replace
t=set(''.join(zip(*s)[0]))
for i in t:
 for j in t:
	try:
	 if all(eval(r(r(r(e,i,'$'),j,i),'$',j))==v*(i<j)for e,v in s):print i,j
	except:0

Try it online!

I think it fails for the last test case.

@Mr.Xcoder thanx for the remark, I'm fixing it..

@Mr.Xcoder here is the corrected version

193 bytes

173 bytes

@HalvardHummel very nice

Powershell, 222 209 192 bytes
param($x)1..13|%{0..(($i=$_)-1)|%{$a,$b='+-*/0123456789'[$i,$_]
$a+$b|?{!($x|%{$e,$r=$_-split'='
try{$r-(-join$(switch($e|% t*y){$a{$b}$b{$a}default{$_}})-replace'-',' -'|iex)}catch{1}}|gu)}}}

Test script and explanation:
$f={

param($x)                               # array of strings with equations
1..13|%{                                #
    0..(($i=$_)-1)|%{                   # $i and $_ contains unique couples of different indecies
        $a,$b='+-*/0123456789'[$i,$_]  # $a and $b contains buttons to swap
        $g=$x|%{                        # for each equation from array
            $e,$r=$_-split'='           # split incorrect expression and correct result
            $e=-join$(switch($e|% t*y){ # swap buttons for each symbol in the expression
                $a{$b}
                $b{$a}
                default{$_}
            })
            $e=$e-replace'-',' -'       # insert a space before each '-'.
                                        # It need to work with negative numbers.
                                        # For example, '4--1' throws an exception, '4 - -1' returns '5'
            try{$r-($e|iex)}catch{1}    # Try to calc $e as powershell expression
                                        # return 0 if the expression result equal to the result of the calculation
                                        # return non zero integer otherwise
        }|gu                            # Get-unique of calculation for each equation
        if(!$g){                        # if $g is 0 or $null
                                        # then all calculations returns true
            $a+$b                       # Ok, return the couple of buttons
        }
    }
}

}

@(
    ,('2*','123=3','8423=252','4+4=8','4*7-10=417','9/3=3','42-9=-36')
    ,('/+','4/2=6','3/0=3','0/8+2=4','95-5=90','4+2=2')
    ,('1-','7+4=11','5-15=46','212-23=-2121')
    ,('42','4+8/2-9*1=-5','99/3-13=20','1+2+3+4=10','4-3-2-1=-6')
    ,('1-','9119=18','5-3=513','8*-9=152','13116/3=-1')
) | % {
    $e,$x=$_
    $r=&$f $x
    "$($e-eq$r): $r : $x"
}

Output:
True: 2* : 123=3 8423=252 4+4=8 4*7-10=417 9/3=3 42-9=-36
True: /+ : 4/2=6 3/0=3 0/8+2=4 95-5=90 4+2=2
True: 1- : 7+4=11 5-15=46 212-23=-2121
True: 42 : 4+8/2-9*1=-5 99/3-13=20 1+2+3+4=10 4-3-2-1=-6
True: 1- : 9119=18 5-3=513 8*-9=152 13116/3=-1

05AB1E, 21 bytes
SÙãʒË_}ʒ¹sÂ‡„--'+:.EQ

Input as two lists, first being the equations and second being the results. Output as a filtered list of pairs with both rotations (i.e. [["2","*"],["*","2"]]).
Try it online or verify all test cases. (NOTE: Uses the legacy version of 05AB1E in the TIO, because .E is disabled in the newer version on TIO. Because of that, an additional ï (cast to integer) is added, because in the legacy version of 05AB1E 1.0 and 1 inside lists were not equal.)
Explanation:
S              # Convert the (implicit) input-list of equations to a list of characters
               # (which implicitly flattens)
               #  i.e. ["18/18","98-8","55*88","-5--15"]
               #   → ["1","8","/","1","8","9","8","-","8","5","5","*","8","8","-","5","-","-","1","5"]
 Ù             # Only leave all unique characters
               #  → ["1","8","/","9","-","5","*"]
  ã            # Cartesian product with itself; creating each possible pair of characters
               #  → [["1","1"],["1","8"],["1","/"],["1","9"],["1","-"],["1","5"],["1","*"],["8","1"],["8","8"],["8","/"],["8","9"],["8","-"],["8","5"],["8","*"],["/","1"],["/","8"],["/","/"],["/","9"],["/","-"],["/","5"],["/","*"],["9","1"],["9","8"],["9","/"],["9","9"],["9","-"],["9","5"],["9","*"],["-","1"],["-","8"],["-","/"],["-","9"],["-","-"],["-","5"],["-","*"],["5","1"],["5","8"],["5","/"],["5","9"],["5","-"],["5","5"],["5","*"],["*","1"],["*","8"],["*","/"],["*","9"],["*","-"],["*","5"],["*","*"]]
    ʒ  }       # Filter it by:
     Ë_        #  Where both characters are unique
               #   i.e. → [["1","8"],["1","/"],["1","9"],["1","-"],["1","5"],["1","*"],["8","1"],["8","/"],["8","9"],["8","-"],["8","5"],["8","*"],["/","1"],["/","8"],["/","9"],["/","-"],["/","5"],["/","*"],["9","1"],["9","8"],["9","/"],["9","-"],["9","5"],["9","*"],["-","1"],["-","8"],["-","/"],["-","9"],["-","5"],["-","*"],["5","1"],["5","8"],["5","/"],["5","9"],["5","-"],["5","*"],["*","1"],["*","8"],["*","/"],["*","9"],["*","-"],["*","5"]]
    ʒ          # Then filter the pairs again by:
     ¹         #  Push the first input-list with equations
      s        #  Swap to take the pair we're filtering
       Â       #  Bifurcate it (short for Duplicate and Reverse)
        ‡      #  Transliterate; replacing the characters at the same indices in the input-list
               #   i.e. ["18/18","98-8","55*88","-5--15"] and ["8","5"]
               #    → ["15/15","95-5","88*55","-8--18"]
               #   i.e. ["9119","5-3","8*-9","13116/3"] and ["1","-"]
               #    → ["9--9","513","8*19","-3--6/3"]
      „--'+:  '#  Then replace all "--" with a "+"
               #   → ["15/15","95-5","88*55","-8+18"]
               #   → ["9+9","513","8*19","-3+6/3"]
      .E       #  And evaluate the strings with Python eval
               #   → [1.0,90,4840,10]
               #   → [18,513,152,-1.0]
        Q      #  And then check if this evaluated list is equal to the (implicit) second input
               #   i.e. [1.0,90,4840,10] and [1,90,4840,10] → 1 (truthy)
               #   i.e. [18,513,152,-1.0] and [18,513,152,-1] → 1 (truthy)
               # (and output the result implicitly)
               #   i.e. [["8","5"],["5","8"]
               #   i.e. [["1","-"],["-","1"]

license: 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:
Can I Settle Down?
In The Settlers of Catan board game, there are five resource types: Brick, Log, Ore, Wheat, and Sheep. Building a settlement costs a Brick, a Log, a Wheat, and a Sheep. However, you can also trade in four identical resources to get a resource of a different type. For instance, if you had four ores in your hand, you could trade all of them in and get one sheep.
Your job is to determine whether or not I can build a settlement, given my hand.
Your Task
Input will be a sequence of the letters B, L, O, W, and S, taken in any reasonable format. These letters correspond to the five resource types given above. You should output whether or not I have the resources necessary to build a settlement, taking into account the possibility of trading four of a kind.
This is code-golf, so shortest code in bytes wins.
Notes

You do not have to output what trades I need to perform or how many settlements I could build. A simple "yes" or "no" will do.
You may not assume that the input is in any specific order. In particular, you may not assume that resources of the same type are grouped together, so OBLSO is a valid input.
This is decision-problem, so you may use any value you want to mean "yes" and "no", as long as the two chosen values are distinct and consistent.
The only rules we're concerned with here are the ones listed above. More complicated Settlers of Catan rules like trading with other players or at harbours are not relevant here.
The input characters (B, L, O, W, S) can be substituted with other values if it is easier for your particular language of choice, so long as there are five distinct inputs. If you use other input values, please specify them in your answer.

Examples
BLWS -> Yes
OOOOWLB -> Yes (trade four O for a S)
OOW -> No
BBBO -> No
(empty input) -> No
BBBBLW -> No
BBBBBLW -> Yes (trade four B for a S)
OOOOOOOOOOOOOOOO -> Yes (sixteen O; trade for B, L, W, S)
BLBLBLBLBL -> Yes (trade L for W and B for S)
BLSWBLSWBLSW -> Yes (extra, unused resources are ignored)

"Building a settlement costs a Brick, a Log, a Wheat, and a Sheep". Yes, to perform the ritual of building a settlement, you need one sheep. Wonder why there aren't any vegetarians?

@Okx , the sheep gives the milk that goes with the bread from the wheat to feed the builders while they build (they take the sheep with them at the end as payment). No animals were hurt in the building of the settlement

Is it OK for the program to require the input to be sorted?

@NieDzejkob No, requiring an ordering is specifically disallowed. Your program must be prepared to handle any sequence of the five resources.

@SilvioMayolo sorry, I don't know how I missed that

@Aganju Butter comes from milk which comes from sheep. Cheese also comes from milk. Warm clothing comes from wool which comes from sheep (though not in cold weather when you need said warm clothing). Butter makes bread more palatable and cheese also helps to do the same. Sheep can also pull on pulleys to lift up large heavy things (assuming a strong sheep and some rope).

Python 2, 54 bytes
lambda s:sum((s+"BLSW"*3).count(n)/4for n in"BLSWO")>3

Try it online!
For each of our resources, we count the number of “freedoms” given by having n of that resource. A freedom represents an opportunity to fill one of the brick-log-wheat-sheep slots we need to fill in order to settle, accounting for the fact that we can convert our resources.
For all of BLSW, having one of the resource gives us one such freedom, and every additional excess of 4 gives us another. The freedom-counting rule is like this:
* Having 1 brick/log/wheat/sheep gives 1 freedom.
* Having 5 bricks/logs/wheat/sheep gives 2 freedoms.
* Having 9 bricks/logs/wheat/sheep gives 3 freedoms.
* …

So n bricks/logs/wheat/sheep give ⌊(n+3)/4⌋ freedoms.
For ores, only the excess foursomes count. The freedom-counting rule is like this:
* Having 4 ores gives 1 freedom.
* Having 8 ores gives 2 freedoms.
* Having 12 ores gives 3 freedoms.
* …

So n ores give ⌊n/4⌋ freedoms.
Theorem: we can settle if and only if we have ≥ 4 such “freedoms”.
So we count our freedoms and check if there are ≥ 4 of them. To handle counting ores as ⌊n/4⌋ but other resources ⌊(n+3)/4⌋, we artificially inflate the counts for the other resources by 3 and then count ⌊n/4⌋ for all of them. We do this by mapping (s+"BLSW"*3).count instead of s.count.
Proof:

Suppose we can settle. Then for each of [B, L, S, W], we either (a) used 1 of that resource that we already had, or (b) sacrificed 4 of some other resource (including ores) to create it. In either case, we count at least 1 freedom by the above rules. So we have ≥ 4 freedoms.
Suppose we have 4 freedoms, k of which are due to “excesses” (every freedom from ores is an excess, and every freedom from other resources past the first one also is) and 4−k of which are witness of owning at least one brick/log/wheat/sheep (the one that gave the “first freedom”). Then we fill 4−k slots with the brick/log/wheat/sheep that gave us our first freedom, and fill the remaining k slots by converting our excesses. All 4 slots are filled and we can settle. We can obviously still do this if we have more than 4 freedoms.

This proof sucks, but I’m sleepy. I’m sure there’s a better explanation.

So say s is OOOOBLW, you end up getting sum(n/4for n in map(("OOOOBLWBBBLLLSSSWWW").count,"BLSWO"))>3...so for each of BLOWS you count how many times it appears in that starter string of "BLWS"*3, then sum it up.

Precisely! (The string is "OOOOBLWBLSWBLSWBLSW", actually, but the counts are the same, of course.)

Python map being 'backwards' always confuses me!

The space between in"BLSWO" is unnecessary in Python, isn't it? Seems to work in TIO at least..

Python 2,  52  51 bytes
-1 byte thanks to Luke (replace >=0 with <0, inverting the False/True results)
lambda h:sum(~-(h+"O").count(c)/4for c in"BOWLS")<0

An unnamed function taking a string of the characters B, O, W, L, and S (as in the OP) and returning False if you can settle or True if not.
Try it online! (coerces the output to the yes/no of the OP).
How?
This is a port of my Jelly answer. We need to make up for any missing B, W, L, or S from the remainder after using one of each of them. As such we can add an extra O to our hand, then reduce all the counts by one, then integer divide all counts by four and then sum - if the result is zero or more we can settle (either because there were no missing required resources or because we can trade to acquire the missing one(s)).
lambda h:sum(~-(h+"O").count(c)/4for c in"BOWLS")<0
lambda h:                                           - a function that takes h (a string)
                                 for c in"BOWLS"    - for each letter, c, in "BOWLS":
                h+"O"                               -   append "O" to h
               (     ).count(c)                     -   count c instances
              -                                     -   negate
             ~                                      -   bitwise not (this is -x-1)
                               /4                   -   integer divide by 4
                                                    -    (NB: -1 and 0 are not affected)
         sum(                                   )   - sum the five values
                                                 <0 - less than zero? (inverted result)

How about using False for 'yes' and True for 'no'? Then you could change >= to <, saving 1 byte.

I prefer your choice of resource ordering to that of the question!

Pyth, 14 bytes
gsm/t/+Q4d4U5Z

Try it here!
or Verify all the test cases.
Pyth,  31 27 17  16 bytes
<3s/R4/L+Q*3U4U5

Verify the test cases.
How do these work?
Explanation #1
gsm/t/+Q4d4U5Z   - Full program.

  m        U5    - Map over the range [0, 5) with a variable d.
      +Q4        - The input, with a 4 appended (this corresponds to O)
     /   d       - Count the occurrences of the current value in ^.
    t            - Decrement.
   /      4      - Integer division by 4.
 s               - Sum
g            Z   - Is non-negative (is the sum ≥ 0)?
                 - Output implicitly.

Explanation #2
<3s/R4/L+Q*3U4U5   - Full program.

          *3U4     - The range [0, 4) repeated 3 times.
        +Q         - The input with ^ appended.
      /L      U5   - Count the occurrences of each element in [0, 5) in ^.
   /R4             - Integer division of each by 4.
  s                - Sum.
<3                 - Is higher than 3?
                   - Output implicitly.

These are the codes used by my program:
B -> 0
L -> 1
S -> 2
W -> 3
O -> 4

+%ld4/ld4 -> s.Dld4

Oh, alright then.

I believe //Q4 4 can be /Q16 but I'm not really sure...

@EriktheOutgolfer It was invalid... Fails for BBBO, for example

@EriktheOutgolfer No, it's count the occurences of 4 and divide by 4.

Overloads are confusing...

Trying to make the former work...

Jelly,  13  12 bytes
;5ċÐ€5’:4S>-

A monadic link accepting a list of numbers representing the resources you own and returning 1 if you can settle down or 0 if not.
The resources are 1, 2, 3, 4, 5 where 5 represents Ore.
Try it online! or see the test-suite (using the OP IO).
How?
The idea is to first count the resources by type, then reduce all counts of B, L, W, and S by one - if we counted none for any of these four then they will now have entries of -1 - we need to acquire them from our remaining resources (This is actually achieved by adding an extra O (5) and reducing all five counts by 1). Next we integer-divide all these values by four to see how many units we may trade for with each of our remaining counts by resource type while not affecting the -1 and 0 counts (note that -1 integer-divided by four is -1, not 0). Lastly we add up the values and check if the result is greater than or equal to zero (here greater than -1 can be used since we always have integers).
;5ċÐ€5’:4S>- - Link: list of numbers (BLWSO:12345) e.g. [3,2,2,2,2,2,5,5,5,5] (WLLLLLOOOO)
;5           - concatenate a five                       [3,2,2,2,2,2,5,5,5,5,5]
     5       - literal 5
   Ð€        - map across implicit range(5) = [1,2,3,4,5]:
  ċ          -   count                                  [ 0, 5, 1, 0, 5]
      ’      - decrement (vectorises)                   [-1, 4, 0,-1, 4]
       :4    - integer divide by four                   [-1, 1, 0,-1, 1]
         S   - sum                                      0
           - - literal -1                              -1
          >  - greater than?                            1

Java 8, 101 bytes
Lambda from int[] to boolean. Assign to Function<int[], Boolean>.
a->{int h,f[]=new int[5],i=0;for(int x:a)f[x]++;for(h=f[4]/4;i<4;)h+=--f[i]>>-1|f[i++]/4;return~h<0;}

Try It Online
Input and output
Input is an array of integers from 0 to 4, inclusive. 4 represents Ore, and the other mappings are immaterial. My test cases are direct translations of those in the question, with 0 as Brick, 1 as Log, 2 as Wheat, and 3 as Sheep.
Output is whether a settlement can be built.
Ungolfed
a -> {
    int
        h,
        f[] = new int[5],
        i = 0
    ;
    for (int x : a)
        f[x]++;
    for (h = f[4] / 4; i < 4; )
        h += --f[i] >> 31 | f[i++] / 4;
    return ~h < 0;
}

Explanation
h is the number of resource quadruples available to trade. We iterate over each resource type (except Ore), incrementing h for each quadruple of extra resources we have, and decrementing where no resources are present. Then our result is whether h is nonnegative.
The line
h += --f[i] >> 31 | f[i++] / 4;

adjusts h appropriately regardless of whether there are no resources (shortage) or there is at least one resource (surplus). f[i] is decremented to account for the required resource in the surplus case, producing -1 in the shortage case. The signed right shift reduces the expression to 0 (surplus case) or -1 (shortage case), so that a bitwise OR with the number f[i++] / 4 of surplus quadruples (in the surplus case) has no effect in the shortage case but results in the number itself in the surplus case.
Acknowledgments

-9 bytes thanks to Nevay, master of bits

-3 bytes: ...for(h=f[4]/4;i<4;h+=f[i++]/4)n+=--f[i]>>-1;return~h<n;.

103 bytes: a->{int h,f[]=new int[5],i=0;for(int x:a)f[x]++;for(h=f[4]/4;i<4;h+=f[i++]/4)h+=--f[i]>>-1;return~h<0;}

101 bytes: a->{int h,f[]=new int[5],i=0;for(int x:a)f[x]++;for(h=f[4]/4;i<4;)h+=--f[i]>>-1|f[i++]/4;return~h<0;}

Now that's some juicy bit hacking!

Retina, 34 bytes
^
BBBLLLWWWSSS
O`.
((.)\2{3}.*){4}

Try it online! Explanation: Building a settlement requires 4 resources which are either your first B, L, W, or S, or any other 4 resources of the same type. This is equivalent to adding three of each of those four types of resources, and then counting to see whether you have four sets of four.

Jelly, 23 bytes
œ-4R¤©Ġs€4ẎL€>3+®e€$S>3

Try it online!
Refer to the following table for the values:
B: 1
L: 2
O: 5
W: 3
S: 4

Retina, 43 bytes
O`.
O{4}
a
}`([^a])\1{4}
$1a
O

D`[^a]
.{4}

Try it online!

Python 3, 79 78 bytes
Edit: -1 byte thanks to @Mr.Xcoder
lambda x:3<sum((a>0)+~-a*(a>1)//4for a in map(x.count,"BLSW"))+x.count("O")//4

Try it online!

If you are willing to switch to Python 2, you can do it in 77 bytes

78 in Py 3, or 76 in Py 2

@Mr. Xcoder Why don't you make a Python 2 solution?

@Jakob Because it is way too similar to Halvard's.

@Mr.Xcoder will keep it Python 3

MATL, 19 bytes
Oh!5:=s4&\w4:)ghs3>

Input is a numeric row vector where the letters are represented as numbers as follows:
B: 1
L: 2
W: 3
S: 4
O: 5

Output is 1 for truthy, 0 for falsy.
Try it online!: verify all test cases.
How it works

Count ocurrences of each resource.
Div-mod them by 4.
Count how many of the remainders for the first four resources (letters BLWS) are nonzero. This gives a number c.
Sum the quotients. This gives a number s.
Output whether c+s ≥ 4.

Commented code
Oh     % Append 0 to implicit input. This is just in case inpout is empty
!      % Convert into column vector
5:     % Push row vector [1 2 3 4 5]
=      % Compare for equality, element-wise with broadcast
s      % Sum of each column. Gives number of times that each entry of
       % [1 2 3 4 5] appears in the input
4&\    % Mod-div 4, element-wise. Pushes vector of remainders and then vector
       % of quotients of division by 4
w      % Swap. Brings remainders to top
4:)    % Get the first four entries
g      % Convert to logical. This transforms non-zero values into 1
h      % Concatenate with vector of quotients
s      % Sum
3>     % Does the result exceed 3? Implicitly display

><>, 61 bytes
510ap\~1(n;
1+$ap> i:0(?v8%:ag
0:ga:v?=5:+1<$-}$,4-%4:-}-${:)

Try it online!
Uses the following resource mapping:
O -> 0
B -> 1
L -> 2
W -> 3
S -> 4

It doesn't really matter what mapping is used, as long as they're in the range 0-4, and 0 is used for O. Makes use of the fact that looking for the combination BLWS is the same as looking for the combination OBLWS while already having an O in hand.

05AB1E, 19 bytes
0 -> Ore
1 -> Brick
2 -> Log
3 -> Wheat
4 -> Sheep
Returns 0 when false, and 1 otherwise.
{γvyDĀi¼¨}g4÷}¾)O3›

Try it online!
Explanation:
{γvyDĀi¼¨}g4÷}¾)O3› Implicit input, e.g. 0030201
{                   Sort -> 0000123
 γ                  Split into chunks of consecutive elements: [0000, 1, 2, 3]
  vy                For each chunk...
    DĀ                 ...is different than 0?
      i¼¨}                ...if true: increment the counter by 1, and
                              remove 1 element from the chunk
          g4÷         ...divide the number of elements by 4
             }      End For
              ¾     Push the counter
               )    Wrap the entire stack in a list
                O   Sum of that list
                 3> True if > 3
                    Implicit output

Non-competive solution: 17 bytes
There was a bug in 05AB1E when I first submitted that solution, where some operators badly handled empty inputs. This resulted in this solution answering 1 on an empty input.
This has now been fixed, so this solution works just fine.
The difference here is that we add an ore prior to removing one of each resource, indiscriminately, counting the number of resources removed that way. We then decrement the counter by 1 to get the correct number of B, L, W and S.
0«{γε¨g4÷¼}O¾<+3›

Try it online!

Kotlin, 131 129 bytes
Submission
fun r(i:String):Any=i.split("").groupingBy{it}.eachCount().map{when(it.key){
""->0
"O"->it.value/4
else->(it.value+3)/4}}.sum()>3

Test
fun r(i:String):Any=i.split("").groupingBy{it}.eachCount().map{when(it.key){
""->0
"O"->it.value/4
else->(it.value+3)/4}}.sum()>3

data class TestData(val input:String, val output:Boolean) {
    fun run() {
        val out = r(input)
        if (out != output) {
            throw AssertionError("Failed test: ${this} -> $out")
        }
    }
}
fun main(args: Array<String>) {
    listOf(

            TestData("BLWS", true),
            TestData("OOOOWLB", true),
            TestData("OOW", false),
            TestData("BBBO", false),
            TestData("", false),
            TestData("BBBBLW", false),
            TestData("BBBBBLW", true),
            TestData("OOOOOOOOOOOOOOOO", true),
            TestData("BLBLBLBLBL", true),
            TestData("BLSWBLSWBLSW", true)
    ).forEach(TestData::run)
    println("Test passed")
}

Cannot work on TryItOnline, but works on try.kotlinlang.org

JavaScript (SpiderMonkey), 116 bytes
s=>Array.from("BLOWS").reduce((m,c)=>Math.floor(((s+"BLSW".repeat(3)).match(new RegExp(c,'g'))||"").length/4)+m,0)>3

Try it online!
Super Clunky bad answer. I'm sure it could be cleaned up more. Method inspired by Lynn's answer in this thread.


text:
Let's make Diet Haskell
Haskell has tuples that can be written as
(a,b,c)

However this is just syntactic sugar for
(,,)a b c

In general an n tuple can be formed with n-1 ,s between (...) followed by its elements separated by spaces.  For example the 7-tuple, (1,2,3,4,5,6,7) can be formed by
(,,,,,,)1 2 3 4 5 6 7

Since Haskell does not have 1-tuples they cannot be formed.  You will also not be held responsible for empty tuples.
Nested tuples can be formed using parens to override the order of operations.
((1,2),3) == (,)((,)1 2)3

As part of our pursuit to remove all syntactic sugar from Haskell  I am going to ask you to write a program that removes syntactic sugar from Haskell's tuples as well.
Your program should take a tuple, an array, or a string representing a sugary tuple and should output a string representing a "sugar-free" tuple.  Input tuples will only ever contain positive integers or other tuples.
Since we are golfing here your output should be short.  It should not contain unnecessary

Spaces.  Spaces should be used only to separate arguments of a tuple functions and should not appear after a ) or before a (
Parentheses.  Parentheses should be used only when forming tuple functions or when nesting tuples.

This is a code-golf question so answers will be scored in bytes with fewer bytes being better.
Test cases
(1,2)     -> (,)1 2
(1,2,3)   -> (,,)1 2 3
((1,2),3) -> (,)((,)1 2)3
(1,2,3,4) -> (,,,)1 2 3 4
(1,(2,3)) -> (,)1((,)2 3)
(10,1)    -> (,)10 1

If I'm not missing anything, you cover 1-tuples but not empty tuples..? Are empty tuples valid input?

@totallyhuman You do not have to handle empty tuples.

The 5th test-case has an extra ,

@H.PWiz You mean that 2,3 should be 2 3 instead?

@EriktheOutgolfer Yes

Also by "numbers" do you mean "positive integers"?

@EriktheOutgolfer Sure, that is fine

If our language doesn't have tuples, would an array suffice?

@ConorO'Brien Sure I've already allowed that for answers.  I can't edit the question right now feel free to add it.

Suggested test cases: ((1,(2,3)),4,(5,6)) and (1,(2,3),4).

Haskell, 169 148 bytes
init.tail.fst.([]%)
p:k="(,"
l%('(':r)|(y,x:s)<-[]%r,m<-y:l=last$m%(p:s):[(p:p:(l>>k)++x:foldl(\r x->x++[' '|x>k,r>k]++r)[x]m,s)|x<',']
l%r=lex r!!0

Try it online! Takes the tuple as a string. init.tail.fst.([]%) is the anonymous main function. Bind it to e.g. f and use like f "(3,(14,1),4,7)", which yields "(,,,)3((,)14 1)4 7".
Why is the input not provided as a Haskell tuple, you ask? Because Haskell is strongly typed, a tuple (1,2) has type (Int,Int)1 and a tuple (1,(2,3)) has type (Int,(Int,Int)). Thus a function which accepts the first kind of tuple can not be applied to the second kind, and especially there can be no function which takes an arbitrary tuple2.
Explanation:

p:k="(," is a short way to assign p to '(' and k to ",".
(%) is the recursive parsing and converting function. The first argument is a list of already parsed tuple entries, the second argument is the remainder of the original string. Each call returns a tuple of the current converted tuple (as a string and enclosed in brackets) and the remainder of the string.

l%('(':r) If the string starts with an opening bracket, we need to parse a new tuple entry.
(y,x:s)<-[]%r We recursively apply % and get a tuple entry y and the remaining string splitted into the next character x and the rest of the string s.
m<-y:l We add the new entry y to the current list of already found entries l and call the result m.
The next character x is now either a comma , or a closing bracket ). The last$ <B> :[ <A> |x<','] is just a shorter way of writing if x == ')' then <A> else <B>.
So if a , is next, we need to recursively parse the next entry: m%(p:s) We prepend an opening bracket in order to end up in the right case and pass the list of already found entries m.
If otherwise x == ')', we finished the current tuple and need to do the required transformation: (p:p:(l>>k)++x:foldl(\r x->x++[' '|x>k,r>k]++r)[x]m,s)

p:p:(l>>k)++x: If we have found n entries, then m has n elements and y, the list before adding the most recently found element, has n-1 entries. This comes in handy as we need n-1 , for an n element tuple and l>>k works on lists as "concatenate the list k with itself as many times as y has elements". Thus this first part yields some string like "((,,,)".
foldl(\r x->x++[' '|x>k,r>k]++r)[x]m concatenates the elements of m (in reverse order, because by adding new entries to the front m itself was constructed in reverse order) while adding only spaces in between two elements if they are both numbers: [' '|x>k,r>k] we check if the current entries x and r are numbers by lexicographically comparing them to "," - if they are not numbers, they are already a tuple representation enclosed in brackets, and '(' < ',' holds.

If the pattern match l%('(':r) right at the beginning fails, then we end up on the last line: l%r=lex r!!0. This means we need to parse a number and return the number and the remainder of the string. Luckily there is the lex function which does exactly that (It parses the next valid Haskell token, not just numbers). However the resulting tuple is wrapped into a list, so we use !!0 to get the first element of the list.

init.tail.fst.([]%) is the main function which takes a string and applies % with an empty list to it. E.g. for an input "(1,2)", , applying ([]%) yields ("((,)1 2)",""), so the outer tuple and brackets need to be removed. fst gets the first element of the tuple, tail removes the closing bracket and init the opening one.

Edit: Many thanks to @Ørjan Johansen for golfing a total of 21 bytes!

1 Actually, the type is (Num t1, Num t) => (t, t1), but that's a diferent story.
2 Ignoring polymorphic functions like id, which cannot actually work with their input.

One could write a polymorphic function using a typeclass Desugarable, but one would have to declare instances for Int, and all tuple types.

g can be shortened to foldr1(\x r->x++[' '|x>k,r>k]++r) and inlined.

@Bergi: …and one cannot declare instances for truly all tuple types. :-) (Try: show (1,2,3,4,5,6,7,8,9,0,1,2,3,4,5) in GHCi, then add a ,6 at the end and try again.)

@wchargin 62 of them would suffice. GHC.Show just is not silly enough to do it :-)

Improving the inlining for six more bytes: Use m<-y:l, fold left instead of right, and use [x] as initial value. Try it online!

f can be anonymous: init.tail.fst.([]%).

@ØrjanJohansen Thanks a lot!

@Bergi "A 63-tuple is too large for GHC (max size is 62) Workaround: use nested tuples or define a data type" Wow, TIL!

In some answers, the input is a data structure that is or mimics a tuple. Could you not take a tuple of tuples as input? I think that would simplify and shorten the code.

@GolfWolf I'm not sure what you mean by "taking tuples of tuples" what is not already covered in the explanation why I can't use tuples. One can not use nested lists, because Haskell's  lists require all elements to be of the same type, so you can not have a list [1,[2,3]], because Int and [Int] are different types. One could however define a custom data type like data T=I Int|U[T], or use Template Haskell as this answer shows.

@Laikoni Duh! Sorry! I was so wrong. Not only I did not pay attention to your answer, but with a little more thought it would have been obvious...

@Bergi actually you could use dependently typed heterogeneous lists to represent the tuple. Just encode it with 2-tuples (cons) and unit (Nil). Though, I doubt it will safe you bytes.

Haskell, 141 bytes 138 bytes(Thanks to Ørjan Johansen)
import Language.Haskell.TH
f(TupE l)='(':tail(","<*l)++')':""%l
q%(LitE(IntegerL i):l)=q++show i++" "%l
_%(e:l)='(':f e++')':""%l
_%[]=[]

f has type Exp -> String.

Input: a Template Haskell Expression (i.e., the standard AST representation of arbitrary-type Haskell values – basically, parsed Haskell code before type checking); must represent a tuple containing only nonnegative integer numbers and other such tuples.
Output: a string containing the desugared syntax for that tuple expression.

Demo:
$ ghci TupDesugar.hs
GHCi, version 8.3.20170711: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/sagemuej/.ghc/ghci.conf
Loaded GHCi configuration from /home/sagemuej/.ghci
[1 of 1] Compiling Main             ( TupDesugar.hs, interpreted )
Ok, 1 module loaded.
*Main> :set -XTemplateHaskell -XQuasiQuotes
*Main> f <$> runQ [|(1,2)|]
"(,)1 2"
*Main> f <$> runQ [|(1,2,3)|]
"(,,)1 2 3"
*Main> f <$> runQ [|((1,2),3)|]
"(,)((,)1 2)3"
*Main> f <$> runQ [|(1,2,3,4)|]
"(,,,)1 2 3 4"
*Main> f <$> runQ [|(1,(2,3))|]
"(,)1((,)2 3)"
*Main> f <$> runQ [|(10,1)|]
"(,)10 1"

You can change ")"++ to ')': in two places, and save the space after the tail by moving it outside parentheses.

Haskell, 119 bytes
data T=I Int|U[T]
f(U t)="(("++init(t>>",")++')':foldr(\x y->f x++[' '|f x>",",y>","]++y)")"t
f(I n)=show n
init.tail.f

Try it online! This uses a custom data type T to represent tuples, that is a tuple ((1,2),3) is represented as U[U[I 1,I 2],I 3]. Example usage: init.tail.f $ U[U[I 1,I 2],I 3] yields (,)((,)1 2)3.

Python 2, 110 bytes
def f(t):
 s='('+','*~-len(t)+')';c=0
 for i in t:
	try:s+=' '*c+`+i`;c=1
	except:s+='(%s)'%f(i);c=0
 return s

Try it online!
Takes a tuple.

GNU sed, 149 82 + 2 = 84 bytes
+2 bytes for -r flag.
y/(),/<>'/
:
s/([^<>']+)'/,\1 /
t
s/ ?<(,+)([^>]+)>/((\1)\2)/
t
s/^.|(\)) |.$/\1/g

Try it online!
Explanation
y/(),/<>'/                   # Replace parens and commas with brackets and apostrophes
:
  s/([^<>']+)'/,\1 /.          # Remove each apostrophe and insert comma after <
  t                            # Branch to : if substitution was made
  s/ ?<(,+)([^>]+)>/((\1)\2)/  # Change <,,,...> to ((,,,)...)
  t                            # Branch to : if substitution was made
s/^.|(\)) |.$/\1/g           # Remove outermost ()s and extra spaces

This fails on some more complicated cases: ((1,(2,3)),4,(5,6)) and (1,(2,3),4).

@ØrjanJohansen Good catch. I'll take a look after breakfast.

JavaScript, 75 bytes
f=a=>`(${t=a.map(x=>'')})${a.map(v=>t=1/v?1/t?' '+v:v:`(${f(v)})`).join``}`

Input array of number|array, output string.
Thanks to Neil, save 2 bytes

(1/t?' ':0)+v can be 1/t?' '+v:v.

Mathematica, 94 bytes
{"(",","&/@Most@#,")",c=1>0;(xIf[j=ListQ@x,c=j;"("<>#0@x<>")",If[c,c=j;x," "<>x]])/@#}<>""&

Contains an unprintable U+F4A1, a builtin Function function.
Takes a List of integer Strings. If this is not allowed, this can be fixed by adding 10 more bytes (this version takes a List of Lists/Integers):
{"(",","&/@Most@#,")",c=1>0;(xIf[j=ListQ@x,c=j;"("<>#0@x<>")",If[c,c=j;""," "]<>ToString@x])/@#}<>""&

JavaScript (ES6), 88 84 bytes
f=a=>a.reduce((s,e)=>s+=e[0]?`(${f(e)})`:/\)$/.test(s)?e:' '+e,`(${[...a].fill``})`)

Takes an array of integers and arrays. Edit: Saved 1 byte by using s+= instead of two separate uses of s+. Saved a further 3 bytes now that I can simplify the inner ternary. If I steal @tsh's ideas then I can get it down to 76 bytes:
f=a=>a.reduce((s,e)=>s+=t=1/e?1/t?' '+e:e:`(${f(e)})`,`(${t=a.map(_=>``)})`)

Your program should take either a tuple or a string representing a sugary tuple I'd presume that an array of arrays/integers should be fine.

Sure that is allowed

Pip, 45 bytes
{Y"()"b:yJ',X#a-1Fcab.:c>0?s.cyJ(fc)bR") "')}

This is a function that takes a list as an argument. Try it online!
Commented version
; Define an anonymous function (the argument is available inside as the variable a)
{
  ; Yank the string "()" into y variable
  Y "()"
  ; Create a string of len(a)-1 commas, join y on it, and assign to b
  b: y J ',X#a-1
  ; For each item c in a
  F c a
    ; Concatenate to b the following expression
    b .:
      ; Is c integer or list?
      ; (If c is a positive integer, c>0 is true; but if c is a list, c>0 is false)
      c>0 ?
        ; If c is integer, concatenate space followed by c
        s.c
        ; If c is list, call function recursively on c and use the result to join y
        yJ(fc)
  ; Replace ") " with ")" in b and return the resulting string
  b R ") " ')
}

R, 316 bytes?
(Have to head out and not sure the proper way to count bytes... plus it's not a great solution but wanted to post it since I spent the time making it...)
p=function(x){
x=eval(parse(text=gsub("\\(","list(",x)))
f=function(j,r=T){
p=paste
s=if(r){"("}else{"(("}
o=paste0(s,p(rep(",",length(j)-1),collapse=""),")")
n=lengths(j)
for(i in seq_along(n)){
v=j[[i]]
if(n[i]>1){v=f(v,F)}
o=p(o,v)}
if(!r){o=p(o,")")}
o=gsub(" *([()]) *","\\1",o)
return(o)}
f(x)
}

Test cases:
> p("(1,2)")
[1] "(,)1 2"
> p("(1,2,3)")
[1] "(,,)1 2 3"
> p("((1,2),3)")
[1] "(,)((,)1 2)3"
> p("(1,2,3,4)")
[1] "(,,,)1 2 3 4"
> p("(1,(2,3))")
[1] "(,)1((,)2 3)"
> p("(10,1)")
[1] "(,)10 1"

It's 301 bytes: Try it online!

Golfed to 261 bytes.
I'd leave an explanation for what I changed, but ironically, I also have to go...But +1, I couldn't wrap my head around this at all; nice work!

JavaScript (ES6), 72 bytes
f=(a,b="",c="")=>a.map?b+"("+a.map(x=>'')+")"+a.map(x=>f(x,"(",")"))+c:a

Input: Array containing numbers and/or arrays
Output:string
Usage: f([...])
Completes all test cases, improvements welcome

C, 308 or 339 bytes
#include <ctype.h>
#define p putchar
f(s,e,c,i,l)char*s,*e,*c;{i=1,l=40;if(*s++==l){p(l);for(c=s;i;i+=*c==l,i-=*c==41,i+*c==45&&p(44),c++);p(41);}for(;s<e;s=c){for(i=0;isdigit(*s);s+=*s==44)for(i&&p(32),i=1;isdigit(*s);s++)p(*s);*s==l&&p(l);for(c=s,i=1;++c,c<=e&&i;i+=*c==l)i-=*c==41;f(s,c-1);*s==l&&p(41);}}
#define g(x) f(x, x+strlen(x))

308 or 339 bytes, depending on whether or not passing a pointer to the end of the input string is allowed; the last line is only there to allow passing a string literal directly without having to calculate its length.
Explanation
A pretty simple algorithm. It counts the number of commas at the current depth, prints them as a tuple constructor, then follows up with the tuple's arguments, escaped (spaces between numbers, nested tuples between parenthesis), recursively.
#include <stdio.h>
#include <ctype.h>
typedef enum { false, true } bool;

void tup2ptsfree(char *s, char *e)
{
  int depth;
  char *c;

  if (*s++ == '(') { /* If we are at the start of a tuple, write tuple function `(,,,)` (Otherwise, we are at a closing bracket or a comma) */
    putchar('(');
    /* do the search for comma's */
    c=s; /* probe without moving the original pointer */
    for (depth=1; depth != 0; c++) {
      if (*c == '(') depth++;
      if (*c == ')') depth--;
      if (*c == ',' && depth == 1) putchar(','); /* We have found a comma at the right depth, print it */
    }
    putchar(')');
  }
  while (s < e) { /* The last character is always ')', we can ignore it and save a character. */
    bool wroteNumber;
    for (wroteNumber=false; isdigit(*s); wroteNumber = true) {
      if (wroteNumber) p(' ');           /* If this is not the first number we are writing, add a space */
      while (isdigit(*s)) putchar(*s++); /* Prints the entire number */
      if (*s == ',') s++;                /* We found a ',' instead of a ')', so there might be more numbers following */
    }
    /* Add escaping parenthesis if we are expanding a tuple (Using a small if statement instead of a large branch to prevent doing the same thing twice, since the rest of the code is essentially the same for both cases). */
    if (*s == '(') putchar('(');
    /* Find a matching ')'... */
    c=s+1;
    for (depth=1; c <= e && depth != 0; c++) {
      if (*c == '(') depth++;
      if (*c == ')') depth--;
    }
    /* Found one */
    /* Note how we are looking for a matching paren twice, with slightly different parameters. */
    /* I couldn't find a way to golf this duplication away, though it might be possible. */
    /* Expand the rest of the tuple */
    tup2ptsfree(s, c-1);
    /* idem */
    if (*s == '(') putchar(')');
    /* Make the end of the last expansion the new start pointer. */
    s=c;
  }
}

#define h(x) tup2ptsfree(x, x+strlen(x))

Test cases and application
#include <stdio.h>

#define ARRAYSIZE(arr) (sizeof(arr)/sizeof(*arr))
static char *examples[] = {
  "(1,2)",
  "(10,1)",
  "(1,2,3)",
  "(1,2,3,4)",
  "((1,2),3)",
  "(1,(2,3))",
  "(1,(2,3),4)",
  "((1,2),(3,4))",
  "((1,(2,3)),4,(5,6))",
  "((1,((2,3), 4)),5,(6,7))",
  "(42,48)",
  "(1,2,3,4,5,6,7)"
};

int main(void)
{
  int i;
  for (i=0; i < ARRAYSIZE(examples); i++) {
    printf("%-32s | \"", examples[i]);
    g(examples[i]); /* Test with golfed version */
    printf("\"\n");
    printf("%-32s | \"", examples[i]);
    h(examples[i]); /* Test with original version */
    printf("\"\n");
  }
}


text:
Compute the Wilson numbers
Given a positive integer n, compute the nth Wilson number W(n) where

and e = 1 if n has a primitive root modulo n, otherwise e = -1. In other words, n has a primitive root if there does not exist an integer x where 1 < x < n-1 and x2 = 1 mod n.

This is code-golf so create the shortest code for a function or program that computes the nth Wilson number for an input integer n > 0.
You may use either 1-based or 0-based indexing. You may also choose to output the first n Wilson numbers.
This is the OEIS sequence A157249.

Test Cases
n  W(n)
1  2
2  1
3  1
4  1
5  5
6  1
7  103
8  13
9  249
10 19
11 329891
12 32
13 36846277
14 1379
15 59793
16 126689
17 1230752346353
18 4727
19 336967037143579
20 436486
21 2252263619
22 56815333
23 48869596859895986087
24 1549256
25 1654529071288638505

Also, Oeis divides by n afterwards

@EriktheOutgolfer I added what is meant by having a primitive root.

Are we supposed to divide by n?

As far as I'm aware, if k = 1 and e = -1, the result of the product would be 0. (sorry asking many questions but I need clarifications for my answer :p)

1 has a primitive root according to the oeis

@H.PWiz I take it as saying that the input must have the primitive root, not k, if the latter it should be fixed.

@EriktheOutgolfer (it took me a while to realize that) the e is outside the summation

@LeakyNun Hmm...I'll post my answer (if it's done, may have misunderstood the challenge) and see if that's indeed the case...

@LeakyNun Yes, I've remade the formula image to make the operations clearer.

These numbers are called Wilson quotients. A Wilson number is an integer that divides its Wilson quotient evenly. For example, 13 is a Wilson number since 13 | 36846277. Also, W(n) usually excludes the denominator.

And I thought we were talking about Wilson primes.

Need we worry about inaccuracies arising from working with numbers larger than our language can (fully) support?

@Shaggy No, just supporting values that can fit in 32-bit integers is fine.

Could you edit that clarification into the challenge, @miles?

Jelly, 8 7 bytes
1 byte thanks to Dennis.
gRỊTP‘:

Try it online!
You don't really have to compute e since you need to divide anyway.

gRỊT saves a byte.

Dennis getting down to the gRỊTty details of Jelly...

Husk, 11 bytes
S÷ȯ→Π§foε⌋ḣ

Try it online!
Explanation
          ḣ   Range from 1 to input
     §foε⌋    Keep only those whose gcd with the input is 1
    Π         Product
  ȯ→          Plus 1
S÷            Integer division with input

Please add explanation? I think you've got a nifty algo there...

Mathematica, 91 bytes
If[(k=#)==1,2,(Times@@Select[Range@k,CoprimeQ[k,#]&]+If[IntegerQ@PrimitiveRoot@#,1,-1])/#]&

@BillSteihn please do not directly edit others' answers (relevant meta discussion). If you have a golfing suggestion, please leave a comment instead!

@JungHwanMin Yes, I noticed that edit! thanks for helping new users with the rules

Pyth, 11 bytes
/h*Ff>2iTQS

Try it here!

How?

/h*Ff>2iTQS - Full program.

S - Generate the inclusive range [1, input]

f - Filter-keep those:

iTQ - whose GCD with the input.

>2 - Is less than two (can be replaced by either of the following: q1, !t)

*F - Apply multiplication repeatedly. In other words, the product of the list.

h - Increment the product by 1.

/ - Floor division with the input.

TL;DR: Get all the coprimes to the input in the range [1, input], get their product, increment it and divide it by the input.

Pari/GP, 36 bytes
n->(prod(i=1,n,i^(gcd(i,n)==1))+1)\n

Try it online!

Python 2, 62 bytes
n=input();k=r=1
exec'r*=k/n*k%n!=1or k/n;k+=1;'*n*n
print-~r/n

Try it online!

J, 33 bytes
3 :'<.%&y>:*/(#~1&=@(+.&y))1+i.y'

This one is more of a request to see an improvement than anything else.  I tried a tacit solution first, but it was longer than this.
explanation
This is fairly straightforward translation of Mr. Xcoder's solution into J.
Try it online!

R, 82 bytes
function(n)(prod((1:n)[g(n,1:n)<2])+1)%/%n
g=function(a,b)ifelse(o<-a%%b,g(b,o),b)

Uses integer division rather than figuring out e like many answers here, although I did work out that e=2*any((1:n)^2%%n==1%%n)-1 including the edge case of n=1 which I thought was pretty neat.
Uses rturnbull's vectorized GCD function.
Try it online!

05AB1E, 8 bytes
Lʒ¿}P>I÷

Try it online!

JavaScript (ES6), 72 70 68 bytes

f=(n,p=1,i=n,a=n,b=i)=>i?f(n,b|a-1?p:p*i,i-=!b,b||n,b?a%b:i):-~p/n|0
<input type=number min=1 oninput=o.textContent=f(+this.value)>

Integer division strikes again. Edit: Saved 2 bytes thanks to @Shaggy. Saved a further 2 bytes by making it much more recursive, so it may fail for smaller values than it used to.

70 bytes (although I haven't had a chance to run a full set of tests on it yet): f=(n,i=n,p=1,g=(a,b)=>b?g(b,a%b):a)=>--i?f(n,i,g(n,i)-1?p:p*i):-~p/n|0

I went back to the recursive solution I was working on before I decided to try mapping an array instead and got it down to 70 bytes too. It's a bit of a mess but you might be able to salvage something from it to help get your solution down below 70: (n,x=n)=>(g=s=>--x?g(s*(h=(y,z)=>z?h(z,y%z):--y?1:x)(n,x)):++s)(1)/n|0

@Shaggy Well, I was inspired to have another look at it, but I'm not sure that's what you were expecting...

Haskell, 42 bytes
f n=div(product[x|x<-[1..n],gcd x n<2]+1)n

Try it online!
Uses the integer division trick as all the other answers.
Uses 1-based indices.
Explanation
f n=                                       -- function
    div                                  n -- integer division of next arg by n
       (product                            -- multiply all entries in the following list
               [x|                         -- return all x with ...
                  x<-[1..n],               -- ... 1 <= x <= n and ...
                            gcd x n<2]     -- ... gcd(x,n)==1
                                      +1)  -- fix e=1

Axiom, 121 bytes
f(n)==(e:=p:=1;for i in 1..n repeat(if gcd(i,n)=1 then p:=p*i;e=1 and i>1 and i<n-1 and(i*i)rem n=1=>(e:=-1));(p+e)quo n)

add some type, ungolf that and result
w(n:PI):PI==
   e:INT:=p:=1
   for i in 1..n repeat
       if gcd(i,n)=1 then p:=p*i
       e=1 and i>1 and i<n-1 and (i*i)rem n=1=>(e:=-1)
   (p+e)quo n

(5) -> [[i,f(i)] for i in 1..25]
   (5)
   [[1,2], [2,1], [3,1], [4,1], [5,5], [6,1], [7,103], [8,13], [9,249],
    [10,19], [11,329891], [12,32], [13,36846277], [14,1379], [15,59793],
    [16,126689], [17,1230752346353], [18,4727], [19,336967037143579],
    [20,436486], [21,2252263619], [22,56815333], [23,48869596859895986087],
    [24,1549256], [25,1654529071288638505]]
                                                  Type: List List Integer

(8) -> f 101
   (8)
  9240219350885559671455370183788782226803561214295210046395342959922534652795_
   041149400144948134308741213237417903685520618929228803649900990099009900990_
   09901
                                                    Type: PositiveInteger

JavaScript (ES6), 83 81 80 78 76 68 bytes
My first pass at this was a few bytes longer than Neil's solution, which is why I originally ditched it in favour of the array reduction solution below. I've since golfed it down to tie with Neil.
n=>(g=s=>--x?g(s*(h=(y,z)=>z?h(z,y%z):--y?1:x)(n,x)):++s)(1,x=n)/n|0

Try it

o.innerText=(f=
n=>(g=s=>--x?g(s*(h=(y,z)=>z?h(z,y%z):--y?1:x)(n,x)):++s)(1,x=n)/n|0
)(i.value=8);oninput=_=>o.innerText=f(+i.value)
<input id=i type=number>

Non-recursive, 76 bytes
I wanted to give a non-recursive solution a try to see how it would turn out - not as bad as I expected.
n=>-~[...Array(x=n)].reduce(s=>s*(g=(y,z)=>z?g(z,y%z):y<2?x:1)(--x,n),1)/n|0

Try it

o.innerText=(f=
n=>-~[...Array(x=n)].reduce(s=>s*(g=(y,z)=>z?g(z,y%z):y<2?x:1)(--x,n),1)/n|0
)(i.value=8);oninput=_=>o.innerText=f(+i.value)
<input id=i type=number>

Japt, 11 bytes
õ fjU ×Ä zU

Try it

Explanation
Implicit input of integer U.
õ

Generate an array of integers from 1 to U.
fjU

Filter (f) co-primes of U.
×

Reduce by multiplication.
Ä

Add 1.
zU

Divide by U, floor the result and implicitly output.

for n=25 it return 1654529071288638400 and it would be wrong because it would be             1654529071288638505

@RosLuP: As confirmed by the challenge author, we don't need to handle numbers of more than 32-bits.


text:
Shout the input
Given a string that consists entirely of printable ASCII, convert all lowercase letters to their uppercase equivalent. Non-lowercase characters are left untouched.
I am not going to outright ban builtin solutions, but if you are going to post a solution that uses the builtin, please also post one that doesn't in your answer.
This is a code-golf so shortest code wins, standard rules apply.
Test cases
input => output

Hello, World! => HELLO, WORLD!
TEST => TEST
1gN0r3 50M3 cH4r4C73r5 => 1GN0R3 50M3 CH4R4C73R5

GOOD LUCK GOLFERS!

I closed this question as a dupe since it's essentially converting a string to a specific case, the only addition being that built-ins are added, which doesn't make this much different in my opinion. If you don't agree with the closure, you can vote to reopen this question.

SQL WOULD LOVE THIS CHALLENGE.

@EriktheOutgolfer Just got an answer which works for that question but not this one: (JavaScript) a=>a.replace(/[A-Z]/g,a=>parseInt(a,36).toString(36))

@tsh That actually lowercases.

Japt, 05AB1E & 2sable (and probably others), 1 byte
u

Try it: Japt  |  05AB1E  |  2sable
Thanks to Mr. Xcoder for pointing out the polyglots.

Japt Without Built-in, 16 bytes
c_¨#a©Z§#z?Z-H:Z

Try it

Polyglot with 05AB1E

Also polyglot with 2sable. Sorry for finding them 1 by 1 :P

Python 3, 9 bytes
str.upper

Try it online! or Verify all test cases.

Python 3, 50 bytes
Saved many bytes thanks to @FelipeNardiBatista.
lambda k:''.join(chr(ord(c)-32*(c>'_'))for c in k)

Try it online!

50 bytes

Pyth, 3 bytes
rQ1

Equivalent to str.upper in python.

Perl 5, 6 bytes
5 bytes code + 1 for -p.
$_=uc

Try it online!

JavaScript (ES6), 18 bytes
s=>s.toUpperCase()

Without builtins.

Thanks, @ThePirateBay; I was about to port my 16 byte Japt solution, which would have been exactly what you posted, when the challenge got dupe-hammered, so I just moved on.

Mathematica, 11 bytes
ToUpperCase

Jelly, 2 bytes
Œu

Try it online!