text:
Print the Stack Exchange favicon
Challenge
Print or return the Stack Exchange favicon, as provided below:
 ___________________
/                   \
---------------------
|                   |
---------------------
|                   |
---------------------
\__________    _____/
           |  /
           | /
           |/

This is code-golf, so the shortest answer in each language wins.

Is the top left corner intended to be slightly misaligned?

@ETHproductions It was intended, but I'm changing it now. It looks kind of awkward either way.

The actual output is 219 bytes, for reference.

Trailing lines and/or trailing spaces on lines are allowed, right?

@dzaima Yeah that's fine

Alternate title: "Print Community's avatar" :P

Related

Operation Flashpoint scripting language, 263 195 bytes
f={r="                   ";t="---------------------\n";s=" ___________________\n/"+r+"\\n"+t+"|"+r+"|\n"+t+"|"+r+"|\n"+t+"\__________    _____/\n           |  /\n           | /\n           |/";s}

Not the right tool for the job.
Call with:
hint call f;

Output:
The formatting fails, because the font is not monospaced.

Just what makes you look at a challenge and think "oh, I should answer that in Operation Flashpoint" puzzles me...

@totallyhuman I guess its scripting lang is just fun to write in. It has quite a few quirks and limitations, so you sometimes need to use some strange workarounds, which makes it interesting (yet not very practical).

Hardcoding the answer would probably give you a better score.

@NieDzejkob Now it's shorter than just hardcoding the output, but more boring than the previous version.

@totallyhuman And with this challenge in particular, I wanted to test how the language would fare with a Kolmogorov-complexity challenge (for which it's far less than ideal for).

Charcoal, 38 37 33 30 bytes
←×_χ↓Ｆ/||⟦ι¹¹⟧\×_⁹‖Ｂ_×ψ⁴↙↙³↑↑³

Try it online! Link is to verbose version of code. Edit: Managed to save a byte with the help of a reflection, although @CarlosAlejo shows that it can in fact be done in 37 bytes without reflecting. Saved a further 4 bytes by drawing the left ¾ and reflecting the final ¼. Edit: Previous 33-byte answer depended on ReflectButterflyOverlap() not overprinting the overlap area with the reflection, so in case this behaviour changed, I sought a solution that didn't rely on that, and the result turned out to be shorter anyway, thanks to my creative use of printing an array. Explanation:
←×_χ                            Print 10 `_`s leftwards (top row)
    ↓                           Move down to the next row
     Ｆ/||                       For each character in the string `/||`
          ι                     Current character
           ¹¹                   Integer 11, prints as `-----------`
         ⟦   ⟧                  Put both into an array
                                Implicitly print on separate lines
              \                 Implicitly print `\`
               ×_⁹              Implicitly print 9 `_`s
                  ‖Ｂ            Reflect right, overlapping the axis
                    _           Implicitly print `_`
                     ×ψ⁴        Implicitly delete 4 characters
                        ↙↙³     Move down left and print three `/`s
                           ↑↑³  Move up and print three '|'s

Very well played. I love that there's four Charcoal answers to this question! ‖ＢＯ wasn't in the language the last time I used it--I'll have to keep that in mind for the future.

I had to see for myself what you meant with "reflecting the final ¼". Well played indeed!

///, 98 bytes
/'/  //&/
"""
|!! |//%/\\\/
!'|//#/_____//"/-------//!/'''' / ###____
\/!! \\&&
"""
\\##''#%'% %\/

Try it online! Or, see it interactively!

Is there a utility that allows me to see the different "step"s of a /// program? (Partial execution after each replace.) That could help me to understand them better.

@CAD97 I've been fiddling around with the online interpreter, and it usually would  come with debug options, but the way the online interpreter orders arguments, it doesn't function that way. You could grab a copy of the interpreter yourself and do something like perl slashes.pl -d1 code.txt. I'm presently working on an online execution environment for ///, but that might take some time.

@CAD97 Said online thing is up, take a look!

JavaScript (ES6), 113 112 bytes
(Saved a byte thanks to @Craig Ayre.)

let f=

_=>` _19
/ 19\\
-21
| 19|
-21
| 19|
-21
\\_10 4_5/
 11| 2/
 11| /
 11|/`.replace(/.(\d+)/g,([a],b)=>a.repeat(b))

 console.log(f());

Looks like you have a stray space before the replacement function. I had just come up with a similar update for my JS solution at 113 bytes. Don't know whether I should post it or let you have it.

Ah, wait, only seeing now that you posted your solution before I posted mine. I'll delete mine when I get to a computer and you can save a byte with replace(/.(\d+)/g,(a,b)=>a[0].repeat(b)).

Thanks, Shaggy.  I had written a program to automate this type of answer, and it was silly to have it output an unneeded space.  Your suggested replace statement is certainly an improvement, which I've now incorporated in my program.

Can you save a byte array matching a: ([a],b)=>a.repeat(b))?

Yes, thanks!  I was unfamiliar with that syntax.

Python 2, 115 bytes, more creative idea
t,u,v,w,x,y,z='\n -/\\_|';k=w+t+11*u+z;i=t+21*v+t
print u+19*y+t+w+19*u+x+(i+z+19*u+z)*2+i+x+10*y+4*u+5*y+k+u,k,k+w

Try it online!
Python 2, 102 bytes,  boring idea
print'eNrjUojHBFz6CpgghksXG+CqwaK2hgpqYxDuASkDM/S5kDUqKKDxUbn6XADUmClx'.decode('base64').decode('zip')

Try it online!

I am down voting this since I have seen this method used way too many times. It is just boring to see over and over again.

@R.Kap Unless there's a shorter way, that's a rather arbitrary reason to downvote.

@R.Kap I think you are talking about this kind of code:
import zlib
print zlib.decompress('eNrj.....mClx'.decode('base64'))

@mdahmoune Great, you found a more concise way to implement the same boring idea.

@Dennis Maybe, but I still stand by my opinion and have every right to express it. I have seen this method used countless times on these kinds of challenges and it requires little to no creativity on the OP's part, which are big aspects, at least in my opinion, of Kolomogorov complexity challenges, and hence my reason for the down-vote.

@R.Kap If general purpose compression algorithms can beat manual ones that easily, that's a problem of the challenge, not the answer. I didn't even manage to beat Bubblegum with Jelly, and decompression had very little overhead in Jelly.

@Dennis I am not even talking about code length here. I am talking about effort and creativity, which this answer, in my opinion, fails to showcase in a language where one can do so much more, which is the reason I down-voted. Now, if you disagree with my reasoning that is fine. In that case, let us just agree to disagree and end this conversation right here before it gets too long. :)

@R.Kap what do you think about the 115 bytes one?

@mdahmoune It is better. I will remove my down-vote. :)

@Dennis I agree with you, we have to keep also the boring idea to push the limit of creativity...

SOGL V0.12, 32 31 bytes
^$∙r↑Ψ«2τγæΕž‘╬Æ╬⁷"ƧΡ⅟?0Ξ³‘6«8ž

Try it Here!
Explanation:
...‘               push a quarter of the icon
    ╬Æ             palindromize vertically
      ╬⁷           palindromize horizontally (these two should be ╬3 together, but spacing doesn't work correctly (though now it does since I fixed it))
        "...‘      push the extention
             6«8ž  at coordinates [12; 8] in the quad-palindromized image put that in

The quarter:
 __________
/
-----------
|
-----------

and the other part:

|  /
| /
|/

"togethe"? "trough"? Also, it took a little while to figure out that . in the explanation meant string. Maybe use ^...' and "...'?

@CalculatorFeline I usually did ... for compressed strings (aka nonsense) but lately I started doing one or two. And feel free to fix my mistakes and grammar :p

Python 2, 124 bytes
a,b,d,e,f,g,h=' _-|/\\\n';r=d*21+h+e+a*19+e+h;n=f+h+a*11+e;print a+b*19+h+f+a*19+g+h+r*2+r[:22]+g+b*10+a*4+b*5+n+a*2+n+a+n+f

Try It Online!

You don't ever use c, so you can eliminate it for 3 bytes. Try it online!

@musicman523 I don't even know why I put that there. Thanks for the catch! :)

C (gcc), 187 bytes
Saved 2 bytes thanks to Cody Gray, and 3 bytes thanks to Keyu Gan!
#define a"         "
#define s a" "a
#define l"\n---------------------\n"
f(){puts(" ___________________\n/"s"\\"l"|"s"|"l"|"s"|"l"\\__________    _____/\n"a"  |  /\n"a"  | /\n"a"  |/");}

Try it online!

puts would be trivially shorter, if a trailing new-line is acceptable.

you may use f() instead of main(). A function is also acceptable.

C, 167 bytes
i;char*d=" q    /()\\   A   |()|    A   |()|    A   \\h#c/  #&|!/   #&| /   #&|/",c,b;main(j){while(c=d[i++],b=c%5==2||c>123?c:c>95?95:c>45?45:c>=32?32:++c,i<47)for(j=c;j-->=b;)putchar(b);}

Try it online!
Note: a lot of apparent spaces above are actually the tab character.
Readable version:
i;
char *d = " q   /()\\   A   |()|    A   |()|    A   \\h#c/  #&|!/   #&| /   #&|/", c, b;
main(j) {
    while(
        c = d[i++],
        b = c % 5==2 || c > 123 ? c:
            c > 95 ? 95:
            c > 45 ? 45:
            c >= 32 ? 32:
            ++c,
        i < 47
    )
        for(j = c; j-- >= b;)
            putchar(b);
}

Explanation:
The data array, d, encodes the answer in literal single characters and coded repeated characters. Each character, c, in the data array is mapped to a base character, b, and a number of repetitions. It is then printed that many times.
Characters that are used only singly (slashes and the pipe) have ASCII codes 47, 92, and 124. Two of these are divisible by 5 with a remainder of 2 (c%5=2||c>123). I couldn't find a shorter condition to test for all three.
Characters that are repeated (underscore, dash, and space), with ASCII codes 95, 45, and 32 respectively, are coded with a higher ASCII code--increased by one per repetition. So, for example, a single space is just a space, but two spaces can be coded by the next ASCII character, the exclamation point. Where a coded character would be unsuitable because it meets the above modulo condition, it can be split, as with #& to represent eleven spaces. The same technique is used to avoid overlap between the space and dash character ranges.
Finally, the ten newlines are encoded as tabs to save bytes that would have been spent escaping the newlines with a backslash, then incremented for printing (++c).

Well done! I knew there were better C answers out there.

Thanks! It was a fun challenge. I spent something like four hours on it, so I'm glad it worked out in the end.

156 bytes

Rust, 181 bytes
||" ___________________
/2\\
1
1
3
\\__________    _____/
4|  /
4| /
4|/".replace("1","3
|2|").replace("2",&" ".repeat(19)).replace("3",&"-".repeat(21)).replace("4",&" ".repeat(11))

Try it online!
Rust, 184 bytes
This version may be more golfable as adding further replace cost fewer bytes each. The first replace isn't part of the loop because it pulls double duty changing s into a String instead of a &'static str.
||{let mut s=" 5__5__5
/2\\
1
1
3
\\55    5/
4|  /
4| /
4|/".replace("1","3
|2|");for p in vec![("2"," ",19),("3","-",21),("4"," ",11),("5","_",5)]{s=s.replace(p.0,&p.1.repeat(p.2))}s}

Try it online!

Charcoal, 49 37 bytes
↓⁵\…_χ↓↓³↗↗³…_⁵↑/↑⁵↖\←…_¹⁹↓ /Ｆ³«Ｐ²¹¶¶

Try it online!
At last I could golf this a bit. This answer (unlike all other Charcoal answers) does not use reflection, but draws all the contour in one pass, leaving the horizontal bars for the end.
Link to the verbose version.

"Unlike all the other Charcoal answer" Actually my first answer did not use reflection either, but I will admit that I didn't spot the chance to golf a byte off by starting the drawing with the left vertical line. (The only other changes between our solutions are that you use Range where I used Times and you print a \ where I just printed :UpLeft 1 step.)

Although it seems the reflecting is till the way to go...

Also that's twice now that my s key didn't work...

Bubblegum, 40 bytes
Saved 1 byte by removing a trailing newline, thanks @ovs!
00000000: 5388 c704 5cfa 0a98 2086 4b17 1be0 aac1  S...\... .K.....
00000010: a2b6 860a 6a63 10ee 0129 0333 f4b9 9035  ....jc...).3...5
00000020: 2a28 a0f1 51b9 fa00                      *(..Q...

Try it online!

Without a trailing newline, this gets 40 bytes.

Thanks! I think my text editor automatically put one in.

How did you create this? zlib.compress(s.encode(), 9) outputs 46 bytes, and the answer seems to be zlib.

Per Dennis's suggestion, I used zopfli --deflate to generate the raw DEFLATE stream, then used xxd to convert it into the xxd format. I believe zlib leaves a checksum, or is not a raw DEFLATE stream for some other reason.

Charcoal, 38 bytes
←…_χＰ↑⁵Ｐ\Ｆ³«↑Ｐ¹¹↑»↗¹…_χ‖ＢＭ²¦⁷Ｐ↓⁴… ⁴↙↙³

Try it online!
I used Carlos's answer in its original form as a jumping-off point, but saved a good bit by using a reflection, taking advantage of horizontal symmetry. (Vertical symmetry wasn't worth it because the underscores ended up on the wrong row.) You can see the evolution of the canvas at each step here.
Here's the verbose version.

btw you can use -d to show each step (also sorry i've been changing charcoal so much, i'm not sure very many of the new ideas are very useful, especially the goat ascii-art builtin and part of the wolfram language haha)

most useless charcoal program ever

Python 2, 119 117 116 bytes
print''.join(' \n-/|\\_'[ord(x)/8-4]*int('1245abjl'[ord(x)%8],36)for x in' V(8&H(7(@&@(7(@&@(7(HT"S8(%@!8(%@ 8(%@8')

Try it online!
A bit of tortured run-length encoding...
EDIT: Save 3 bytes by replacing the set of lengths:
[1,2,4,5,10,11,19,21][ord(x)%8]
with
int('1245abjl'[ord(x)%8],36)

Wow! I was trying to think of an effective way to do this myself.

Nice code, but it seems that it is 119 bytes?

@mdahmoune: Quite right - forgot to use r'' when checking the length...

C++ 11 - 162 159 154 152 150 bytes
MSVC:
void f(){char*i="b t_b\nb/t b\\b\nv-b\nb|t b|b\nv-b\nb|t b|b\nv-b\nb\\k_e f_b/b\nl b|c b/b\nl b|b b/b\nl b|b/";while(*i)cout<<string(*i++-97,*i),i++;}

GCC: (+4 chars)
int f(){char*i="b t_b\nb/t b\\b\nv-b\nb|t b|b\nv-b\nb|t b|b\nv-b\nb\\k_e f_b/b\nl b|c b/b\nl b|b b/b\nl b|b/";while(*i){cout<<string(*i-97,*(i+1));i+=2;}}

Input string i is coded in char pairs:

Count of chars to repeat (added to 'a' to be a legible character)
Char to print

I think, there's still a lot of room for improvement here.
Edit:

Replaced putchar with cout<<
Remove while, Use string constructor to repeat chars
Removed space before pointer and a spurious semi-colon ;;
Compounding instructions with comma, removing braces.

C++11 does not support auto as a return type, that's a C++14 feature. However, you can fix this and save a byte by making the return type int. It doesn't appear that this code works, though; could you test it on Try it online! and see if you can fix it?

Changed the return type auto -> void. I was testing on Visual Studio 2017 - automatically C++14. Added a version for gcc.

Oh okay, gotcha. I'm running Linux so I don't have VS. Nice job!

Hi Robert - your run length encoding approach is similar to my own; see here. I additionally pack each (length,char) pair into a single char instead of 2. There are 7 possible characters, and 8 distinct lengths; so I use the 56 characters in  ' '..'X' for encoding; which saves 40 bytes with a little extra overhead for decoding.

Pyth, 74 bytes
J*21\-L*db+d*19\_++\/y19\\V2J++\|y19\|;J++++\\*T\_y4*5\_\/V3+++y11\|y-2N\/

Try it online!

Welcome to PPCG!

R16K1S60 Assembly, 152 144 Bytes
Writes output to screen peripheral the R16K1S60 in ASCII. Runs on The Powder Toy save 2012356. (See link in header for info)
The byte size of the program is the compiled result (Cells Used * 2), not the assembly.
You know you've done well when the logo takes more space than your bytecode.
a:
mov ex, ip
mov ax, .string
mov sp, ip
mov dx, 0x1000
send sp, dx
.loop:
mov bx, [ax]
cmp bx, ip
je .end
cmp bx, ip
je .newline

shr bx, cx, 8
and cx, 0x00FF
.inner:
send sp, cx
sub bx, ex
jnz .inner
.reentry:
add ax, ex
jmp .loop
.newline:
add dx, 0x0020
send sp, dx
jmp .reentry
.string:
dw 0x0120
dw 0x135F
dw 0x000C
dw 0x012F
dw 0x1320
dw 0x015C
dw 0x000C
dw 0x152D
dw 0x000C
dw 0x017C
dw 0x1320
dw 0x017C
dw 0x000C
dw 0x152D
dw 0x000C
dw 0x017C
dw 0x1320
dw 0x017C
dw 0x000C
dw 0x152D
dw 0x000C
dw 0x015C
dw 0x0A5F
dw 0x0420
dw 0x055F
dw 0x012F
dw 0x000C
dw 0x0B20
dw 0x017C
dw 0x0220
dw 0x012F
dw 0x000C
dw 0x0B20
dw 0x017C
dw 0x0120
dw 0x012F
dw 0x000C
dw 0x0B20
dw 0x017C
dw 0x012F
dw 0x0009
.end:
hlt

Explanation
The assembly code above implements a simple compression algorithm, with the words 0x000C being a newline and 0x0009 being the command to stop execution.
The other words are encoded simply, like this:
0xTTCC

T: Times to repeat the value
C: The ASCII character to print

The ASM uses every register available to it, including some of the less commonly used ones:

The Instruction Pointer, to get a few known values into quick recall to save some bytes (A constant value in an instuction that's not just a register uses an extra byte to store it)
The Stack Pointer is used as 6th general purpose register, because none of the code uses the stack.

Only AX, BX, CX, and DX are actually used for important data. EX and SP are used to store some constants that get frequently used.
It's somewhat simple, and has nil chance of winning, but it was fun to write!
See revision history for the old answer (It's just as large in terms of ASM)
funfact: if this was measured in words (in the case of the R16K1S60,16 bits) it'd be smaller than the pyth answer, at 72 bytes

Python 2, 159 153 139 bytes
s=" "*19;e="-"*21;a=" "*9;print" %s\n/%s\\\n%s\n|%s|\n%s\n|%s|\n%s\n\%s    %s/\n%s|  /\n%s| /\n%s|/"%("_"*19,s,e,s,e,s,e,"_"*8,"_"*7,a,a,a)

Try it online!
EDIT: Saved 6 bytes by using % formatting instead of .format().
EDIT: Saved another 14 bytes by fixing the output, thanks to musicman523.

This isn't printing the exact text (extra lines are present). Fixing this will probably save some bytes as well.

Here is a fixed version, coming in at a hot 139 bytes

Jelly, 50 48 45 bytes
21“©&Ẇƥ⁸þ/Ẉoụ’ḃ1pF“CṣʠėHẹỊtṡḤḶ’ṃ“ _/\-|”¤xs¹Y

Try it online!

V, 49 bytes
i ±¹_
/±¹ \2ÙÒ-jÓÓ/|
3äkGR\±_´ µ_/
±± |  /2ñÙlx

Try it online!

Japt, 79 72 71 bytes
" _p
/ p\\
{"-r
| p|
"²}-r
\\_g a_b/
 h|  /
 h| /
 h|/"r".%l"_g p6nZÅnH

Test it

7 bytes saved thanks to ETHproductions' excellent suggestion of using base 32 integers for the repetition values.

Very nice compression method. If you use nH you can save a few more bytes: http://ethproductions.github.io/japt/?v=1.4.5&code=IiBfcAovIHBcXAp7Ii1yCnwgcHwKIrJ9LXIKXFxfZyBhX2IvCiBofCAgLwogaHwgLwogaHwvIiByIi4lbCJfZyBwNm5axW5I&input=

Mathematica, 163 bytes
Row@Map[Column,Characters/@{" /-|-|-\\   ",r="_ - - -_   ",r,r,r,r,r,r,r,r,r,"_ - - - |||","_ - - -   /","_ - - -  / ","_ - - - /  ",r,r,r,r,r," \\-|-|-/   "},{1}]

PHP, 86 bytes
<?=gzinflate(base64_decode("U4jHBFz6CpgghksXG+CqwaK2hgpqYxDuASkDM/S5kDUqKKDxUbn6AA"));

Try it online!
PHP, 118 bytes
<?=strtr(' 333____
/00   \
11-
|02
11-
|02
11-
\33    3/
2  /
2 /
2/',['        ','----------',"           |",_____]);

Try it online!

Python 2, 171 bytes
p,u,q,v,r,s,F=' ','_','/','|','-'*21,'\\',lambda f,m:f+m*19+f;B=lambda n:p*11+v+p*n+q
print'\n'.join([F(p,u),q+p*19+s,r,F(v,p),r,F(v,p),r,s+u*10+p*4+u*5+q,B(2),B(1),B(0)])

Each line is exactly 85 bytes! Hoorah!

Zsh, 244 bytes
This is specifically written for Zsh, not Bash, as it allows a bit more in terms of weird syntax.
alias p=printf
function r { p "$1%.s" {0..$2}}
function l { p $1;r $2 19;p $3;p "\n"}
l " " _ " "
l / " " \\
l - - -
l \| " " \|
l - - -
l \| " " \|
l - - -
p \\
r _ 10
r " " 4
r _ 5
p "/\n"
r " " 11
p "|  /\n"
r " " 11
p "| /\n"
r " " 11
p \|/

Note: when I tried to run it on tio.run the output is different than on my terminal. The fix to this is replacing
function r { p "$1%.s" {0..$2}}

with
function r { p "$1%.0s" {0..$2}}

which would make it 245 bytes (link).
Edit
Seems like I was too eager to hit that post button and I missed some spaces, making my solution a bit less efficient. My new output seems off though, but I think I counted correctly (but it wouldn't change the length anyway).

Welcome to PPCG! Notice that the lower line of underscores has a gap of four spaces in it, which is missing from the output of your code.

@Steadybox Ohh silly me. I've updated the answer, thanks for pointing it out!

No problem! Unfortunately, I think it's still a bit off, but this should fix it (and it saves you a byte too!).

I think you can save a few bytes by using 'funcname(){}' instead of 'function funcname{}'

Retina, 74 bytes

 _18¶/ 18\-| 18|-| 18|-\_9 3_4%  % %/
-
¶-20¶
%
/¶ 10|
\d+
$*
+`(.)1
$1$1

Try it online!

,,,, 115 101 98 bytes
I am absolutely ashamed that this is the best I can produce. >.>
"|/
"' 11×:"| /
"⇆:"|  /
"⇆'
'/'_5×' 4×'_10×92c'
'|' 19×'|'
'-21×+++++3×110⇆⊣"\
"' 19×'/'
'_19×' #

JavaScript (ES6), 151 bytes
_=>` 2_________
/0\\
1
|0|
1
|0|
1
\\2    _____/
3|  /
3| /
3|/`.replace(/\d/g,a=>a.repeat.call(...[[" ",19],["-",21],["_",10],[" ",11]][a]))

Test Snippet

f=
_=>` 2_________
/0\\
1
|0|
1
|0|
1
\\2    _____/
3|  /
3| /
3|/`.replace(/\d/g,a=>a.repeat.call(...[[" ",19],["-",21],["_",10],[" ",11]][a]))

O.innerHTML=f()
<pre id=O>

Retina, 89 bytes

1"""____¶/19\¶##-¶|19|¶##-¶|19|¶##-¶\""4"/¶11|2/¶11|1/¶11|/
#
!!
"
_____
!
-----
\d+
$*

Try it online!

Charcoal, 48 bytes
↙¹→Ｐ¹¹↓↓¹Ｐ¹¹‖Ｂ↓¦↘→×¹⁰_Ｍ⁷↑←←×¹⁰_‖ＢＪ¹¹¦⁶→×⁴ ↙↙³↑↑³

Try it online!
Somewhat different internals than Carlos's, although not visible at first.

tcl, 150
proc R {s n\ 19} {string repe $s $n}
puts " [R _]
/[R \ ]\\
-[R -]-
[set T |[R \ ]|\n-[R -]- ]
$T
\\[R _ 11]    ____/
[set S [R \  12]|]  /
$S /
$S/"

demo

Another version with same number of bytes:
proc R {s n\ 19} {string repe $s $n}
puts " [R _]
/[R \ ]\\
[set T -[R -]-\ \n|[R \ ]|]
$T
-[R -]-
\\[R _ 11]    ____/
[set S [R \  12]|]  /
$S /
$S/"

demo

Python 3.6, 132 128 125 124 bytes
x,y="_ "
b=y*19
c='-'*21
e=y*11
f=f"{c}\n|{b}|\n"
print(fr''' {x*19}
/{b}\
{f*2+c}
\{x*10+y*4+x*5}/
{e}|  /
{e}| /
{e}|/''')

Try it online!

Windows batch, 263 bytes
@echo off
echo  ___________________
echo /                   \
for /l %%G in (1,1,2)do (
echo ---------------------
echo ^|                   ^|
)
echo ---------------------
echo \__________    _____/
echo            ^|  /
echo            ^| /
echo            ^|/

Braingolf, 129 120 bytes
9+.# [#_]#
#/[# ]#\#
&@#
.+>[#-]#
!&@V9+#|[# ]#|#
!&@R!&@v&@R&@934#
..#\[#_][# ][#_]#/#
[# ]"|  /
"[# ]"| /
"[# ]"|/"&@

Try it online!
As always, braingolf is not good at ASCII art

Golfscript, 102 bytes
Try it online!
This is less than half the size of the actual output.
' ''_'9*.'_
/'' '19*'\
''-'21*n+.'|'.5$\n+++.@.@\'\\'9$'_'' '4*'_'5*'/
'2$.'   |'++.'  /
'@.' /
'@'/'

C (gcc), 138 137 bytes
That string still taunts me with its look of compressibility.
f(i){for(char*s=" S_:/S \\:U-:|S |:U-:|S |:U-:\\J_D E_/:K |  /:K | /:K |/";*s;s++)for(i=*s>64&*s<91?*s++-64:1;i--;)putchar(*s^58?*s:10);}

Try it online!

PowerShell, 116 115 bytes
' _19
/ 19\
-21
| 19|
-21
| 19|
-21
\_10 4_5/
 11|  /
 11| /
 11|/'-replace'(.)(\d+)',{$x,$c,$n=$_|% gr*;"$c"*"$n"}

Try it online!


text:
Is this string valid FEN?
The challenge
Write a program or function which takes a string input as a function parameter or from stdin and determines if it is a valid FEN string.
Input
You can assume the input will only ever include the following characters (case sensitive)
pkqrbnPKQRBN12345678/
The length of the input will always be a minimum of 1 character and a maximum of 100 characters
Output
Output should be a truthy/falsey value. These can be any values you wish as long as they are consistent (all truthy results have the same output, all falsey results have the same output). You should have exactly two distinct possible outputs.
What counts as valid
Lowercase letters represent black pieces, uppercase letters represent white pieces.
You should ensure it is possible in a game of chess for the pieces in the current position to exist.
Each player will always have exactly 1 king (k/K)
Each player may have no more than 8 pawns (p/P)
Each player will usually have no more than 1* queen (q/Q)
Each player will usually have no more than 2* rooks (r/R)
Each player will usually have no more than 2* knights (n/N)
Each player will usually have no more than 2* bishops (b/B)
* It is legal for a player to 'promote' a pawn to any of these four pieces.
The total of pawns, queens, rooks, knights and bishops for each player will never be more than 15
The total number of pieces plus empty squares (denoted by numbers) should always add up to exactly 8 for each rank. And there should always be exactly 8 ranks, separated by a forward slash.
Things you can ignore
You do not need to concern yourself with whether or not it is possible to play into the position denoted, or if the position is legal, only that the pieces can exist in the quantities given.
You can ignore further complexities of FEN strings such as player turn, castling rights and en passant.
This is code golf. Shortest program in bytes wins. Usual loopholes and rules apply.
Test Cases
Input rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR
Output True
Input 2br2k1/1p2n1q1/p2p2p1/P1bP1pNp/1BP2PnP/1Q1B2P1/8/3NR2K
Output True
Input r2r2k1/p3q2p/ppR3pr/rP4bp/3p4/5B1P/P4PP1/3Q1RK1
Output False
(black has 7 pawns and 4 rooks - impossible)
Input 6k1/pp3ppp/4p3/2P3b1/bPP3P1/3K4/P3Q1q1
Output False
(only 7 ranks)
Input 3r1rk1/1pp1bpp1/6p1/pP1npqPn/8/4N2P/P2PP3/1B2BP2/R2QK2R
Output False
(9 ranks)
Input 5n1k/1p3r1qp/p3p3/2p1N2Q/2P1R3/2P5/P2r1PP1/4R1K1
Output False
(2nd rank has 9 squares/pieces)
Input rnbqkbnr/pppppppp/8/35/8/8/PPPPPPPP/RNBQKBNR
Output True
Thanks to Feersum and Arnauld for clarifying this case (3+5=8)
What is FEN?
FEN is a standard notation for recording the position of the pieces on a chess board.

Image credit http://www.chessgames.com

“Each player will usually have no more than 1* queen”—please clarify what counts as valid, since I assume it doesn’t matter what counts as “usual”. Is it valid for white to have nine queens? Ten queens? Eight pawns and two queens? Zero kings? An unpromoted pawn on the first or last rank?

@AndersKaseorg * It is legal for a player to 'promote' a pawn to any of these four pieces. The player may have up to 9 queens so long as the number of pawns is reduced to compensate. You do not need to worry about the position of the pieces being legal or illegal, only the number of pieces.

pkqrbnPKQRBN/ should be pkqrbnPKQRBN12345678/, no?

@AugmentedFourth a valid point, I will edit that in

What about zero kings (which cannot happen in any real game of chess)? Or a state in which a promotion has occurred without any captures on either side (also not possible in any real game)? There are probably some less obvious conditions imposed by real games, so if you don’t intend to make us figure all that out, we need an unambiguous explanation of what you consider valid.

My apologies if it was not clear. It is my intention that the focus be on the quantities rather than the position. I have stated that you do not need to worry about whether or not the position is legal or possible to reach in normal play. I will attempt to rewrite the validity section to reduce any ambiguity.

In your third test-case, black has 6 pawns, not 7, making it a 'True' (?)

A good false test case to add: rnbqkbnr/pppppppp/8/35/8/8/PPPPPPPP/RNBQKBNR

@feersum This FEN is badly formed indeed but I don't think it's breaking any of the rules described in the challenge. (And many chess engines will probably accept it as input.)

@pizzapants184 I will recheck all my test cases

@feersum that would be invalid due to The total number of pieces plus empty squares (denoted by numbers) should always add up to exactly 8 for each rank.

@DarrenH The FEN position proposed by feersum is valid according to your current rules. 35 is just an unusual way to describe 8 empty squares.

@Arnauld In that case I have misunderstood that aspect of FEN and consider myself corrected. I will include that as a positive test case

I'm not saying that it's a valid FEN position. I'm just saying that it does not break any of the rules described in the challenge.

Let us continue this discussion in chat.

Can it be okay to take input through command line arguments?

@ComradeSparklePony Yes that's fine

I'd say add a test case for invalid FEN due to black pawns on first rank or white pawns on last rank

@PatrickRoberts pawns on first or last rank are valid for the purpose of this challenge. You do not need to account for the legality of a position, only the quantity of pieces. Accounting for the legality of a position (such as both players being in check) adds a lot of complexity so I figured a blanket of 'position doesn't matter' is clearer than a debate on where to draw the line of what needs accounted for and what doesn't.

I was suggesting that 35 is an invalid way to represent 8. The rules are not too specific on this point but don't suggest to me that it should be valid.

Retina, 105 bytes
[1-8]
$*
^
/
iG`^(/[1KQRBNP]{8}){8}$
G`K
G`k
A`K.*K|k.*k
{2`N

2`B

2`R

1`Q

K

T`L`P
8`P

A`P
}T`l`L
^.

Try it online! Link includes test cases. Explanation:
[1-8]
$*

Expand digits to empty squares, which we denote using 1s.
^
/
iG`^(/[1KQRBNP]{8}){8}$

Delete the input if it does not match 8 sets of 8 valid squares joined with /s. (An extra / is prefixed to simplify the check.)
G`K
G`k
A`K.*K|k.*k

Delete the input if it has no white or no black king, or if it has two of either.
{2`N

2`B

2`R

1`Q

K

Delete white's starting pieces, if they are still there.
T`L`P

Demote any remaining white pieces to pawns.
8`P

Delete the valid white pawns.
A`P

Delete the input if there are any white pawns left over.
}T`l`L

Check again but with the black pieces.
^.

Output a truthy value unless the line was deleted.

JavaScript (ES6), 168 174 ... 155
This answer has been edited an embarrassing number of times. Hopefully, the current version is both reliable and decently golfed.

Returns a boolean.
s=>[...s].map(c=>++n%9?+c?n+=--c:a[i='pP/KkQqRrBbNn'.search(c),i&=i>4&a[i]>(i>6)||i]=-~a[i]:x+=c=='/',a=[x=n=0])&&!([p,P,s,k,K]=a,n-71|x-7|s|k*K-1|p>8|P>8)

Formatted and commented
s => [...s].map(c =>                  // for each character 'c' in the FEN string 's':
  ++n % 9 ?                           //   if we haven't reached the end of a rank:
    +c ?                              //     if the character is a digit:
      n += --c                        //       advance the board pointer by c - 1 squares
    :                                 //     else:
      a[                              //       update the piece counter array:
        i =                           //         i = piece identifier (0 to 12)
          'pP/KkQqRrBbNn'.search(c),  //             with special case: '/' --> 2
        i &=                          //         we count it as a promoted pawn instead if:
          i > 4 &                     //           it's a Q, R, B or N and we already have
          a[i] > (i > 6) ||           //           2 of them for R, B, N or just 1 for Q
          i                           //           else, we keep the identifier unchanged
      ] = -~a[i]                      //         '-~' allows to increment 'undefined'
  :                                   //   else:
    x += c == '/',                    //     check that the expected '/' is there
  a = [                               //   initialize the piece counter array 'a'
    x =                               //   initialize the '/' counter 'x',
    n = 0 ]                           //   initialize the board pointer 'n'
) &&                                  // end of map()
!(                                    // now it's time to perform all sanity checks:
  [p, P, s, K, k] = a,                //   copy the 5 first entries of 'a' to new variables
  n - 71 |                            //   have we reached exactly the end of the board?
  x - 7 |                             //   have we identified exactly 7 ends of rank?
  s |                                 //   have we encountered any unexpected '/' character?
  k * K - 1 |                         //   do we have exactly one king on each side?
  p > 8 |                             //   no more than 8 black pawns, including promotions?
  P > 8)                              //   no more than 8 white pawns, including promotions?

Test cases

let f =

s=>[...s].map(c=>++n%9?+c?n+=--c:a[i='pP/KkQqRrBbNn'.search(c),i&=i>4&a[i]>(i>6)||i]=-~a[i]:x+=c=='/',a=[x=n=0])&&!([p,P,s,k,K]=a,n-71|x-7|s|k*K-1|p>8|P>8)

console.log(f("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR")) // True
console.log(f("2br2k1/1p2n1q1/p2p2p1/P1bP1pNp/1BP2PnP/1Q1B2P1/8/3NR2K")) // True
console.log(f("r2r2k1/p3q2p/ppR3pr/rP4bp/3p4/5B1P/P4PP1/3Q1RK1")) // False (black has 7 pawns and 4 rooks - impossible)
console.log(f("6k1/pp3ppp/4p3/2P3b1/bPP3P1/3K4/P3Q1q1")) // False (only 7 ranks)
console.log(f("3r1rk1/1pp1bpp1/6p1/pP1npqPn/8/4N2P/P2PP3/1B2BP2/R2QK2R")) // False (9 ranks)
console.log(f("5n1k/1p3r1qp/p3p3/2p1N2Q/2P1R3/2P5/P2r1PP1/4R1K1")) // False (2nd rank has 9 squares/pieces)
console.log(f("rnbqkbnr/pppppppp/8/35/8/8/PPPPPPPP/RNBQKBNR")) // True
console.log(f("rnbqkbnr/pppppppp/8/9/7/8/PPPPPPPP/RNBQKBNR")) // False (additional test case suggested by Rick Hitchcock)
console.log(f("rnbqkbnr/pppp/ppp/8/8/8/8/PPPPPPPP/RNBQKBNR")) // False (additional test case)

Is it shorter to allow promotion from pawn, king and /?

Python 3, 284 259 236 225 247 234 bytes
import re
s=input()
t,c=s.split("/"),s.count;P=p=9;o=0
for x in"pqrnb":p-=max(0,c(x)-o);P-=max(0,c(x.upper())-o);o+=o<2
v=8==len(t)and all(8==sum(int(x)for x in re.sub("[A-z]","1",p))for p in t)and p>0<P and c('k')==c('K')==1
print(v)
Try it Online!
Try it Online with all of the test cases!
-11 bytes thanks to Mr. Xcoder
-13 bytes thanks to Jonathan Allen
+22 I forgot kings existed.
Semi-ungolfed with some explanation:
import re
string = input()
split = string.split("/")
count = string.count # find # of occurences of char in string
pawns = 9 # represents the # of pawns a player has out of the game... plus one, e.g. 1 is all in game, 2 is one out, 0 is invalid
PAWNS = 9 # would be 8, but then I would need >= instead of >
offset = 0 # default for pawns
for char in "pqrnb": # for each pawn, each queen over 1, and each rook/knight/bishop over 2 for each player
    # subtract one from the players 'pawns' var, which must end up 1 or greater to be valid
    # otherwise too many pawns/queens/etc of that player are on the board
    pawns -= max(0,count(char)-offset)
    PAWNS -= max(0,count(char.upper())-offset)
    offset += (offset 0 and PAWNS>0 and \ # make sure each player does not have an invalid number of pawns/q/n/b/r
    count('k')==count('K')==1 # correct # of kings
print(valid)

I think and p*P>0 would work instead of and p>0 and P>0.

P and p could both be negative if both opponents have too many pawns/queens/rooks/knights/bishops

234 bytes. I replaced ,p,P=9,9 with ;P=p=9.

230 bytes. Why did you have unnecessary spaces in the for-loop :/

225 bytes: You can use p>0<P instead of p>0and P>0 to save 5 bytes too. Alternatively, you could have used p and P (for -3 bytes), you don't need the >0, because non-zero values are truthy in Python

You are welcome. However, I kind of question the validity of this answer, because in test case #3, one player cannot have more than 2 rooks :/

Pawns can be upgraded, the spec says that there are 7 lowercase pawns and 4 rooks, whereas my eyes only see 6 lowercase 'p's.

I used the P>0<p idea for kings too (which I forgot originally >.<)

You can save 13 bytes by initialising with o=0 before the loop and incrementing with  o+=o<2 at the end of the loop's body.

JavaScript (ES6), 181 172 174 bytes
f=([c,...s],n=1,o={p:0,P:0})=>c?c=='/'&&n%9?0:f(s,n+(+c||1),(o[c]=(o[c]||0)+(/[qrbn]/i.test(c)&&o[c]>1-/q/i.test(c)?!o[c>'a'?'p':'P']++:1),o)):o.p<9&o.P<9&n==72&o.k==1&o.K==1

Ungolfed:
f=
  ([c,...s],                 //c is current character
   n=1,                      //n is current square, range [1-72] (board is 9x8 due to slashes)
   o={p:0,P:0}               //o holds piece counts
  )=>
  c?
    c=='/'&&n%9?0:           //ensure 8 squares per row
    f(s,
      n+(+c||1),             //increment n by the correct number of squares
      (o[c]=(o[c]||0)+(/[qrbn]/i.test(c)&&o[c]>1-/q/i.test(c)?!o[c>'a'?'p':'P']++:1),o)
                             //"depromote" extra queens, rooks, bishops, or knights
     ):
  o.p<9&o.P<9&               //no more than 8 pawns per side (accounting for promotions)
  o.k==1&o.K==1&             //each side has one and only one king
  n==72                      //correct number of squares

f=([c,...s],n=1,o={p:0,P:0})=>c?c=='/'&&n%9?0:f(s,n+(+c||1),(o[c]=(o[c]||0)+(/[qrbn]/i.test(c)&&o[c]>1-/q/i.test(c)?!o[c>'a'?'p':'P']++:1),o)):o.p<9&o.P<9&n==72&o.k==1&o.K==1

console.log(f('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR')); //true
console.log(f('2br2k1/1p2n1q1/p2p2p1/P1bP1pNp/1BP2PnP/1Q1B2P1/8/3NR2K')) //true
console.log(f('r2r2k1/p3q2p/ppR3pr/rP4bp/3p4/5B1P/P4PP1/3Q1RK1')); //false
console.log(f('6k1/pp3ppp/4p3/2P3b1/bPP3P1/3K4/P3Q1q1')); //false
console.log(f('3r1rk1/1pp1bpp1/6p1/pP1npqPn/8/4N2P/P2PP3/1B2BP2/R2QK2R')); //false
console.log(f('5n1k/1p3r1qp/p3p3/2p1N2Q/2P1R3/2P5/P2r1PP1/4R1K1')); //false
console.log(f('rnbqkbnr/pppppppp/8/35/8/8/PPPPPPPP/RNBQKBNR')); //true
console.log(f('rnbqkbnr/pppppppp/8/35/8/8/PPPPPPPP/RNQQKBNR')); //false, too many queens

Fail K7/8/8/8/8/8n8/k7

PHP, 269 bytes
$t=($o=count_chars($a="$argn/"))[47]==8&$o[107]==1&$o[75]==1&9>($w=$u=$o[80])&9>$b=$l=$o[112];foreach([81,82,78,66]as$k=>$v){$z=$k?11:10;$b+=$x=$o[32+$v];$t&=$l+$x<$z;$w+=$x=$o[$v];$t&=$u+$x<$z;}$t&=$b<16&$w<16;for(;$c=$a[$n++];)$c<A?$c>0?$s+=$c:$t&=!$s-=8:++$s;echo$t;

Try it online!

Python 3, 263 bytes
s=input()
n=0
for a in s.split('/'):n+=sum([int(c)if c in"123456789"else 1for c in a])
m=lambda k:{c:s.count(c)for c in s}.get(k,0)
p=[m("p"),m("P")]
for c in"rnbqRNGQ":b=c in"qQ";p[c<"Z"]+=m(c)+b-2if m(c)>2-b else 0
print((n==64)&(p[0]<9>p[1])&(m("K")>0<m("k")))

Try it online!
Not the smallest Python submission, but I think it still has some promise.

JavaScript (Node.js), 122 bytes
s=>[a={q:1,Q:1},...s].map(c=>+c?n-=c:a[c=a[c]>1?c<a?'P':'p':c]=-2*!(n--%9)-~a[c],n=72)|!(n|a['/']+7|a.k*a.K-1|a.p>8|a.P>8)

Try it online!
JavaScript (Node.js), 123 bytes
s=>[...s].map(c=>+c?n-=c:a[c=a[c]>1?c<a?'P':'p':c]=-2*!(n--%9)-~a[c],a={q:1,Q:1},n=71)&&!(n|a['/']+7|a.k*a.K-1|a.p>8|a.P>8)

Try it online!
Arnauld's solution but use a as object rather than array. Would see which is shorter
s=>[...s].map(
  c=>+c?n-=c:                    // number, skip spaces
  a[c=a[c]>1?c<a?'P':'p':c]=     // if there's two, count on pawn
                                 // promoting to pawn don't make it bad
                                 // promoting to king mean there's 2 king and anyway invalid
                                 // promoting to slash mean there's slash on unintended places, invalid
  -2*!(n--%9)-~a[c],             // subtract on slash position, all 7 chances must belong to slash
  a={q:1,Q:1},                   // an extra queen, so only 1 extra before needing promotion
  n=71                           // board size
)&&!(
  n|                             // length unmatched
  a['/']+7|                      // unintended slash or non-slash
  a.k*a.K-1|                     // incorrect king amount
  a.p>8|                         // Not too many pawns
  a.P>8)

source: Stack Exchange

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/

sort: votes


text:
Transposes and Diagonals
For this challenge, you should write a program or function which outputs the diagonals of a given square matrix. However, if you transpose the rows and columns of your solution's source code, it should instead become a program or function which returns the matrix's antidiagonals. Read on for specifics...
Rules

The source code of your solution is considered as a 2D grid of characters, separated by a standard newline of your choice (linefeed, carriage return, or a combination of both).
No line in your source code may be longer than the previous one. Here are some examples of valid layouts:
###
###
###

########
#######
###
###
#

And here is an example of an invalid layout (as the third line is longer than the second):
######
####
#####
###

Your two solutions should be each others' transpose, that is you should obtain one from the other by swapping rows and columns. Here are two valid pairs:
abc
def
ghi

adg
beh
cfi

And
print 10
(~^_^)~
foo
bar
!

p(fb!
r~oa
i^or
n_
t^
 )
1~
0

Note that spaces are treated like any other characters. In particular, trailing spaces are significant as they might not be trailing spaces in the transpose.
Each solution should be a program or function which takes a non-empty square matrix of single-digit integers as input. One solution should output a list of all diagonals of the matrix and the other should output a list of all antidiagonals. You may use any reasonable, unambiguous input and output formats, but they must be identical between the two solutions (this also means they either have to be both functions or both programs).
Each diagonal runs from the top left to the bottom right, and they should be ordered from top to bottom.
Each antidiagonal runs from the bottom left to the top right, and they should be ordered from top to bottom.

Scoring
To encourage solutions that are as "square" as possible, the primary score is the number of rows or the number of columns of your solution, whichever is larger. Less is better. Ties are broken by the number of characters in the solution, not counting the newlines. Again, less is better. Example:
abcd
efg
h

This and its transpose would have a primary score of 4 (as there are 4 columns) and a tie-breaking score of 8 (as there are 8 non-newline characters). Please cite both values in the header of your answer.
Test Cases
The actual task performed by the two solutions shouldn't be the primary challenge here, but here are two examples to help you test your solutions:
Input:
1 2 3
4 5 6
7 8 9
Diagonals:
3
2 6
1 5 9
4 8
7
Antidiagonals:
1
4 2
7 5 3
8 6
9

Input:
1 0 1 0
0 1 0 1
1 0 1 0
0 1 0 1
Diagonals:
0
1 1
0 0 0
1 1 1 1
0 0 0
1 1
0
Antidiagonals:
1
0 0
1 1 1
0 0 0 0
1 1 1
0 0
1

Related.

As I realized the sandbox post was by you before getting halfway through it, before I got on SE this morning I realized you had already posted this... at this point I'm starting to think I must be psychic :P

Javascript, score 20 14, (258 176 non-newline characters)
///mmm()mu[=+r
///=.av=a,pr"=
///> p,>px=[ [
m=>//(yv()xp"]
m. ////.(=+]+)
map((////>y?u&
v,y)=>v//r]r:&
.map((u,x//[ur
)=>r[p=m.//p)
length-1-//],
x+y]=r[p]////
?r[p]+" "+u//
:u),r=[])&&r

and
///mmmv.)lx?:
///=.a,m=e+ru
///> pya>ny[)
m=>//()prg]p,
m. //(=([t=]r
map(//>(phr+=
(v,y//vu=-["[
)=>v.//,m1p ]
map((//x.-]")
u,x)=>r////+&
[p=x+y]////u&
=r[p]?r[p]//r
+" "+u:u),//
r=[])&&r

Example code snippet:

f=

///mmm()mu[=+r
///=.av=a,pr"=
///> p,>px=[ [
m=>//(yv()xp"]
m. ////.(=+]+)
map((////>y?u&
v,y)=>v//r]r:&
.map((u,x//[ur
)=>r[p=m.//p)
length-1-//],
x+y]=r[p]////
?r[p]+" "+u//
:u),r=[])&&r

console.log(f([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]))

and

f=

///mmmv.)lx?:
///=.a,m=e+ru
///> pya>ny[)
m=>//()prg]p,
m. //(=([t=]r
map(//>(phr+=
(v,y//vu=-["[
)=>v.//,m1p ]
map((//x.-]")
u,x)=>r////+&
[p=x+y]////u&
=r[p]?r[p]//r
+" "+u:u),//
r=[])&&r

console.log(f([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]))

Can you enable syntax highlighting? Place <!-- language-all: lang-javascript --> before the first code block.

MATL, score 10 (100 non-newline characters)
%P!
  Q&%
  TXd!
  %d
     P!
      "@%
       Xz
      %z
         q
         !

There are 10 lines of 10 characters (note the trailing spaces).
The above code produces the diagonals. Try it online!
The transposed version produces the anti-diagonals. Try it online!
Explanation
Note that

% is a comment symbol, which causes the rest of the line to be ignored.
Two-char functions like Xd cannot be split into an X and a d in consecutive lines.

Original code
The original code, linearized and without the commented part, is
Q&TXd!P!"@Xzq!

which works as follows:
Q      % Implicit input. Add 1 to each entry to make them positive
&      % This modifes default inputs/ouputs of next function, which is Xd
       % Specifically, it specifies 2 inputs and 1 ouput
T      % Push true
Xd     % Diagonals of matrix. With second input true, it gives all diagonals,
       % starting from below. The columns are arranged as columns of a matrix,
       % padding with zeros
!P!    % Flip horizontally. This is to produce the correct display order
"      % For each column
  @    %   Push current column
  Xz   %   Remove zeros
  q    %   Subtract 1
  !    %   Transpose into a row
       % Implicit end. Implicit display of stack contents

Transposed code
The transposed code, linearized, is
P!QT&Xd!P!"@Xzq!

which has the following two differences compared to the original code:

T and & are swapped. This has no effect, because T is a literal, not a function, so it doesn't intercept the & specification.
P! is added at the begining.

The added code modifies the input matrix so that the diagonals of the modified matrix are the anti-diagonals of the input:
P      % Implicit input. Flip vertically
!      % Transpose

Jelly, Score 7, 49 non-newline bytes
Diagonal printing program
......U
......Œ
......D
......ṙ
......L
......Ṛ
ŒDṙLṚUU

Try it online!
Anti-diagonal-printing Program
......Œ
......D
......ṙ
......L
......Ṛ
......U
UŒDṙLṚU

Try it online!
Older Answer(Unordered Output), Score 3, 6 non-newline bytes
Diagonal-printing program
UU
UŒ
ŒD

Try it online!
Anti-diagonal printing program
UUŒ
UŒD

Try it online!

Jelly, score 4 (12 characters)
previous scores: 5 (16 characters), 4 (16 characters)
Original
ŒDṙṚ
D  ñ
ṙLñL

Try it online!
Transpose
ŒDṙ
D L
ṙ ñ
ṚñL

Try it online!
Background
Diagonals
The straightforward way of obtaining the diagonals (topmost to bottommost) of a square matrix is as follows.
ŒDṙLṚ

For an input matrix M, ŒD lists M's diagonals, starting with the main diagonal and moving upwards.
For the input
1 2 3
4 5 6
7 8 9

this yields
1 5 9
2 6
3
7
4 8

ṙL then computes M‘s length with L and rotates the result length(M) units to the left.
For our example, the length is 3 and we get
7
4 8
1 5 9
2 6
3

Finally, Ṛ reverses the order of the diagonals, returning
3
2 6
1 5 9
4 8
7

for our example input.
Anti-diagonals
The same building blocks can be used to obtain the anti-diagonals (again, topmost to bottommost) of a square matrix.
ṚŒDṙL

For an input matrix M, Ṛ first reverses the order of the rows.
For the input
1 2 3
4 5 6
7 8 9

this yields
7 8 9
4 5 6
1 2 3

As before, ŒDṙL generates the diagonals (bottommost to topmost) of the result.
For our example, this returns
1
4 2
7 5 3
8 6
9

as desired.
How it works
In Jelly, each line defines a link (function). In particular, the last line defines the main link, which is executed when the program starts.
Other links must be called. This answer uses ñ, which executes the link below dyadically. ñ wraps around, so when it is called from the main link, it executes the link on the first line.
Original
The main link
ṙLñL

takes an input matrix M, computes its length with L, then rotates the input length(M) units to the left with ṙ (note that this doesn't alter M), and finally calls the first link with the result (M) and length(M) as arguments.
The first link
ŒDṙṚ

computes the diagonals of M with ŒD (as seen in the previous section), rotates the result length(M) units to the left with ṙ, then reverses the order of the result with Ṛ.
The second link is never called.
Transpose
The main link
 ṚñL

takes an input matrix M and computes its reverse with Ṛ. It then computes the length of M with L and  calls the first link with arguments reverse(M) and length(M).
The first link
ŒDṙ

then computes the diagonals of reverse(M) with ŒD (as seen in the previous section), and finally rotates the result length(M) units to the left with ṙ.
The remaining links are never called.

Husk, 7 9 4 characters, score 4 3
∂T
m
↔

Try it online!
-4 characters thanks to BMO.

R, score 14 13 11 (99 95 non-newline characters)
Thanks to @Giuseppe for improving the score by 1. Shaved off a few characters by making use of redundancies in the transpositions. Currently the best score for a non-golfing language!
######`,scr
`::`(#:fpoo
pryr,#:)llw
f)(###`(i((
split (#tmm
p,col(p#())
)+row#r#m-)
(p)))#y#,#)
######r

And transposed:
#`pfsp)(#
#:r)p,+p#
#:y(lcr)#
#`r#ioo)#
#(,#tlw)#
#### (###
`::`(pryr
,f)(####
split(m,
col(m)-#
row(m)))

Try it online!

row(m)+col(m) is shorter for the anti-diagonals.

@Giuseppe Of course, thanks! Edited now.

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


text:
Every Nth Char in Source Outputs N
Heavily inspired by Hello, World! (Every other character)
Write a program that outputs 1. When the first, third, fifth, etc. chars are removed, it outputs 2. When all chars where their (1-based) index in the source, mod N, are not 0, are removed, it should output N.
This is code-challenge. The winner is the program that works with the largest N, while working for all n < N (obviously, to run up to N, it has to be at least N characters long). If there is a tie, the winner is the shortest answer that reaches the largest N. Your program must at least work up to N=2, since I don't think any languages will struggle with simply printing 1. To prevent programs extending infinitely, your program may not be longer than 1024 bytes.
Example
Examples are based off of this sample program: abc123def456ghi789.
For the program to work for N=1, abc123def456ghi789 should output 1.
For the program to work for N=2, b13e46h79 should output 2.
For the program to work for N=3, c3f6i9 should output 3.
For the program to work for N=4, 1e67 should output 4.
For the program to work for N=5, 24i should output 5.
For the program to work for N=6, 369 should output 6.
For the program to work for N=7, dh should output 7.
etc.
The highest N this program could work for is its length, 18.
Remember that the winner will be the question that works for the largest N that also works for all smaller ns where n<N.
This is not a duplicate of Run the Nth characters to get N. That challenge take the first char and the each Nth char after that, while mine takes the Nth char and each Nth char after that. In addition, that is code-golf, and only is for N <= 16

Sandbox

Very closely related. (Same challenge as code golf with fixed N.)

Is there any reason to assume that scoring by N doesn't just turn this into an exercise in patience for who can be bothered to add the most numbers? I don't see any natural upper limit.

@MartinEnder that challenge also always starts with the first character. Personally, I doubt that someone can go near infinite with it - I personally can't see any way you'd implement this infinitely. That's partly because of the difference in which chars get removed from my challenge and Helka's. If the answers prove me wrong I may need to set a byte cap or something. Thanks for the input.

@cairdcoinheringaahing as I already said, it's not. That challenge take the first char and the each Nth char after that, while mine takes the Nth char and each Nth char after that. In addition, that is [tag:code-golf], and only is for N <= 16

@StepHen but the underlying challenge is the same: output N from code made from the Nth chars. The fact that it's code golf doesn't count as I could make a Hello World challenge, where the winning criteria was fastest code but it'd still be closed as a dupe. And the N <= 16 is the minimum requirement so that people don't just submit a 1 byte answer. I could easily find an answer from that thread and answer it here, therefore this is a dupe.

@cairdcoinheringaahing from the other challenge: Your program does not have to work for N = 17 or above. If you want, I can bump up my minimum (currently N = 2)

@StepHen it doesn't have to but answers can be adapted to do so.

@MartinEnder thanks for the input about the upper limit, I'm added a byte cap.


text:
Staircase numbers
A staircase number is a positive integer x such that its nth digit (one indexed starting with the least significant digit) is equal to x % (n + 1).  Thats a bit of a mouthful so lets look at an example.  Take 7211311, if we take the modular residues of 7211311 on the range 2-8 we get the following:
7211311 % 2 = 1
7211311 % 3 = 1
7211311 % 4 = 3
7211311 % 5 = 1
7211311 % 6 = 1
7211311 % 7 = 2
7211311 % 8 = 7

These are the digits of 7211311!  Thus 7211311 is a staircase number.
Task
Write code that takes when given a positive number as input, will output two distinct values one if the number is a staircase number and the other if it is not.
This is a code-golf competition so your aim should be to minimize the number of bytes in your source code.
Test Cases
Here are the first 13 staircase numbers:
1, 10, 20, 1101, 1121, 11311, 31101, 40210, 340210, 4620020, 5431101, 7211311, 12040210

Isn't 0 a staircase numbers? A lot of answers think so.

@Okx the task is just to distinguish positive staircase numbers from positive non-staircase numbers, so the behavior is undefined for 0 and negative numbers.

Haskell, 55 57 bytes
f m|let n#x=n==0||n`mod`10==m`mod`x&&div n 10#(x+1)=m#2

A different approach than the other Haskell solution.
Thanks xnor for saving 2 bytes.

You can use this tip to shorten the let expression.

A different, shorter approach. Well done! +1

n==0 → n<1 saves a byte.

Brachylog, 25 21 16 14 bytes
{it+₂;?↔%}ᶠ↔c?

Try it online!
First Brachylog submission :D probably very ungolfed...many thanks to Leaky Nun and Fatalize for encouragement and help to golf this from 25 all the way down to just 14. :) :)

05AB1E, 6 bytes
Code:
ā>%JRQ

Uses the 05AB1E encoding. Try it online!
Explanation:
ā        # Get the range [1 .. len(input)]
 >       # Increment by 1
  %      # Vectorized modulo
   J     # Join the array into a single number
    RQ   # Reverse that number and check if it's equal to the original input

Javascript, 42 41 39 38 bytes
-4 bytes thanks to @Shaggy and @ETHProductions
s=>[...s].some(d=>s%i++^d,i=~s.length)

This takes the number as a string and returns false if the number is a staircase number and true otherwise.
Example code snippet:

f=
s=>[...s].some(d=>s%i++^d,i=~s.length)

function update() {
  o.innerText = f(document.getElementById("i").value)
}
<input id="i" type="number">
<button onclick="update()">Test</button>
<p id="o">

You should be able to drop the ! as the challenge doesn't explicitly specify that you must return true for true and false for false, simply that you must return 2 distinct values.

This is very well golfed, well done. I think you should be able to squeeze out two more bytes if you calculate i yourself: s=>[...s].some(d=>s%i--^d,i=s.length+1)

Actually, by exploiting the fact that ~x == -(x+1) on integers and x%-y == x%y, I think you can get one more: s=>[...s].some(d=>s%i++^d,i=~s.length)

Python 2, 54 bytes
f=lambda n,x=0:10**x>n or(`n%(x+2)`==`n`[~x])*f(n,x+1)

Try it online!

Haskell, 60 bytes
Takes the number as an int
x n|s<-show n=reverse s==(rem n.(+1)<$>[1..length s]>>=show)

Japt, 9 7 6 bytes
Takes input as a string.
Ô¶¡%´J

2 bytes saved with help from ETHproductions.
Try it
Ô¶¡%´J     :Implicit input of string U
Ô          :Reverse
 ¶         :Test for equality with
  ¡        :Map U
   %       :  Modulo
    ´J     :  J (initially -1) prefix decremented

Gosh darn (Y+2, I feel like that could be at least 1 byte shorter...

...and it can: ¥£%´JÃw :-) (works because x%y == x%-y in JS)

Aha, yes, was trying a few different things to get that calculation down to 2 bytes.

Mathematica, 60 bytes
FromDigits@Reverse@Mod[#,Range@Length@IntegerDigits@#+1]==#&

Try it online!
@alephalpha golfed it to 48
Mathematica, 48 bytes
FromDigits@Reverse@Mod[#,Range[2,Log10@#+2]]==#&

next one is 24120020

Neim, 6 bytes
ᛖ

Explanation:
         Get the length of the input, then create an exclusive range
 ᛖ        Add 2 to each element
         Modulus
          Reverse
          Join
         Check for equality

Try it online!

@Thehx Regarding your edit, Neim uses a custom encoding: this one

Jelly, 7 bytes
DJ‘⁸%⁼Ṛ

Try it online!

Pyth, 13 bytes
-1 bytes thanks to Okx.
qsjk_m%QhdSl`

Try it online!
Explanation
             QQ    # Implicit input
          Sl`Q     # Generate [1, len(str(Q))]
     m%Qhd         # For digit d in above range, perform Q % (d + 1)
 sjk_              # Reverse, then convert to number
q             Q    # Test equality with input

Alternate solution, still 13 bytes (thanks to karlkastor)
qi_.e%Q+2k`QT

Try it online! That's essentially the same as the first solution, excepted that it uses i to convert from array of numbers to a number, and that the range is generated differently.

You can replace ss\M_withjk_` to save 2 bytes.

@Okx I need it because j outputs a string whereas I need a number to compare with the input (which is a number).

Another 13 byte solution would be: qi_.e%Q+2k\QT using enumerated map (.e`) instead of map. And converting the remainders to a base 10 int from the list instead of using join.

Python 2, 56 bytes
lambda x:all(`x%(i+2)`==`x`[~i]for i in range(len(`x`)))

Try it online!

PHP, 43 bytes
for(;$r<$a=$argn;)$r=$a%~++$i.$r;echo$r>$a;

Try it online!
PHP, 44 bytes
prints 1 for true and nothing for false

for(;$r<$a=$argn;)$r=$a%~++$i.$r;echo$r==$a;

Try it online!

Perl 6, 32 bytes
{$_ eq[~] $_ «%«(1+.comb...2)}

Try it online!

.comb is the number of characters in the string representation of the input argument $_ (that is, the number of digits).
1 + .comb ... 2 is the sequence of numbers from one greater than the number of digits down to 2.
«%« is the modulus hyperoperator that gives the remainder when $_, the input argument on its left, is divided by each of the elements of the sequence on its right: $_ % 2, $_ % 3, ....
[~] concatenates those digits into a new number, which is compared with the input argument using the string equality operator eq.

C++,104 bytes
1) original version:
int main(){int N,T,R=1;cin>>N;T=N;for(int i=1;i<=log10(N)+1;i++){if(N%(i+1)!=T%10){R=0;}T/=10;}cout<<R;}

2) in a readable form:
int main()
{
    int N, T, R = 1;

    cin >> N;
    T = N;

    for (int i = 1; i <= log10(N) + 1; i++)
    {
        if (N % (i + 1) != T % 10)
        {
            R = 0;
        }

        T /= 10;
    }

    cout << R;
}

Try it Online!

APL (Dyalog Extended), 21 19 bytes
{⍵=10⊥⌽⍵|⍨1↓⍳1+≢⍕⍵}

Try it online!
Creates two lists of digits and check if they are equal.
Explanation
{⍵=10⊥⌽⍵|⍨1↓⍳1+≢⍕⍵} ⍵ → input
               ≢⍕⍵  length of ⍵ as a string
             1+     +1
            ⍳       range from 1 to that
          1↓        Drop first element
       ⍵|⍨          ⍵ mod each element in range
      ⌽             reversed
   10⊥              converted from base 10
 ⍵=                 equals the input?

Pari/GP, 42 bytes
n->Vecrev(s=digits(n))==[n%d|d<-[2..#s+1]]

Try it online!

Python 2, 66 60 58 57 bytes

Thanks to @Leaky nun for 6 bytes: remove unneeded x and (shouldnot check for 0)
Thanks to @Einkorn Enchanter for 1 byte: use of enumerate

lambda x:all(a==`x%(i+2)`for i,a in enumerate(`x`[::-1]))

Try it online!

Shorter if you enumerate

Thank you. And hey, I just realised you were wheat wizard.. :D

This is a very late comment, but enumerate can take a second argument "number to start counting from", so x%i and enumerate(…,2) saves two bytes.

Charcoal, 20 15 bytes
⌊Ｅθ⁼ιＩ﹪Ｉθ⁻⁺¹Ｌθκ

Try it online! Outputs - for a staircase number, nothing otherwise. Link is to verbose version of code.

Java 8, 156 149 bytes
interface B{static void main(String[]s){String f="";for(int i=1;i<=s[0].length();)f=new Long(s[0])%++i+f;System.out.print(f.equals(s[0]));}}

Ungolfed :
interface B {
    static void main(String[] s) {
        String f = "";
        for (int i = 1; i <= s[0].length();)
            f = new Long(s[0]) % ++i + f;
        System.out.print(f.equals(s[0]));
    }
}

Try it Online !
UPDATE :
-7 bytes : removed useless {} and replaced Integer.parseInt(...) by new Integer(...)
-9 bytes : thanks to Kevin Cruijssen, removed a bunch of useless (), used Long instead of Integer and print instead of println. Thanks Kévin !

Nice answer, +1 from me. Btw, some small things to golf: new Integer can be new Long (-3 bytes); println can be print (-2 bytes); and you can remove the parenthesis surrounding new Long(s[0])%i+f; (-4 bytes).

Really nice ! Thanks, i'll update this !

Python 3: 63 Bytes
lambda m:all(int(x)==m%(n+2)for n,x in enumerate(str(m)[::-1]))

If I could count the number of times I wished 'enumerate' were shorter...
Try it online!

Yep, and I just realized its exactly the same as the answer @officialaimm gave...  Should I remove?

Theirs is in python 2 and you came up with it independently so I would leave it.

Can save two bytes by starting your enumeration at 2 and rearranging the logical: lambda m:all(m%n==int(x)for n,x in enumerate(str(m)[::-1],2))

Java (OpenJDK 8), 60 bytes
n->{int m=2,r=0,t=1;for(;n>=t;t*=10)r+=n%m++*t;return r==n;}

Try it online!
A non-string version.

Haskell, 53 bytes
f n=foldr(\(k,_)a->10*a+mod n k)0(zip[2..]$show n)==n

Try it online!

Python 2, 61 bytes
lambda x:[`x%(n+2)`for n in range(len(`x`))][::-1]==list(`x`)

Nope, your new golf is a byte shorter. :)

q/kdb+, 34 bytes
Solution:
{s~raze($)x mod'2+(|)(!)(#)s:($)x}

Example:
q){s~raze($)x mod'2+(|)(!)(#)s:($)x}7211311 / this is a staircase number (true)
1b
q){s~raze($)x mod'2+(|)(!)(#)s:($)x}7211312 / this is not (false)
0b
q)t(&){s~raze($)x mod'2+(|)(!)(#)s:($)x}each t:1 + til 1000000 / up to a million
1 10 20 1101 1121 11311 31101 40210 340210

Explanation:
Cast the input number to a string, count from 0..length of string, add 2 to all, reverse it and feed each number into mod along with the original input. Cast the result of the mod to a string and reduce the list, check if it is equal to the string of the input number:
{s~raze string x mod'2 + reverse til count s:string x} / ungolfed solution
{                                                    } / lambda function
                                           s:string x  / convert input to string, save as s
                                     count             / return length of this string
                                 til                   / like python's range() function
                         reverse                       / reverses the list
                     2 +                               / adds two to each element in the list
               x mod'                                  / ' is each both, so feeds x, and each element of the list to modulo function
        string                                         / converts output list to string list ("7";"2";"1"..etc)
   raze                                                / reduce list ("721...")
 s~                                                    / is s equal to this reduced list, returns boolean

Notes:
Most of the solution is for generating the 2,3,4.. list, I have another solution that does less stuff, but winds up being 37 bytes after golfing:
{s~x mod'reverse 2 + til count s:("J"$) each string x} / ungolfed
{s~x mod'(|)2+til(#)s:("J"$)each($)x}                  / golfed

Clojure, 75 bytes
#(=(sort %)(sort(map(fn[i c](char(+(mod(Integer. %)(+ i 2))48)))(range)%)))

Input is a string, using map and the trailing % ended up being shorter than for[i(range(count %))] approach.

Haskell, 62 bytes
f x=and$zipWith(==)(reverse$show x)$map(head.show.mod x)[2..]
Instead of reversing the (infinite) list of moduli, it truncates the list by zipping it with the reversed string-respresentation of the integral x, which it then ensures is equal element-wise.

Perl 5, 41 bytes
39 bytes of code + 2 flags -pa
map{$\||=$_!=$F[0]%++$n}0,reverse/./g}{

Try it online!
Outputs nothing (undef) for staircase numbers, 1 for anything else

MathGolf, 7 bytes
mækî)%Ñ

Input as a string.
Try it online.
Explanation:
m        # Map over each character of the (implicit) input-string,
 æ       # using the following four characters as inner code-block:
         #  (implicitly push the current character of the map)
  k      #  Push the input as an integer
   î     #  Push the 1-based map-index
    )    #  Increase it by 1
     %   #  Take the input-integer modulo (1-based) index+1
         # After the map, the digits are implicitly joined together to a string
      Ñ  # Check that this string is a palindrome
         # (after which the entire stack joined together is output implicitly as result)

Arturo, 42 bytes
$[n][1every? reverse digits n'x->x=n%<=1+]

Try it

Nibbles, 8.5 bytes
==.,,;`@~$%_+$~\@

Attempt This Online!
==.,,;`@~$%_+$~\@
==                Equal
  .                map
   ,                range
    ,                length
     ;                A :=
      `@~              decimal digits
         $              input
          %         mod
           _         input
            +        add
             $        it
              ~       1
               \   reverse
                @   A

C (GCC), 65 64 bytes
-1 byte thanks to @ceilingcat
i,j,k;f(n){for(i=j=k=1;++j,i<n;i*=10)k=n/i%10^n%j?0:k;return k;}

Try It Online!
Explanation:
i,j,k;
f(n)
{
    // i and k are 1, j is 2 since it's incremented before the first check for
    // i < n (and at the end of every loop). i is multiplied by 10 at the end
    // of each iteration.
    for(i=j=k=1;++j,i<n;i*=10)
        // If digit i doesn't equal n modulo j, set k to 0.
        k=n/i%10^n%j?
            0
        :
            k;

    return k;
}

Suggest k*=n/i%10==n%j instead of k=n/i%10^n%j?0:k


text:
Output a primitive element for each field size
A primitive element of a finite field is a generator of the multiplicative group of the field. In other words, alpha in F(q) is called a primitive element if it is a primitive q−1th root of unity in F(q).  This means that all the non-zero elements of F(q) can be written as alpha^i for some (positive) integer i.
All elements of the field F_{2^k} can be written as polynomials of degree at most k-1 with coefficients that are either 1 or 0.   In  order to make this complete, your code also needs to output an irreducible polynomial of degree k which defines the field you are using.
The task is write code that outputs a primitive element of F_{2^k} of your choosing for each k = 1 .. 32 in order.
Your output  must simply list the k coefficients of the primitive element in any format that you like and then  on a separate line the k+1 elements of the irreducible polynomial.  Please separate the outputs for each value of k if possible.
Your code may take as long as you like but you must have run it to completion before submitting your answer.
You may not use any builtin or library function which returns primitive elements of a finite field or tests whether an element is primitive.
An example
For k = 1 the only primitive element is 1.
For k = 2 we have  F_4. The 4 elements are {0, 1, x, x + 1} so there are two primitive elements x and x + 1.  So the code could output
1 1
1 1 1

as the coefficients for example where the second line is the irreducible polynomial which in this case is x^2+x+1 which has coefficients 1 1 1.

Got any examples?

May we also output the polynomials and/or field elements encoded as the bits of an integer we output?

@orlp Yes absolutely.

I think Pari/GP is the only language that has a built-in for this.

Can I use a built-in to test whether a polynomial is primitive?

@alephalpha Good question. No please don't.  Having said that, if you have a non competing answer. In gp/pari I could add it to the question and use it to produce more examples.

@Lembik OK. Try it online!

@alephalpha: Macaulay2 has a couple of builtins for this too.

…or you can avoid those builtins with something like n->(k=GF 2^n;lift(k_0,ambient k)).

Your examples are wrong. You say k=1, k=2,  but the fields you describe are F_1, F_2, not F_2, F_4.

@isaacg, F_1 would be quite the challenge.

@isaacg I think the examples are OK. F_1 doesn't exist. See https://en.wikipedia.org/wiki/Field_with_one_element

@Lembik You're right, I misunderstood the challenge

Pari/GP, 114 bytes
Inspired by isaacg's answer in another question.
for(n=1,32,for(i=1,2^n,if(sumdiv(2^n-1,d,Mod(x,f=Mod(Pol(binary(2*2^n-i)),2))^d==1)==1,print([x,lift(f)]);break)))

Try it online!

If built-ins are allowed:
Pari/GP, 61 bytes (non-competing)
for(i=1,32,print([ffprimroot(ffgen(f=ffinit(2,i))),lift(f)]))

Try it online!

Mathematica, 127 bytes
Do[For[i=2*2^n,PolynomialMod[x^Divisors[2^n-1]+1,i~IntegerDigits~2~FromDigits~x,Modulus->2]~Count~0!=1,i--];Print@{2,i},{n,32}]

Explanation:
If we choose a primitive polynomial as the irreducible polynomial, then \$x\$ is a primitive element. A irreducible polynomial of degree \$n\$ is primitive if and only if it has order \$2^n - 1\$, i.e., it is divisible by \$x^{2^n - 1} - 1\$, but not divisible by any \$x^i - 1\$, where \$i\$ runs through all the proper divisors of \$2^n - 1\$.
Output:
Outputs integers whose bits are the coefficients of the polynomials. For example, \$8589934581\$ is \$111111111111111111111111111110101\$ when written in binary, so it represents the polynomial $$x^{32}+x^{31}+x^{30}+x^{29}+x^{28}+x^{27}+x^{26}+x^{25}+\\x^{24}+x^{23}+x^{22}+x^{21}+x^{20}+x^{19}+x^{18}+x^{17}+\\x^{16}+x^{15}+x^{14}+x^{13}+x^{12}+x^{11}+x^{10}+x^9+\\x^8+x^7+x^6+x^5+x^4+x^2+1$$

{2,3}

{2,7}

{2,13}

{2,25}

{2,61}

{2,115}

{2,253}

{2,501}

{2,1019}

{2,2041}

{2,4073}

{2,8137}

{2,16381}

{2,32743}

{2,65533}

{2,131053}

{2,262127}

{2,524263}

{2,1048531}

{2,2097145}

{2,4194227}

{2,8388589}

{2,16777213}

{2,33554351}

{2,67108849}

{2,134217697}

{2,268435427}

{2,536870805}

{2,1073741801}

{2,2147483533}

{2,4294967287}

{2,8589934581}

This is nice. I look forward to the Jelly version :)


text:
Fastest Gun in the West
You are the roughest, toughest, coolest cowboy west of the Mississippi. However, some weird guy on a wacky nerd website decided that it would be cool to plop you into random unfinished landscapes and fight. No matter, you'll still win. However, to help you win those grueling gunfights you'll write home about, it's helpful to know how many bullets the coward lurking in the landscape has.
How about you help this poor guy out. Given an ASCII landscape, find the gun inside it and tell him how many bullets are loaded into it. This is the gun:
  (X)
(X\ /X)
 (XVX)
  \X/

Each X in the above picture is a potential slot for a bullet. The slot will either contain a space or one of 0,O,o (may not be consistent - the cowboy may have loaded different types of bullets in his gun).
There will always be exactly one gun, matching the above description, in the landscape. However, please note that the spaces around and inside the gun can contain anything.
Input
You will be given a string containing printable ASCII (so not tabs) and newlines to separate lines. You may also take a list of strings, if you wish. Strings will all be padded with spaces, so they will all be the same length. The input will be at least 4 rows high and 7 columns wide.
There will always be exactly one gun in the landscape.
Output
You will output how many bullets (0, O, o) there are in the gun, so your output will always between 0 and 6.
Test Cases
  (0)   ( )
(o\ /o( \ / )
 (oVo) ( V )
  \o/   \ /

0

----------------------------
////////////////////////////
////////////////////////////
/////////////(o)////////////
///////////(0\// )//////////
////////////( Vo)///////////
/////////////\ /////////////
////////////////////////////
----------------------------

3

()()()()()()()()()()()()()()()()\)/)()()()()()()()()()()()()
()()()()()()()()()()()()()()()()(V)()()()()()()()()()()()()(
()()()()()()()(\0/)()()()()()()()()()()()()()()()()()()()()(
()()()()()()()()()()()()()()()()()()()()()()()( )()()()()()(
()()()()()()(o)()()()()()()()(00)()()()()()(( \(/0)()()()()(
()()()()()()()()()()()()()()()()()()()()()()(( V )()()()()()
()()()()()()()()()()()()()()()()()()()()()()()\O/()()()()()(

2

------(0)---
||||(0\|/0)
-----(0V0)--
||||||\0/
-------_------
|||||||-|
------|-|
|||||||-|
------|-|

6

00ooOO(0)/\\/V

  ( )
( \\/ )
 ( V )
 \\ /

00OOoo()()()())))

0

  (\)     (0)
(0\\/0) ( \0/ )
 (0V0)   ( V )
 \\0/     \ /

1 (left gun is invalid because of the `\` in the bullet slot)

-00(0)00\0
-(O\0/o)\
- (OVo)o\0
-o \ /oo/

5

This is code-golf, so shortest answer in bytes wins.

Sandbox

+1 If someone FGITWs this challenge ;)

You should add a test case where there's a 0 inside the gun's bounding box but outside the gun.

@StepHen Oh right, there's the one zero inside the gun that doesn't belong to it. It would be good to have zeros outside the gun but within its bounding box as well though.

"The input will be at least 4 rows high and 5 columns wide." - if there is always a gun then the input must be at least 7 columns wide.

Snails, 71 bytes
Try it online.
A
\/a=\)2w\V={\\u\(}c=\/b={\\c\(2}u!{(nb|.|.n.)=^o=^O=^0^ }{nb|.|.n.}^

Programming language for 2-dimensional pattern matching. you must be glad I made this challenge then :P

Do you have a link to this language? It's pretty funny that the fastest gun in the west is a snail.

@PyRulez Here is a link for you

@PyRulez you can click the language name on the TIO page

I am interested in how this works.

@KritixiLithos You can check out the documentation.

Mathematica, 170 bytes
Catch@BlockMap[b="O"|"o"|"0";MatchQ[#,p=Characters@{"  (X)  ","(X\\ /X)"," (XVX) ","  \\X/  "}/." "->_/."X"->$;p/.$->b|"X"|" "]&&Throw@Count[Pick[#,p,$],b,2]&,#,{4,7},1]&

Takes an array of strings/chars. Returns the number of bullets.

JavaScript, 215 211 209 bytes
Thanks to Shaggy for -4 bytes!

f=

i=>[...i].map((_,x)=>eval(String.raw`a=i.match(/(\n|^).{${x}}..\(${Z='([oO0 ])'}\).*\n.{${x}}\(${Z}\\.\/${Z}\).*\n.{${x}}.\(${Z}V${Z}\).*\n.{${x}}..\\${Z}\//);a&&alert(a.filter(i=>/^[oO0]$/.test(i)).length)`))

tests = [["  (0)   ( )\n(o\\ /o( \\ / )\n (oVo) ( V )\n  \\o/   \\ /",0],["----------------------------\n////////////////////////////\n////////////////////////////\n/////////////(o)////////////\n///////////(0\\// )//////////\n////////////( Vo)///////////\n/////////////\\ /////////////\n////////////////////////////\n----------------------------",3],["()()()()()()()()()()()()()()()()\\)/)()()()()()()()()()()()()\n()()()()()()()()()()()()()()()()(V)()()()()()()()()()()()()(\n()()()()()()()(\\0/)()()()()()()()()()()()()()()()()()()()()(\n()()()()()()()()()()()()()()()()()()()()()()()( )()()()()()(\n()()()()()()(o)()()()()()()()(00)()()()()()(( \\(/0)()()()()(\n()()()()()()()()()()()()()()()()()()()()()()(( V )()()()()()\n()()()()()()()()()()()()()()()()()()()()()()()\\O/()()()()()(",2],["------(0)---\n||||(0\\|/0)\n-----(0V0)--\n||||||\\0/\n-------_------\n|||||||-|\n------|-|\n|||||||-|\n------|-|",6],["00ooOO(0)/\\\\/V\n\n  ( )\n( \\\\/ )\n ( V )\n \\\\ /\n\n00OOoo()()()())))",0],["  (\\)     (0)\n(0\\\\/0) ( \\0/ )\n (0V0)   ( V )\n \\\\0/     \\ /",1]]

alert = x => i = x;

tests.forEach((t, index) => {
    i = 'Not Found'
    f(t[0]);
    document.getElementById('a').textContent += t[0] + '\n\n' + i + '\n\n';
    if (i != t[1]) {
        document.getElementById('a').textContent += 'Failed test ' + index + '! Expected '  + t[1] + '\n\n';
        document.getElementById('a').style = 'color: red'
    }
})

Basically, tries to match a gun n characters after a line break, for n from 0 to the length of the string.

Save a few bytes by assigning to Z within the literal, the first time you use it and getting rid of the {}.

Python 2, 219 224  227 bytes
import re
f=lambda s:sum(sum(g>' 'for g in m.groups())for m in[re.match(r'.*@..\(X\)..@\(X\\./X\)@.\(XVX\).@..\\X/.*'.replace('X','([0Oo ])').replace('@',r'[^\n]*\n.{%d}'%i),'\n'+s,re.DOTALL)for i in range(0,s.find('\n'))]if m)

EDIT: Fixed a bug which cost me 5 bytes :(... found 3 bytes of extra r''s that weren't needed. And then Grrr!! Was not counting \ chars in my code correctly, so added 6...
Takes a string with newlines; retuns the number of bullets found.
Basically, applies a regex that looks for the gun pattern with 0, 1, ... lineLength characters of pad at the beginning of the lines.

C (gcc), 357 351 bytes
#define M(F,C)F(i){i=s[i]==C;}
b,i;char*s,c;M(L,'(')M(R,')')M(A,'/')M(D,'\\')M(V,'V')B(i){i=b=(c=s[i])==32?b:c==111?b+1:c==79?b+1:c==48?b+1:0;}(*t[])(int)={L,B,R,L,B,D,A,B,R,L,B,V,B,R,D,B,A};main(j,v,k,l)char**v;{for(s=v[1];s[l++]!=10;);for(;k=i,s[i++];){for(j=17;j--;)if(!(t[j])(k-=j==13?l-3:j==8?l-5:j==5?2:j==2?l-4:1))break;b=j<0?putchar(b+47):1;}}

Try it online! (golfed) (expanded) (357 golfed) (357 expanded)
I wondered how bad a solution would be in a language without built-in pattern matching. It came out a lot smaller than I feared.
Basically, this approach breaks the gun down into a series of individual parts it expects to see in specific locations relative to a specific index. If all parts are found where they are expected, it's a gun! The bullet test increments a global counter to keep track of how many bullets were in it, which we print when we have found the one and only gun in the landscape.
Note 1: I padded the test cases with spaces to ensure consistent row widths.
Note 2: Add 10 bytes if you don't like the assign instead of return trick. For clarity, I used actual return statements in the expanded code.

Three minor optimizations:

Use putchar with b's value directly instead of printf (3 bytes).
Use ternary operator instead of if statement to print bullet count (1 byte).
Roll bullet count initialization into print ternary (2 bytes).
The last one is a bit smelly since it means b is zero when testing the first index, but since no gun could be at index 0 anyway, I think it's a fair change.


text:
Sinusoidal ASCII-art animated text
I somewhat miss those old demos showing the capabilities of computers when they were called x86 instead of i3, i5 and i7. One of the first I watched in my 386 was the Unreal demo from Future Crew that is now celebrating its 25th anniversary. At minute 0:43 the first part of the demo starts and we see a scrolling text following a sinusoidal path. Let's try to imitate that effect in ASCII art!
The challenge
Given this path:
***                                ***
   ***                          ***
      **                      **
        *                    *
         *                  *
         *                  *
          *                *
           **            **
             ***      ***
                ******

and an input text, draw the text following that path, like this:
Thi                                Golf!
   s i                          de       Yay
      s                       Co            !
        P
         r                  d
         o                  n
          g                a
           ra            s
             mmi      zle
                ng Puz

Note that the spaces count as characters in the path, and that the path repeats itself if the text is longer than the sample.
The animation part
Once you have drawn the text, wait for 100 ms (to create an animation of around 10 fps) and draw the text again but starting from the next position of the path. So, for frame #n, calculate n modulo 40 and start drawing in the following position of the path with the text always aligned to the left of the canvas:
***                                ***
|  ***                          ***  |
|     **                      **     |
|       *                    *       |
|        *                  *        |
|        *                  *        |
|         *                *         |
|          **            **          |
|            ***      ***            |
|               ******               |
Position 0                 Position 39

So for frame 10 we will have:
                           and Co
                        es       de
                      zl            Go
                     z                l
                    u                  f
T                   P                  !
 h
  is             ng                       Ya
     is       mmi                           y!
        Progra

Notes

Input will be a single string (or char array, whatever) with the text to animate, and will always have at least 1 character.
Valid characters to animate are those in the printable ASCII set.
The path to follow will be exactly as given.
Text will always be aligned to the left of the canvas, so the effect will be the text waving like a flag, with no text displacement. And by canvas I mean screen or whatever you will use to show the text. ;-)
Frames must be clear of any characters/pixels from previous frames unless the character/pixel is the same in both frames.
The speed of the animation does not matter as long as it runs smoothly or as fast as your device can (we can set a minimum of 5 fps, but this is not a requirement). Just adjust the speed to make it fluid and do not worry if the waiting times are not exactly the same.
The animation will loop endlessly.

This is code-golf, so may the shortest program or function capable of animating the text win!

Related. Sandbox.

I can count 38 columns rather than 40.

@Arnauld that's because what counts are the positions in the path, not the columns.

Oh I see. Makes sense.

Is this okay as output? It displays the input in the form of a sinusoidal wave and loops endlessly. Of course, since the video is in Graphics Interchange format, it is faster in actuality.

@R.Kap yes, it is a valid output format, as long as the path is as specified in the question. Do not worry if your device cannot achieve 5 fps.

@R.Kap if your device takes its time to draw the text, try to animate a text only 2-characters long, so it will run faster and we will better see the animation and check the path followed.

Gosh. This is so much harder to do than I initially thought, especially in the language I am using.

Can we start the animation at any frame mod 40?

@Arnauld I'm going to say yes, I did not say in the question that the animation should start on frame 0.

@dzaima I'm so sorry, I misunderstood the tag. Removed.

HTML + ES6, 241 244 237 bytes
Breakdown:

HTML: 16 bytes
JS function: 221 bytes

let f =

s=>setInterval(_=>o.innerHTML=[...s].map((c,i)=>([j,y]=[...Array(40)].map((_,k)=>[j=k%20,y,y+=77732>>j&1?k<20||-1:0],y=0)[(i+p)%40],a[y]=a[y]||[...s].fill` `)[x]=(x+=j!=9,c),x=0,a=[],p++)&&a.map(r=>r.join``).join`
`,p=30)

f("This is Programming Puzzles and Code Golf! Yay!")

How?
Building the path
The following code builds the path:
[...Array(40)].map((_, k) =>
  [
    j = k % 20,
    y,
    y += 77732 >> j & 1 ? k < 20 || -1 : 0
  ],
  y = 0
)

This gives an array of arrays [j, y, z] where j is the position modulo 20, y is the y-coordinate at this position and z is not used later (it just happens to be computed here to save some bytes).
Because the path is symmetric, we only need to encode the 20 first positions. We do that by using a binary number where each 1 bit means that y must be updated (+1 for the first half, -1 for the second half).
001
   001
      01
        1
         1
         1
          1
           01
             001
                000

With the first position being mapped to the least significant bit, this gives:
00010010111110100100 as binary = 77732 as decimal

Because this binary number is itself also symmetric, we can read it in the same order for the 2nd half.
Hence the formula:
y += (77732 >> j) & 1 ? (k < 20 ? 1 : -1) : 0

which can also be written as:
y += (77732 >> j) & 1 ? k < 20 || -1 : 0

where k is the position and j is the position modulo 20.
Updating x is much easier: we just have one special case to detect by comparing the position modulo 20 with 9.
Drawing the text
In the following code, the path building code described above has been replaced by a path variable for readability.
s => setInterval(                       // set a periodic timer:
  _ =>                                  //   with an anonymous callback
    o.innerHTML =                       //   which updates the content of 'o'
      [...s].map((c, i) => (            //   for each character c of the string s
          [j, y] = path[(i + p) % 40],  //     retrieve j and y from the path
          a[y] = a[y] || [...s].fill` ` //     initialize a[y] if it's undefined
        )[x] = (x += j! = 9, c),        //     update a[y][x] / update x
        x = 0,                          //     initialize x
        a = [],                         //     initialize a[]
        p++                             //     increment the phase
      ) &&                              //   end of map()
      a.map(r => r.join``).join`\n`,    //   join everything together
  p = 30                                //   initial phase = interval period = 30
)                                       // end of timer definition

This is brilliant, and quite close to the path asked, but the path is not exactly the one I drew. The two columns that contain two * in vertical are not aligned (at the same height), and another small nitpick. But I must say I still don't know how your code creates the wave effect (what does the y+=155464 do?). Congratulations!

@CarlosAlejo I think the path should now be fixed. Could you please double-check? I'll add an explanation of the method used.

Path checked, and thank you very much for the explanation!


text:
Convert Between Percentages and Decimal
I, uh....honestly can't believe we don't have this one yet.
Challenge
Write two functions or programs that:

Convert from decimal to percentage
Convert from percentage to decimal

You may also write a single program that does both of the above.
Format
Percentages must be taken and returned with a percent sign. (In many languages, this means they will be strings.) They may be integers or floating point numbers.
Decimals are just floating point numbers.
You do not need to handle rounding errors involving very large or very small floating point numbers.
In cases where the numbers are integers (such as 56.0) you may return 56, 56., or 56.0. (This is intended to make I/O more flexible.)
Test Cases
    0.0% <-> 0.0
  100.0% <-> 1.0
   56.0% <-> 0.56
  123.0% <-> 1.23
  -11.0% <-> -0.11
-214.91% <-> -2.1491

Scoring
This is code-golf, so the shortest answer in each language wins. If you write two separate programs, add their sizes for your score.

If I'm interpreting the test cases correctly, they mandate that an input of 0.0 return both 0% and 0.0%. Which one is it?

Good point. I've updated to make it more clear that all numbers involved are floating point numbers.

I think we should just convert to percent and not back and forth. That makes the challenge unnecessarily complex.

Never mind that. It's good

Also, is writing a single program allowed. Another user did it, so I just want to know if that is allowed.

@ckjbgames Yes, you may write a single program or function that can handle both types of input

@musicman523 Kewl

Are we allowed to use 2 languages?

@ckjbgames You should use the same language for both parts of the problem; however, you may add another answer if you wish to answer in a different language

I'm downvoting because it's a very boring challenge. Nothing wrong about the challenge itself, other than that.

@isaacg That's fine, and you are of course entitled to that opinion. I made this challenge knowing it wouldn't be difficult, simply because I wanted to see the answers and it's easier for new PPCG members to get involved on easier questions. Think of it as a learning opportunity - go answer in a language you've never used before! Or go answer some harder challenges if you're still not convinced :)

@musicman523 upvote for your consideration on helping new PPCG users like me :)

@isaacg This challenge is quite difficult in a batch file as we don't have decimal multiplication, nor decimal division...

Mathematica, 34+20=54
to Decimal
ToExpression@StringDrop[#,-1]/100&

to Percentage
ToString[100#]<>"%"&

Python 2, 59 bytes
This one does both.
lambda s:'%'in s and`float(s[:-1])/100`or`float(s)*100`+'%'

Try it online!
Single functions, score 27 + 28 = 55
Decimal to percent, 27 bytes
lambda s:`float(s)*100`+'%'

Try it online!
Percent to decimal, 28 bytes
lambda s:`float(s[:-1])/100`

Try it online!

Why do you need the backticks in the second snippet? Isn't returning as float allowed?

Percentages must be taken and returned with a percent sign.

@KarlNapf Yes, they do. But for float(s[:-1])/100 you do not need a percent sign, and hence can be returned as a floating-point number.

Japt, 7 bytes
From percentage:
/L

Test it online!
To percentage:
*L+'%

Test it online!

Java, 45 bytes
-4 bytes thanks to musicman523.
From decimal, to percent:
a->new Float(a.split("%")[0])/100

To percent, from decimal:
a->a*100+"%"

You sure the second function is valid Java?

@LegionMammal978 I was surprised when I tried it out. Yes, it's valid Java.

@Okx would new Float(...) work in place of Float.valueOf(...)?

@musicman523 So it would. Thanks!

Dyalog APL, 20 bytes
To percentages
'%',⍨100∘×

From percentages
.01×∘⍎¯1↓⊢

Try it online!

You can shorten the 0.01 to .01

'%'~⍨⊢ can become ¯1↓⊢

@KritixiLithos thanks!

Perl 6, 10 + 10 = 20 bytes
Decimal to percentage:
*×100~'%'

Percentage to decimal:
*.chop/100

Python 3, 81 77 74 bytes
def a(m):e=m.strip("%");f=float(e);return f/100if e!=m else str(f*100)+"%"

Try it online!
EDIT: Saved 4 bytes by removing some whitespace.
EDIT: Saved another 3 bytes by setting float(e) to a variable.

+1 for an extremely well-made PPCG answer. Also, removing some whitespace will save you some bytes.

Here's an even shorter Python 3.6 version: def a(m):e=m.strip("%");f=float(e);return f"{f*100}%"if e!=m else.01*f. Replace f"{f*100}%" with str(f*100)+"%" to make it <3.6 compatible. (The 3.6 version won't work on tio.run so use something like repl.it instead.)

PHP, 62 bytes 61 bytes
Thanks @ckjbgames

$i=readline();echo strstr($i,'%')?(float)$i/100:($i*100).'%';

Try it online!

Remove the newline. That should help.

@ckjbgames Thanks for the tip!

PHP 7.1 <?=$argn[-1]>'%'?($argn*100)."%":$argn/100;

<?=100*$argn."%"; and <?=$argn/100; should be the shortest way form the commandline with the -F option

Haskell 16+19 = 35 bytes
Percent to decimal:
(/100).read.init

Decimal to percent:
(++"%").show.(*100)

JavaScript (ES6), 20+12=32 bytes
To Decimal
p=>parseFloat(p)/100

To Percentage
d=>d*100+'%'

05AB1E, 8 bytes
From % to decimal
¨т/

Try it online!
And from decimal to %
т*'%«

Try it online!
Explanations
¨т/
¨   # Cut of last character
 т/ # Divide by 100 (I know. Very creative)

 т*'%«
 т*    # Multiply by 100
   '%« # Append '%'

Jelly, 5 + 5 = 10 bytes
% → number
ṖV÷ȷ2

Try it online!
number → %
×ȷ2”%

Try it online!
Full program only.

Excel, 15 + 4 = 19 bytes
Assuming that the values to be converted are stored in field A1
Percentage to decimal
=NUMBERVALUE(A1)

Decimal to percentage
=A1%

Python 3, 26 24 23 bytes + 27 bytes = 50 bytes
First program (% -> decimal)

float(input()[:-1])*.01

Second program (decimal -> %):

str(float(input())*100)+'%'

Rather similar to the other one. Pretty easy, too.

Write two....

@CalculatorFeline yeah

Does this convert back and forth between decimal and percent?

@NonlinearFruit Need to do that

@NonlinearFruit How to best implement

I miss read, the spec asks for 2 programs. So you need a second one for decimal to percent. The current one should also print the result

@NonlinearFruit Done!

Your second program doesn't run: TypeError: unsupported operand type(s) for +: 'float' and 'str'

@LyricLy Lemmeh fix

@LyricLy Done! There you go

If you are writing full programs, you will need to print your output. Maybe you should be testing your programs on a site such as TIO

@musicman523 It was just the second one, which is now fixed.

You can save 1 byte by changing 0.01 to .01. You can also switch to Python 2 and save 7 bytes by removing float(), since input() will automatically read the number as a floating point number.

@musicman523 kewl

@musicman523 Is using 2 languages allowed?

@ckjbgames No need to double comment, I get notified for both.

Python 2, 67 bytes
lambda x:`float(x.strip('%'))*[100,.01]['%'in x]`+['%','']['%'in x]

Try it online!

This is a really clever answer. I like it.

Python 3, 71 bytes
i=input()
print(float(i[:-1])/100if'%'in i else'%.2f%%'%(float(i)*100))

Try it online!

Haskell, 60 42 bytes
Decimal to percentage (21 bytes)
f x = show(x*100)++"%"

Percentage to decimal (21 bytes)
f x = read(init x)/100

Welcome to PPCG! As per community consensus submissions may not assume the input is present in a certain variable. Function submissions are allowed though, so you can fix your answer by prepending f x= or \x->.

ES6, 34 bytes
n=>1/n?n*100+'%':n.slice(0,-1)/100

(Now works with 0.0 and 0%)
Try it online!
This works because 1/n is NaN if a "%" is present and NaN is like false.
(1/n with n = 0 is Infinity (not NaN) and Infinity is not considered false by JS)

But !0 is also false... using 1/n might work though.

I made a mistake in my original comment on why this works, !NaN is true not false.

Sorry, !0 is true too of course. What was I thinking?

@Neil Thank you for your help, the new version is still 34 bytes, but now works with zero.

Retina, 77 bytes
^-?
$&00
\b%?$
00%$&
\.(..)
$1.
(....)\.(.*)%%
.$1$2
^(-?)0+\B|\B0+(%?)$
$1$2

Try it online! Link includes test cases. Requires and returns input with at least one digit before and after the decimal point. Explanation: The first stage inserts two leading zeros after any sign, while the second stage inserts two trailing zeros and a % sign before any % sign. (The \b is needed to stop the pattern matching twice for percentages.) The third stage then multiplies by 100. This results in the correct numerical value for floats converted into percentages, but percentages are now 10,000 times too big and now have a duplicated % sign, so the fourth stage corrects this. The final stage then trims leading and/or trailing zeros as necessary.

perl 5: 24 bytes
From % to decimal: 8 bytes (7 + 1 for p flag)
$_/=100

Usage:
echo '-214.91%' | perl -pe '$_/=100'

Output:
-2.1491

From decimal to %: 16 bytes (15 + 1 for p flag)
$_*=100;$_.="%"

Usage:
echo -2.1491 | perl -pe '$_*=100;$_.="%"'

Output:
-214.91%

,,,, score 19
Percent to decimal, 10 bytes
-1⇆⊣f100⇆÷

Explanation
Take 56.0% for example.
-1⇆⊣f100⇆÷

               implicit input                               ["56.0%"]
-1             push -1                                      ["56.0%", -1]
  ⇆            switch "56.0%" and -1                        [-1, "56.0%"]
   ⊣           pop -1 and "56.0%" and push "56.0"           ["56.0"]
    f          pop "56.0" and push 56.0 (convert to float)  [56.0]
     100       push 100                                     [56.0, 100]
        ⇆      switch 56.0 and 100                          [100, 56.0]
         ÷     pop 100 and 56.0 and push 56.0 / 100         [0.56]
               implicit output                              []

Decimal to percent, 9 bytes
100×s'%⇆+

Explanation
Take 0.56 for example.
100×s'%⇆+

               implicitly take input and convert to float    [0.56]
100            push 100                                      [0.56, 100]
   ×           pop 0.56 and 100 and push 100 * 0.56          [56.0]
    s          pop 56.0 and push "56.0" (convert to string)  ["56.0"]
     '%        push "%"                                      ["56.0", "%"]
       ⇆       switch "56.0" and "%"                         ["%", "56.0"]
        +      pop "%" and "56.0" and push "56.0%"           ["56.0%"]
               implicit output                               []