text:
Output the PPCG Prime
This is the PPCG Prime
624 digits long
777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777111111111111111111111111111111111111111111111111111111111111111111111111111111188888888118888888811188888811188888811188111118818811111881881111881881111881188111118818811111881881111111881111111188888888118888888811881111111881118888188111111118811111111881111111881111881188111111118811111111881111881881111881188111111118811111111188888811188888811111111111111111111111111111111111111111111111111111111111111111111111111111111333333333333333333333333333333333333333

If we split every 39 digits we get
777777777777777777777777777777777777777
777777777777777777777777777777777777777
777777777777777777777777777777777777777
777777777777777777777777777777777777777
111111111111111111111111111111111111111
111111111111111111111111111111111111111
188888888118888888811188888811188888811
188111118818811111881881111881881111881
188111118818811111881881111111881111111
188888888118888888811881111111881118888
188111111118811111111881111111881111881
188111111118811111111881111881881111881
188111111118811111111188888811188888811
111111111111111111111111111111111111111
111111111111111111111111111111111111111
333333333333333333333333333333333333333

Your task is to output the PPCG-Prime
This is code-golf. The shortest code in bytes wins.
If you input the PPCG-Prime in the Mathematica function below, you get this result
ArrayPlot@Partition[IntegerDigits@#,39]&

How on earth did you find this?

@StewieGriffin The average probability for a number n to be prime is proportional to 1/log(n), which is not very small, anyway. Just check a lot of numbers until it's prime.

Comments are not for extended discussion; this conversation has been moved to chat.

@user202729 log(n) is about 1436.6 in this case.

How many primes are <= this number? That would be one way to compress that information, although one that would make the program run incredibly slow.

@Fabian I don't think this method would be efficient... For a Prime this big (624 digits), the number you are asking has 621 digits (and is even more difficult to golf), Unless this is the 10^621th prime!!! If you want to find your number, here is a simple approximation x/logx by Gauss

Oh, right. Would be interesting to find if its prime index was a prime whose index was a prime whose index was a prime and so on. Hm, that gives me an idea for a different challenge...

Oh, was already done: https://codegolf.stackexchange.com/questions/110812/find-recursively-prime-primes

Jelly, 55 54 52 47 46 bytes
“=÷¡v⁺ʋiṂYR¤"bİɲ}Ñ1Ṇ⁴ẠV⁹yȥGẇ’“¿mŻ“p’Dx39jBo88V

There are more convoluted approaches in the revision history, but this simple one beats them all.
Try it online!
How it works
“=÷¡v⁺ʋiṂYR¤"bİɲ}Ñ1Ṇ⁴ẠV⁹yȥGẇ’

This is a numeric literal, encoded in bijective base 250, where the digits are taken from Jelly's code page. The chain's (left) argument and the return value are set to the encoded integer,
n := 0x21871c77d7d7af6fafafeff0c37f72ff7fbfbdbfdfef5edfeff8e3.
“¿mŻ“p’

A similar literal to the above one, but the second “ separates two encoded integers. The return value is replaced with the encoded array, [777711, 113].
Dx39

D converts the return value to decimal ([[7, 7, 7, 7, 1, 1], [1, 1, 3]]), then x39 repeats each individual integer/digit in the result 39 times. This yields a pair of arrays, which contains the digits before and after the 7-character high text, respectively. Let's call this array A.
jB

First, B converts the (left) argument n to binary. This yields the digits that form the 7-character high text, where each 88 has been replaced by 0.
Then, j joins the array A, using the binary array as separator.
o88

This performs logical OR with 88, replacing each 0 with 88.
V

We have the correct digits now, but in an array of 7's, 1's, 88's, and 3's. V implicitly turns this array into a string and then evals it, yielding a single integer.

Bubblegum, 51 bytes
00000000: 331f c4c0 90ba c002 0a90 5986 d818 50d5  3.........Y...P.
00000010: 282c 3406 6e65 5036 1e4b 9195 8109 649d  (,4.neP6.K....d.
00000020: 5858 1896 4279 68b2 f895 61fa 94ca c098  XX..Byh...a.....
00000030: 3800 00                                  8..

Try it online!

SOGL V0.12, 52 51 bytes
≡=vā⁷H↕↕jΥ_Ν↑∆∫▲pΖo	‘θδžΟwd╬2n?q[‘²Κ7n⌡"α¼■╤ģ⅞¹‘¹H∑
ties bubblegum!
note that this answer contains a tab
Try it Here!
Tries to save bytes by reusing the same string for both of the Ps.
Explanation:
...‘...‘²Κ7n⌡"..‘¹H∑  compressed strings replaced with ellipses to shorten the width
...‘                  pushes "1111111188888188888888111118811111881111188111118881118818111811111111188888188888888111118811111881111188118118888818818881811118111" - CG
    ...‘              pushes "1111111888888888888881118118111811811181181118118111811811188881111881" - P
        ²             join with itself - double the P
         Κ            reverse add - prepend the PP to CG
          7n          split to line lengths of 7
            ⌡         for each
             "..‘       push "311ŗ117777" with ŗ replaced with the ToS - current item looping over
                 ¹    wrap the results tn an array
                  H   rotate it counter-clockwise
                   ∑  join to a single string

The numbers there are saved as from the original starting at the bottom left, going up, then 1 right & down, then up, ect.
A 52 byte plain compression version:
#⅓→9E■Ν►1&⅝θ⅞%øøμ←N═]y)u⅝↓$A○░(ZF16Φ⅓Mč▓d⅛Hι‼∑υnη▲Z‘

Try it Here!

I'm not sure if what you've posted is the correct code at all...

how does ...‘ get those numbers?

@Pureferret String compression.

@totallyhuman so how does it 'encode'/compress thoses strings into ...‘?

@dzaima I don't think that actually helps me understand, unfortunately. Entering the first part that encodes the CG into that tool doesn't give ...‘ anywhere in that tool.

@dzaima yeah, that doesn't give you ...‘ as I expected. I'm trying to figure out which symbols/characters are actually representing your two long stings of numbers, which is still not clear.

Ah ok. I thought your explanation was using three dots or an elipsis for a special meaning. Thats clearer now! thanks

CJam, ASCII, 61
Hs78f*~_@"'hfv;HH`>O4RU(_o^.U)9q&-1iadr`4tk"90b2b88fe|1$'339*

Try it online
Append ]s39/N* for nice wrapping.
Explanation:
Hs         generate "17" (H=17)
78f*       repeat each character 78 times, getting an array of 2 strings
~_         dump the 2 strings on the stack, and duplicate the '7's
@          move the '1's to the top of the stack (first 6 lines done so far)
"…"90b     convert that string from base 90 (treating characters as numbers)
2b         convert the resulting number to base 2,
            obtaining a bit map for the "PPCG" part, with 1 for "1" and 0 for "88"
88fe|      replace (boolean OR) all the zeros with 88
1$         copy the string of 78 '1's
'339*      repeat '3' 39 times

C, 519 427 414 396 377 bytes
Thanks to Tas, Felix Palmen and Lynn.
#define p(n,l)for(i=40*l;i;)putchar(--i%40?n+48:10);
f(i){p(7,4)p(1,2)puts("188888888118888888811188888811188888811\n188111118818811111881881111881881111881\n188111118818811111881881111111881111111\n188888888118888888811881111111881118888\n188111111118811111111881111111881111881\n188111111118811111111881111881881111881\n188111111118811111111188888811188888811");p(1,2)p(3,1)}

For your interest, here is a longer, easier-to-read version:
#define p(n,l) for(i=40*l;i;) putchar(--i%40?n+48:10);
f(i) {
    p(7,4)
    p(1,2)
    puts("188888888118888888811188888811188888811\n\
       188111118818811111881881111881881111881\n\
       188111118818811111881881111111881111111\n\
       188888888118888888811881111111881118888\n\
       188111111118811111111881111111881111881\n\
       188111111118811111111881111881881111881\n\
       188111111118811111111188888811188888811");
    p(1,2)
    p(3,1)
}

You can get much lower (~450ish) by simply printing the 1s and 8s as they are, and having a define for the 7, 3 and 1

@Keyu Gan: I am compiling with a current version of GCC (7.2.0-debian11), which allows this for a couple of years. I'm not quite sure if the syntax is maybe in one of the newer C standards.

@Keyu Gan: It is allowed in C99 and C11.

414 bytes

This version is very tricky. At least I understand it; thanks.

Using "new" newlines saves again ~20 bytes

@xanoetux nice. Suggest to add the submission format from tio :)

@xanoetux wow i didn’t know that before :p

The code you posted isn’t 396 bytes long. Adding whitespace for readability is a nice idea, but you should show the actual 396 byte code so that it can be verified by others.

@Lynn I was sure I had done so. But you're right, I forgot it at last edit. Here you go

Anyway, I got down to 377 bytes.

Yes, as I call puts only once, that actually saves a whole #define

Yes, I forgot to replace it... I should read my post before posting it :)

Mathematica, 107 bytes
Uncompress@"1:eJxTTMoP8ixgYmAwH8TAkLrAAgqQWYbYGFDVGCxkBh5lCDNwWIqqDCyGrAGDhWEpFmXY3IaiDItPqQqMiQMA+yaAoA=="

Try it online!

Correct me if I'm wrong, but is that a REPL-only solution? That doesn't seem to be a function (which I'm guessing you could fix with a single & on the end).

this is not supposed to be a function. this code just outputs the PPCG prime, just like the OP asked

Java (OpenJDK 8), 165 bytes
n->{for(int i=0;++i<566;)System.out.print(i<157?7:i>526?3:i<236|i>446||new java.math.BigInteger("vnku5g6l0zenpa1kydel5rxw162k4fk4xapa154o",36).testBit(446-i)?1:88);}

Try it online!
Credits

-10 bytes thanks to aditsu!

165: n->{for(int i=0;++i<566;)System.out.print(i<157?7:i>526?3:i<236|i>446||new java.math.BigInteger("vnku5g6l0zenpa1kydel5rxw162k4fk4xapa154o",36).testBit(446-i)?1:88);}

Nice catch, the double 88, thanks!

Javascript (ES6), 187 181 bytes
-6 bytes thanks to @JustinMariner
r=s=>s[0].repeat(39),a=r`7`,b=r`1`,i="8888881",c=188+i,d=11+i,j="188111",e=j+1188,f=j+188,g=j+111,h=g+1,k=r`3`
z=>"aaaabbccdd1eeff1eeghccgj8888hhgf1hhff1hhdd1bbk".replace(/./g,eval)

Super simple approach; it could probably be golfed some more.
Explanation
r=s=>s[0].repeat(39),                               // helper function to repeat character
a=r`7`,b=r`1`,i="8888881",c=188+i,d=11+i,j="188111",// Set the variables (a-k) to different
e=j+1188,f=j+188,g=j+111,h=g+1,k=r`3`               // parts of the prime

_=>"aaaabbccdd1eeff1eeghccgj8888hhgf1hhff1hhdd1bbk" // Replace all letters in the string
    .replace(/./g,eval)                             // with the value of the variable

Example code snippet (with some helper code to add line breaks in the output)

r=s=>s[0].repeat(39),a=r`7`,b=r`1`,i="8888881",c=188+i,d=11+i,j="188111",e=j+1188,f=j+188,g=j+111,h=g+1,k=r`3`
z=_=>"aaaabbccdd1eeff1eeghccgj8888hhgf1hhff1hhdd1bbk".replace(/./g,eval)
o.innerText=z().replace(/.{39}/g,"$&\n")
<pre id=o>

You can save some bytes if you define a helper function r as r=s=>s[0].repeat(39) and then replace a, b, and k with r`7`  etc. Try it online!.

C (gcc), 269 267 bytes
function, uses simple RLE.
x[]={39,79,80,156};k;f(i){for(char*c="d7b1882188316831683128512811285128112841281128412821285128112851281128712881882188212871283148112881288128712841282128812881284128112841282128812891683168c1a3";i=*c++;++c)for(i=i<97?i-48:x[i-97];i--;++k%39||puts(""))putchar(*c);}

Try it online!

Suggest L"'OP\x9c" instead of x

Ruby, 109 bytes
The script calls Zlib.inflate to decompress the number. It needs at least Ruby 1.9.3. It contains unprintable bytes, so I can't paste it here.
I paste the output of vis prime-inflate.rb:
require'zlib'
puts Zlib.inflate DATA.read
__END__
x\M-Z37\^_\M-<\M-@\M^P\M-:\M-@\^B
\M^PY\M^F\M-X\^XP\M-U\^X,d\^F\^^e\^H3pX\M^J\M-*\^L,\M^F\M-,\^A\M^C\M^Ea)\^Ve\M-X\M-\\M^F\M-"\^L\M^KO\M-)
\M^L\M^I\^C\^@\^P\M-p~\M-!

If you have unvis(1), run unvis prime-inflate.vis > prime-inflate.rb to restore the 109-byte script. Or you can decode the Base64, below, with ruby -e 'print *STDIN.read.unpack(?m)' < prime-inflate.b64 > prime-inflate.rb.
cmVxdWlyZSd6bGliJwpwdXRzIFpsaWIuaW5mbGF0ZSBEQVRBLnJlYWQKX19F
TkRfXwp42jM3H7zAkLrAAgqQWYbYGFDVGCxkBh5lCDNwWIqqDCyGrAGDhWEp
FmXY3IaiDItPqQqMiQMAEPB+oQ==

I call Zlib.inflate so I don't need to design and golf my own decompression algorithm. I use DATA with __END__ because the compressed string isn't valid UTF-8. Ruby code must be valid ASCII (in Ruby 1.9.x) or UTF-8 (from Ruby 2.0) or have a magic comment #coding:binary to change the encoding, but Ruby doesn't check the encoding after __END__.

6502 machine code (C64), 142 122 bytes
00 C0 A9 27 85 FB A2 00 86 FC A2 04 CA 10 01 60 BC 70 C0 BD 74 C0 20 D2 FF C6
FB D0 0B 48 A9 27 85 FB A9 0D 20 D2 FF 68 88 D0 EB E0 02 D0 DD 48 A5 FC 4A A8
B9 4A C0 90 04 4A 4A 4A 4A 29 0F F0 08 E6 FC A8 68 49 09 D0 CD 68 D0 C0 28 38
36 36 52 12 52 12 42 12 42 22 52 12 52 12 72 82 28 28 72 32 14 82 82 72 42 22
82 82 42 12 42 22 82 92 36 06 27 50 4F 9C 33 31 31 37

Online demo
Usage: sys49152

-20 bytes with better implementation of same method and data tables for large blocks as well.

Explanation
This also uses the lengths of the 1 and 8 sequences in the middle part; as they're all shorter than 16, two of them are encoded per byte.
Commented disassembly listing:
         00 C0        .WORD $C000       ; load address
.C:c000  A9 27        LDA #$27          ; counter for newlines (39)
.C:c002  85 FB        STA $FB
.C:c004  A2 00        LDX #$00          ; index for run-length data
.C:c006  86 FC        STX $FC
.C:c008  A2 04        LDX #$04          ; index for "blocks" (counting down)
.C:c00a   .blockloop:
.C:c00a  CA           DEX
.C:c00b  10 01        BPL .continue     ; block index underflow -> done
.C:c00d  60           RTS
.C:c00e   .continue:
.C:c00e  BC 70 C0     LDY .lseqlens,X   ; load length of next block to Y
.C:c011  BD 74 C0     LDA .chars,X      ; load character of next block to A
.C:c014   .outloop:
.C:c014  20 D2 FF     JSR $FFD2         ; output character
.C:c017  C6 FB        DEC $FB           ; decrement newline counter
.C:c019  D0 0B        BNE .skipnl
.C:c01b  48           PHA               ; newline needed -> save accu
.C:c01c  A9 27        LDA #$27          ; restore newline counter
.C:c01e  85 FB        STA $FB
.C:c020  A9 0D        LDA #$0D          ; load newline character
.C:c022  20 D2 FF     JSR $FFD2         ; output character
.C:c025  68           PLA               ; restore accu
.C:c026   .skipnl:
.C:c026  88           DEY               ; decrement repeat counter
.C:c027  D0 EB        BNE .outloop      ; repeat until 0
.C:c029  E0 02        CPX #$02          ; check for block index of text part
.C:c02b  D0 DD        BNE .blockloop    ; not in text part -> repeat
.C:c02d   .textpart:
.C:c02d  48           PHA               ; save accu
.C:c02e  A5 FC        LDA $FC           ; load index for run-length data
.C:c030  4A           LSR A             ; and shift right
.C:c031  A8           TAY               ; -> to Y register
.C:c032  B9 4A C0     LDA .seqlens,Y    ; load run-length data
.C:c035  90 04        BCC .lownibble    ; carry clear from shift -> low nibble
.C:c037  4A           LSR A             ; shift high nibble into low nibble
.C:c038  4A           LSR A
.C:c039  4A           LSR A
.C:c03a  4A           LSR A
.C:c03b   .lownibble:
.C:c03b  29 0F        AND #$0F          ; mask low nibble
.C:c03d  F0 08        BEQ .textdone     ; run-length zero? then text block done
.C:c03f  E6 FC        INC $FC           ; increment index for run-length data
.C:c041  A8           TAY               ; run-length to y-register
.C:c042  68           PLA               ; restore accu
.C:c043  49 09        EOR #$09          ; toggle between '8' and '1'
.C:c045  D0 CD        BNE .outloop      ; and back to output loop
.C:c047   .textdone:
.C:c047  68           PLA               ; restore accu
.C:c048  D0 C0        BNE .blockloop    ; back to loop for next block
.C:c04a   .seqlens:
.C:c04a  28 38 36 36  .BYTE $28,$38,$36,$36
.C:c04e  52 12 52 12  .BYTE $52,$12,$52,$12
.C:c052  42 12 42 22  .BYTE $42,$12,$42,$22
.C:c056  52 12 52 12  .BYTE $52,$12,$52,$12
.C:c05a  72 82 28 28  .BYTE $52,$82,$28,$28
.C:c05e  72 32 14 82  .BYTE $72,$32,$14,$82
.C:c062  82 72 42 22  .BYTE $82,$72,$42,$22
.C:c066  82 82 42 12  .BYTE $82,$82,$42,$12
.C:c06a  42 22 82 92  .BYTE $42,$22,$82,$92
.C:c06e  36 06        .BYTE $36,$06
.C:c070   .lseqlens:
.C:c070  27 50 4F 9C  .BYTE $27,$50,$4F,$9C
.C:c074   .chars:
.C:c074  33 31 31 37  .BYTE "3117"

Python 2, 112 bytes
print'7'*156+'1'*78+bin(int('JAOKI5B0O6K9IWDU8P76KDLR0VZMNWQ2WB9D8BOS8',36))[2:].replace('0','88')+'1'*80+'3'*39

Try it online!

C (gcc), 224 bytes
f(i,j,c){for(i=0;c="wwdfFdfFDfFDfFDFDDFFDDFFDddDDFdDDddDDddDDDdDDDDffDffDFDDDFDfdDDDDFDDDdDDDdDDFdDDDDFDDDdDDFFDdDFDDDdDDDDdfDdfD"[i/2]>>i++%2*4&15;c-6?putchar(c-4?c+48:49):printf("88"))for(j=0;j++<c%2*38;)putchar(c+48);}

Try it online!
Contains some unprintables, the string literal is "ww\x11dfFdfFDfFDfFDFDDFFDDFFDddDDFdDDddDDddDDDdDDDDffDffDFDDDFDfdDDDDFDDDdDDDdDDFdDDDDFDDDdDDFFDdDFDDDdDDDDdfDdfD\x11\x03".

Retina, 129 bytes

h155b78i7b1i7b2i5b2i5b2!4!!4!""1!4!!4!!6#i7b1i7b1!6!2i3b##!6"1##""1#!8i5b2i5b79d38
#
!7
"
!3!
!
i1b
\d+
$*
+`(\D)1
$1$1
1

T`l`d

Try it online!

Batch, 364 335 333 bytes
@set a=888888&set b=1111111111111&set e=1881111&set d=1%e%&set f=333333333&for /L %%x in (1,1,156) do @cd|set/p=7
@echo %b%%b%%b%%b%%b%%b%1%a%8811%a%88111%a%111%a%1%d%188%e%188%e%88%e%88%d%188%e%188%e%1%d%1111%a%8811%a%88%d%111881118888%e%11%d%11%d%1%d%88%d%11%d%11%d%88%e%88%d%11%d%11111%a%111%a%%b%%b%%b%%b%%b%%b%11%f%%f%%f%%f%333

Save two bytes by changing echo| to cd|

Thanks, I knew there was something shorter, but couldn't remember

Also, (1,1,156) do can be shortened to (1,1,156)do

x86-16 machine code, IBM PC DOS, 117 108 107 bytes
Binary:
00000000: be14 01b1 53ac d404 bb67 01d7 cd29 fecc  ....S....g...)..
00000010: 75fa e2f1 c3ff b7fd 4122 0922 0d1a 0d1a  u.......A"."....
00000020: 0d0a 150a 050a 150a 050a 110a 050a 110a  ................
00000030: 090a 150a 050a 150a 050a 1d0a 2122 0922  ............!"."
00000040: 090a 1d0a 0d12 050a 210a 210a 1d0a 110a  ........!.!.....
00000050: 090a 210a 210a 110a 050a 110a 090a 210a  ..!.!.........!.
00000060: 251a 0d1a fd45 9c33 3138 37              %....E.3187

Listing:
BE 011E         MOV  SI, OFFSET DAT     ; RLE table
BB 0171         MOV  BX, OFFSET CHR     ; character table
B1 53           MOV  CL, 83             ; data length
            BYTE_LOOP:
AC              LODSB                   ; AL = byte
D4 04           AAM  4                  ; Unpack AL = char index, AH = run length
D7              XLAT                    ; AL = ASCII char
            RLE_LOOP:
CD 29           INT  29H                ; write char to console
FE CC           DEC  AH                 ; decrement length counter
75 FA           JNZ  RLE_LOOP           ; loop until end of run
E2 EC           LOOP BYTE_LOOP          ; loop until end of bytes
            DAT:
C3              RET                     ; return to DOS (and first byte of DAT)
                DB  0FFH,0B7H,0FDH,41H,22H,09H,22H,0DH,1AH,0DH
                DB  1AH,0DH,0AH,15H,0AH,05H,0AH,15H,0AH,05H,0AH,11H
                DB  0AH,05H,0AH,11H,0AH,09H,0AH,15H,0AH,05H,0AH,15H
                DB  0AH,05H,0AH,1DH,0AH,21H,22H,09H,22H,09H,0AH,1DH
                DB  0AH,0DH,12H,05H,0AH,21H,0AH,21H,0AH,1DH,0AH,11H
                DB  0AH,09H,0AH,21H,0AH,21H,0AH,11H,0AH,05H,0AH,11H
                DB  0AH,09H,0AH,21H,0AH,25H,1AH,0DH,1AH,0FDH,45H,9CH
            CHR:
                DB  '3','8','1','7'

Uses a form of RLE to encode the lengths for each run of numbers.  Since there's only four possible numbers, these are encoded using 2 bits of each byte and the remaining 6 bits for the length of the run.  This compresses the 624 byte input down to 83. For example:
Run       Len    Num   Hex
888888 -> 000110 10  = 0x1A
777    -> 000011 00  = 0x0C
1111   -> 000100 01  = 0x11

A standalone PC DOS executable COM program.  Output to console (in delightful MDA amber today):

Or formatted with line breaks:

-8 bytes thanks to @gastropner for the excellent idea to use AAM to unpack the byte instead of bit shifting!
-1 byte thanks to @gastropner adjusting data to start with a 0xC3 (RET opcode)!

You can shave off 8 bytes by replacing the bit fiddling and the XCHG AL, AH with a single AAM 04H and swapping the 8 and the 1 in CHR.

@gastropner oh, that's gooood! I had never thought to use AAM to unpack a byte. Thanks!

There is one more byte to be had, slightly more hard-earned: DB  7BH,0FFH,0FFH -> DB  0DBh,0DBh (and 9Fh to 9CH at the end), change CHR to DB  '3','1','8','7', and move DAT before RET to have that last instruction double as data.

@gastropner very clever - thanks! Updated!

R, 178 165 bytes
-10 bytes thanks to Dominic van Essen
`?`=c
w=8?2?8?2
x=5?2?1?2
y=2?4?2?2?2
z=4?2?1?y
cat(rep(7?0:76%%2*7+1?3,156?79?8?2?8?3?6?3?6?3?2?x?x?z?x?x?7?2?8?w?2?7?2?3?4?1?2?w?7?y?w?z?8?2?9?6?3?6?80?39),sep="")

Try it online!
A run-length-decoding solution with a few optimizations thanks to this tip.

Nice!  Welcome to R!  rep is shorter than rep.int for 174 bytes.

And, if you can bear it, redefining the (otherwise unused) binary operator / as c can also save some bytes, at the expense of quite severe obfuscation...

Oh, I can bear it. :D In fact, using ? is even better because of its lower precedence. I was experimenting with redefining an operator to condense all the a,b,a sequences (couldn't find a way that saved bytes--function is expensive), but I didn't notice that redefining c would be helpful too.

JavaScript (ES6), 183 bytes (possibly 182?)
x=>"7"[r="repeat"](156)+(o="1"[r](78))+"...".replace(/./g,x=>x.charCodeAt().toString(2).padStart(8,0).replace(/0/g,8))+1+o+"3"[r](39)

Where ... is a string of 34 characters. Many of these are ASCII control characters or weird possibly invalid ones like 0x80, but if I save it to a file on my laptop it will produce the correct output (with a console.log of course). Oddly it seems to work with a raw null byte too, but as I'm not sure if I'm right about that I've just used a \0. The string looks something like:
"\x80`\x1C\x0E\x07>O\x93Éæ|\x9F'óü\x03\x00Ïç\tþ\x7F\x9FÏ3üÿ<\x9Egùÿ\x03\x81"

For now this is a 1-2 bytes behind the current answer (was ahead until I remembered to add x=> >:|), but I worked pretty hard on it and I'm sure it's possible to find a couple of bytes to golf somewhere.

PowerShell, 164 bytes
$a='136361616151315131531532513151315215436365213213315454521532545453153254541616';6..2|%{$a=$a-replace$_,(11,88,22,34,3332)[$_-2]};'7'*156+'1'*78+$a+'1'*78+'3'*39

Try it online!
String multiplication, concatenation, and replacements. PowerShell doesn't have base 36 or similar, so large-number compression options are limited. There might be a better way to "compress" the middle part -- I'm still checking on that.

Wolfram Language (Mathematica), 89 (17+71+1) bytes
First you export the number to a GZIP file. This file, named "o" with no extension will be exactly 71 bytes, which counts towards the total.  By default, it will go to your $TemporaryDirectory.  Omitting digits for readability.
Export["o",777777...,"GZIP"]

Then
"o"~Import~"GZIP"

will reconstruct the number.  The file name is one byte so that's where the +1 comes from.
Try it online!

C (gcc), 188 187 185 181 176 156 bytes
-1 thanks to JonathanFrech.
-2 -4 thanks to ceilingcat.
x;r(d,n){for(;n--;)printf("%d",d);}f(i){r(7,156);r(1,79);for(i=38;i--;r(1,x%10))x="PS10*,),00*,/00=+/ff0/)-)-*,),)-)-SSgf"[i]-20,r(8,x/10);r(1,80);r(3,39);}

Try it online!

Welcome to PPCG, nice first answer!

I think you can shift your string to get to a string which does not need escaping a backslash, resulting in 187 bytes.

@JonathanFrech Ah, nice one!

@ceilingcat Good catch!

Jelly, 86 bytes
Lẋ@1,8żḣLẋ/€F
7ẋ156;1ẋ78¤©;“½Ẹ^o“2FẒ⁶ġbȥ“¡E⁷£cṿ“t¡ɗḋ“£F¢Xȥ“¡McṾbȥ“¬3Ṭo’DÇ€F¤;®;3rẋ39¤Ḍ

Try it online!
-12 bytes thanks to user202729

88 bytes: TIO (“ can separates a list of strings inside a string literal)

What time is it in your country? Why are you awake right now?

@user202729 Oh right, thanks. And I'm in UTC-4 I did a stupid and had to stay up rly late so I felt like doing a challenge before going to sleep since this got reopened. I can elaborate in chat if you'd like :P

Python 2, 309 158 155 136 135 bytes
x='1'*78
s='7'*156+x
a=1
for c in str(int('109PDKEZ3U32K97KJQVELW8GKXCD42EGEYK715B6HPMPL0H8RU',36)):s+=`a`*int(c);a^=9
print s+x+'3'*39

Try it online!
Python 2, 137 bytes
s='7'*156
a=1
for c in'90'*8+str(int('PL6PU5TXIC24LCKIQY50C2LPAIC9TVZEVQGTMM63IHGBBUV1XSA6',36))+'09'*8:s+=`a`*int(c);a^=9
print s+'3'*39

Try it online!

Jelly, 85 bytes
”7ẋ“ɓ’80“¡Ȯ⁶LÑɓĠ⁶-€Øġ°$¤ṛọḳƓƒṭ⁽@^ḥ⁷Ofạ<e½Ṇż;,RṘ¶ṀḊ+`⁸ⱮḃĿþṛ9.wƑ¡kḟUẎgLLµ’ḃĖŒṙị⁾1839”3ẋ

Try it online!
Based on Dennis's approach to the Trinity Hall challenge, minus the symmetry, plus the leading 7s and trailing 3s.

Dennis approached this challenge differently because it is a different one. I think you've been outgolfed!

@JoseZaman He made Jelly BTW.

Befunge-93, 500 bytes
v F         >20g1-20p
>"3"20g10g`#^_>52*"F"20p30g10g`#v_"^!1"21p30p84*2+1p
^                       p03-1g03<
^>"81118888888811888888881>!"30p84*2+1p52*
^^"8888811188888811"*25"188111118"<>">#7"21p30p57*5p
>*"188111188188111188188111118818"^ $>:#,_@
^25"18811111881881111188188111111"<
>"8888811888888881"25*"1111111881"^
^"88811881111111881118888"*25"188"<
>"1188111111188111111118811111111"^
^"11881"*52"188111111118811111111"<
>"11111881"52*"188111188188111188"^
^"1118811111111188888811188888811"<

Try it online!

Knight, 113 bytes
;=s*"1"311;=p;=l',kr`\J&J&A&A/J&J&\kke\:8ee\A/eeA&A/er`'76;Wl=sSs=p+p/=t-Al;=lSlF1""9 9F*"8"%t 9O++*"7"156s*"3"39

Try it online!
This one was fun to golf. Not sure if it is optimal, but cool nonetheless. Came up with it myself, I see others had similar ideas.
One challenge in Knight is that only printable ASCII, tab, newline, and CR is allowed. All other characters are UB (although generally supported).
So basically, this uses a lookup table containing indices of 8s and the length.
It is specifically encoded as \$9 + \text{len} + 9 \times \Delta\text{pos}\$.
Specifically, it was generated by this C program (string literal snipped)
#include <stdio.h>
#include <string.h>
int main()
{
    // the range containing all the 8s
    char str[] = "8888888811888888...*snip*";
    char acc[40] = {0};
    // Start at -3 to make our first index in ASCII range. We start at 79, so this is free.
    int pos = -3, i = 0;
    // loop through all the 8s using a strtok loop
    for (const char *s = strtok(str, "1"); s != NULL; s = strtok(NULL,"1"))
    {
        // 9 + len + 9 * offset from last index
        acc[i] += strlen(s) + 9;
        acc[i++] += (s - str - pos) * 9;
        // update position
        pos = s - str;
    }
    // print
    puts(acc);
}

So, with that out of the way, here is the program ungolfed:
# Create the base string with all 1's
# This is string repetition, not arithmetic.
; = str * "1" 311
# Position to start inserting.
# The first 8 is at index 79, but we start early to make
# the first character in the LUT in ASCII range.
; = pos 76
# magic lookup table
; = lut ',kr`\J&J&A&A/J&J&\kke\:8ee\A/eeA&A/er`'
# For all chars in lut
; WHILE lut {
    # Get codepoint of the front of lut and subtract 9
    ; = chr - ASCII(lut) 9
    # Pop first char from lut
    ; = lut SUBSTITUTE(lut 0 1 "")
    # Extract delta and length
    ; = delta / chr 9
    ; = length % chr 9
    # Advance position
    ; = pos + pos delta
    # Inject <length> 8's into str
    : = str SUBSTITUTE(str pos 0 (* "8" length))
}
# Add leading 7's and trailing 3's
; = str + (* "7" 156) str
; = str + str (* "3" 39)
# print
: OUTPUT(str)

Scratch, 396 bytes
Try it online!
There's probably room for optimization.
define(n)(t
repeat(t
set[P v]to(join(P)(n
when gf clicked
set[P v]to(
[7][156
[1][78
[1888888881][2
[1][2
[888888111][2
repeat(2
[8][2
[1][5
[881][1
end
repeat (2
[8][2
[1][4
[881][1
end
[1][1
repeat(2
[8][2
[1][5
[881][1
end
[881111111][2
[1888888881][2
[188][1
[1][7
[8811188881][1
[8][2
[1111111188][2
[1][7
[8811118811][1
[8811111111][2
[881111881][2
[1881111111][2
[118888881][2
[1][79
[3][39

Vyxal s, 66 bytes
7113Sf»«u2F»S4/⌊*2 18f38ẋf».⟩o2d≥s¾T¢(₀P⟇iŀ₍#(⇩t⁽ ≠ṗ²½u&⁼∑H»fZødṅṀ

Try it online!

Python 2, 244 128 120 bytes
-8 bytes thanks to @JonathanFrech
s='1'*78
print'7'*156+s+bin(int("8zlghh9gqo74zwzntkcjmoou35vvlbg1cmasrm6ny1iafcvw568sj",36))[2:].replace(*'08')+s+'3'*39

Try it online!

120 bytes.

///, 180 bytes
/~/\/\///P/IH~O/1G~N/1J~M/AA~L/77~J/IB~I/88~H/11~A/LLLLLL~B/HHH1~C/333333333~D/BB~E/III~F/H1I~G/F1/MMMMMMADDDDDBHEPEP1EH1EGOPGIOIO1PGPGJJ1EPEPJIFINNNIONN1IOIONNHEH1EDDDDDBH1CCCC333

Try it online!

FEU, 178 bytes
a/lllmtwrzxyzrrszwqqwqqwzqwzxzwqqwqqwszvyzxyzxzwszszzqvzvzwszwzxzvzvzwzqwzxzvzv1yrtvooop
m/l/mmmm/m/nnn/n/7777/o/pppp/p/333/q/1z/r/sy/s/x1/t/uuu/u/vvv/v/ww/w/xx/x/11/y/zzz/z/88/g

Try it online!
Compression. My compression testing wasn't very rigorous, so this might be able to be optimized.

brainfuck, 531 503 bytes
-[>+>+<<-----]>++++>-->---[>+<+++++++]>++>>++++++++++<<<++++[->[>+<-]>[<<<<.>>>+>-]>.<<<]++[->[>+<-]>[<<<.>>+>-]>.<<<]<<+>>++[-<.<........>.>]++[-<..<......>.>]<.>>>>.<<<++[-<.<..>.....<..>>]++[-<.<..>....<..>>]<.>>>>.<<<++[-<.<..>.....<..>>]++[-<.<..>......>]<.>>>>.<<<++[-<.<........>.>]<.<..>.......<..>...<....>>>>>.<<<+++[-<.<..>.......>]<<..>....<..>.>>>>.<<<++[-<.<..>.......>]++[-<.<..>....<..>>]<.>>>>.<<<++[-<.<..>.......>]++[-<..<......>.>]<.>>>>.<<<++[->[>+<-]>[<<<.>>+>-]>.<<<]<++>>[-<<.>>]

Try it online!

05AB1E, 148 bytes
•d•Å3•Θ•Å1ì•2œP²IM›BŽт›ÖΛZY
‰ øÕŒQÉΓΩr‡'?₁0rºн∊÷ζì‰ÉöΘ…çнEîx5›иñÄÂ½ü’üΔιàòEγ®é∍NaV†Sƒ¯%à˜PÝ™₆·à≠ø€ćËÙzLtp:Ö†p\nJ$gāböò_¿®₂@h”•rª•Δ•Å1ìƵtÅ7ì»¶õ.:ðõ.:

Try it online!
Explanation
•d•Å3•Θ•Å1ì•...•rª•Δ•Å1ìƵtÅ7ì»¶õ.:ðõ.:
•d•Å3                                  push 39 "3"s
     •Θ•Å1                             push 80 "1"s
          ì                            merge lists
           •...•                       compressed number containing the "1"s and "8"s (probably could be shortened)
                r                      reverse stack
                 ª                     append
                  •Δ•Å1                push 79 "1"s
                       ì               merge everything
                        »              convert list to newline separated string
                          ¶õ.:         replace newlines with nothing
                              ðõ.:     replace spaces with nothing
                                       (implicit print)

Definitely can be golfed...

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


text:
Visualize Inclusion-Exclusion
Inclusion-Exclusion lets you calculate the sizes of some unions and intersections between sets knowing some of the other values. I won't explain it exactly, but your challenge is to visualize inclusion-exclusion on a Venn Diagram.
Because I'm nice, you'll be using rectangles, not circles.
You will be given a list of rectangles denoted by top-left and bottom-right corner coordinates in any reasonable format (list of 4-tuples, list of pairs of pairs, list of pairs, etc). You can assume that all coordinates are non-negative and within your language's (reasonable) number range (please specify what it is if it's less than 128). You can choose to be left-inclusive or left-exclusive and right-inclusive or right-exclusive. Regardless of your chosen format, you can assume all rectangles are at least 1x1.
Then, you are to draw out each rectangle on the screen (ASCII canvas) using a single non-whitespace character k, which is yours to choose.
However, whenever two rectangles overlap, the overlapping area shall be drawn with another non-whitespace character l != k, also yours to choose.
Whenever three rectangles overlap, the overlapping area should be drawn with k, and for an odd number of rectangles covering, k, and an even number, l.
The background should be single whitespaces (0x20).
Test Cases (k = "#", l = ".")
0 0 9 9
1 1 10 10
2 2 11 11

#########
#........#
#.#######.#
#.#######.#
#.#######.#
#.#######.#
#.#######.#
#.#######.#
#.#######.#
 #........#
  #########

1 1 3 3
2 2 4 4

 ##
 #.#
  ##

1 1 9 9
2 2 8 8
3 3 7 7

 ########
 #......#
 #.####.#
 #.####.#
 #.####.#
 #.####.#
 #......#
 ########

Notes

Leading spaces and newlines (which occur if the minimum coordinate isn't 0, 0) must be present
Any trailing spaces and newlines are allowed to a reasonable extent (i.e. don't trail like 100000000 newlines, that's just annoying)
x- and y- axes can face either way but you must be consistent and specify which (default is x- right and y- down)
coordinates can be 0-, 1-, or 2- indexed.

Reference Proton Implementation
This is code-golf, so the objective is to have the shortest code. Happy golfing!

x-axis extends rightwards and y-axis extends downward from the top-left corner?

@user202729 In test cases, yes (actually ambiguous) but you may use either as long as you're consistent

@dzaima Yup. [...]

So, x2 and y2 are the respective first coordinates not part of the rectangle?

@FelixPalmen ? I don't get what you mean

@JoKing yes, i will make the input format more flexible. realized that this is an old challenge and i wasn't too familiar with challenge writing yet

@JoKing Will clarify, they are half-inclusive (lost that meaning when I reworded my input); that is, [x1, x2).

@JoKing Actually I will allow any of the four combinations.

6502 machine code routine (C64), 57 bytes
20 44 E5 A0 03 84 FB 20 9B B7 A4 FB 96 22 C6 FB 10 F5 85 FC A6 24 20 F0 E9 A4
25 B1 D1 09 01 49 02 91 D1 C8 C4 23 D0 F3 E8 E4 22 D0 E9 A9 2C C5 FC F0 D0 A5
C6 F0 FC C6 C6 4C 44 E5

This is position-independent code, put it somewhere in RAM and use the correct start address calling it with sys.
Online demo (start address $C000 / 49152).
Usage: sys<startaddress>,<x1>,<y1>,<x2>,<y2>[,<x1>,<y1>,<x2>,<y2>[,...]]
Example: sys49152,0,0,9,9,1,1,10,10,2,2,11,11
On reasonable number ranges: The natural range on this 8-bit machine is [0-255], and the program will accept this as parameters. But the C64 screen only has 40 columns and 25 rows, therefore limiting the reasonable range to [0-40] for x values and [0-25] for y values. Using other values will have unpredictable behavior.

commented disassembly listing:
20 44 E5    JSR $E544           ; clear screen
 .mainloop:
A0 03       LDY #$03            ; index for reading coordinates
84 FB       STY $FB
 .inputrect:
20 9B B7    JSR $B79B           ; read 8bit value from parameter
A4 FB       LDY $FB
96 22       STX $22,Y           ; and store to $22-$25
C6 FB       DEC $FB
10 F5       BPL .inputrect      ; parameter reading loop
85 FC       STA $FC             ; store last character
A6 24       LDX $24             ; load y1
 .rowloop:
20 F0 E9    JSR $E9F0           ; get pointer to screen row in $d1/$d2
A4 25       LDY $25             ; load x1
 .colloop:
B1 D1       LDA ($D1),Y         ; load character at screen position
09 01       ORA #$01            ; set bit 0 ( -> '#')
49 02       EOR #$02            ; toggle bit 1 (toggle between '#' and '!' )
91 D1       STA ($D1),Y         ; store character at screen position
C8          INY                 ; next x
C4 23       CPY $23             ; equals x2?
D0 F3       BNE .colloop        ; no -> repeat
E8          INX                 ; next y
E4 22       CPX $22             ; equals y2?
D0 E9       BNE .rowloop        ; no -> repeat
A9 2C       LDA #$2C            ; load ','
C5 FC       CMP $FC             ; compare with last character from parsing
F0 D0       BEQ .mainloop       ; if ',', repeat reading coordinates
 .waitkey:
A5 C6       LDA $C6             ; load input buffer size
F0 FC       BEQ .waitkey        ; and repeat until non-empty
C6 C6       DEC $C6             ; set back to empty
4C 44 E5    JMP $E544           ; clear screen

Python 2, 218 192 189 185 158 154 147 bytes
def f(l):_,_,a,b=map(range,map(max,zip(*l)));print'\n'.join(''.join((' '+'#.'*len(l))[sum((x<=i<X)*(y<=j<Y)for x,y,X,Y in l)]for i in a)for j in b)

Try it online!

Charcoal, 40 bytes
ＷＳ«≔Ｉ⪪ι ιＦ…§ι⁰§ι²«Ｊκ§ι¹ＵＭＫＤ⁻§ι³§ι¹↓§10Σλ

Try it online! Link is to verbose version of code. Will be 6 bytes shorter once @ASCII-only fixes a bug in Charcoal. Takes input as a newline-terminated list of space-separated list of co-ordinates. Explanation:
ＷＳ«

Loop over each line of input until a blank line is reached.
≔Ｉ⪪ι ι

Split the line into a list of co-ordinates.
Ｆ…§ι⁰§ι²«

Loop over all the X co-ordinates.
Ｊκ§ι¹

Jump to the top of the column.
ＵＭ

Map over each of...
ＫＤ⁻§ι³§ι¹↓

... all the cells in the column...
§10Σλ

... the new value is 0 if they contain 1, otherwise 1. Edit: Soon after writing this, Charcoal changed the behaviour of ¬ so that Ｉ¬Σλ works here to save 1 byte.

:| did i mess something up https://tio.run/##XY7LasMwEEXX1ldcvBqBCn7k2a5CskkhEOr@gHBUR0SWjC0ngZJvV@OUQtzlzD33zJRH2ZZOmhAuR20UaGub3he@1bYizvHNolXX6crSWnaeisZoT1ogRsy5gOZvLHrv6@bTUSKw8lt7UNcByPkQ7e8eTwN8H75cC/qQtlL0BCZ81Mv479U/62mUpg9rtJPN2tW1tAfaK3Xa6FaVXjtLO237jkZv/O8LvG7cxT7t4zSJBYq@JsMf/hu7hZAgwRJLliLFAguWIcMcc5YjxwwzNsEEU0xZeDmbHw

@ASCII-only Bug in my workaround - I can print an \n instead I guess...

J, 36 34 bytes
(' ','#.'$~#){~[:+/(-@]{.-~$1:)/"2

Try it online!
-2 bytes thanks to Bubbler
We take input as a list of 2x2 matrices.

For each of them "2, draw a box of ones 1: of the same shape $ as the element-wise difference between the top-left and bottom-right coords -~.
Then rotate that down and to the right with 0 fill -@]{. until the upper leftmost 1 is in the coords specified by the left arg -@[.
[:+/ Sum the resulting matrices element-wise.  J guarantees they will be the same size by adding 0 fill to the right.  This will produce a single matrix with integers 0, 1, 2, 3, etc.  We'll use those to index into our ascii chars {~.
'#.'$~# Repeat the pattern #. cyclically $~ to the input length #, and then prepend a space ' ',.

34

@Bubbler, Thank you.

Python 2, 181 bytes
l=input()
_,_,x,y=map(max,zip(*l))
m=eval(`[[32]*x]*y`)
for v,w,x,y in l:
 for i in range(v,x):
	for j in range(w,y):
	 m[i][j]=max(m[i][j]^1,34)
for n in m:print''.join(map(chr,n))

Try it online!

R, 196 189 bytes
m=matrix
x=m(scan(file("stdin")),4)
y=m(0,max(x[3,]),max(x[4,]))
n=ncol(x)
while(n){z=x[,n]
i=z[1]:z[3]
j=z[2]:z[4]
y[i,j]=y[i,j]+1
n=n-1}
i=!y
y=y%%2+1
y[i]=' '
cat(rbind(y,'\n'),sep='')

Try it online!
The code reads input as stdin, arranged as a
x1 y1 x2 y2
tuple, where x is the column and y is the row.
I am using 1 and 2 for the overlap levels, where 1 represents an even level.
Saved 7 bytes thanks to user2390246.

A few ideas for golfing this down: 1. Is there any need to transform your matrix x? 2. Use nrow (or ncol if not transformed) instead of dim(x)[1] 3.  You don't need to define i=y>0 as you only use it once.

Initialise the matrix to -1 and then just use y=y%%2 and y[y<0]=" ".

Thank you. I included suggestion 1 and 2. Suggestions 3 and 4 would not work because: i=y>0 is used to store the levels prior to applying the modulus, and the modulus should not be sign preserving. However, that gave me the idea to use the implicit R convention that 0=FALSE, and save two extra bytes. :)

C (gcc), 205 bytes
x[999][999];a;b;c;d;j;k;l;m;n;main(i){for(;scanf("%d %d %d %d",&a,&b,&c,&d)>3;m=d>m?d:m,n=c>n?c:n)for(i=b;i<d;++i)for(j=a;j<c;++j)x[i][j]=x[i][j]^2|1;for(;k<n||++l<(k=0,puts(""),m);putchar(x[l][k++]+32));}

Try it online!

Raku, 54 bytes
{my@a;{@a[$^a..$^b;$^c..$^d]X+^=1}for $_;@a >>~|>>' '}

Try it online!
Takes input as a flat list of coordinates as inclusive coordinates, i.e. x1,y1,x2,y2,x1,y1,x2,y2... and outputs as a list of list of characters with k being 1 and l being 0.
Explanation:
{                                                    }  # Anonymous codeblock
 my@a;    # Declare an array
      {                          }for $_;    # Loop over the input
       @a[                 ]   # Indexing into @a
          $^a..$^b             # The range of rows
                  ;$^c..$^d    # And the range of columns for each
                            X        # And for each cell
                             +^=1    # Set it to itself bitwise XOR'd with 1
                         # Cells not yet accessed are numerically zero
                                         @a >>~|>>' '   # Stringwise OR each cell with a space
                         # Cells not yet accessed are stringily empty

Jelly, 43 bytes
+µ>2Ḥạ
ạ1ẋ$0ẋ⁸¤;µ/€«þ/µ€z0z€0Z€Zz€0Z€ç"/o⁶Y

Try it online!
Explanation
+µ>2Ḥạ                                Helper Link; combines final rectangles (0 is blank, 1 is covered, 2 is uncovered)
+                                     add the two values
 µ                                    (with the sum...)
  >2                                  check if it's greater than two
    Ḥ                                 double the result (2 if it's 3 or 4, 0 if it's 0, 1, or 2)
     ạ                                absolute difference (0 should take whatever the other thing's value is, 1+1 and 2+2 should give 2, 1+2 and 2+1 should give 1)
ạ1ẋ$0ẋ⁸¤;µ/€«þ/µ€z0z€0Z€Zz€0Z€ç"/o⁶Y  Main Link
               µ€                     For each rectangle stored as [[x1, x2], [y1, y2]]
         µ/€                          For each of [a, b] = [x1, x2] and [y1, y2], reduce it by (in other words, use a dyad on a size-2 list)
 1ẋ$                                  repeat [1]            times
ạ                                                abs(a - b)
        ;                             and append to
    0ẋ ¤                              [0] repeated   times
      ⁸                                            a
            «þ/                       and reduce by minimum outer product table (take the outer product table, by minimum, of the x results and the y results)
                                      [NOTE] At this point, we have a list of matrices with 0s as blanks and 1 as covered
                 z0z€0Z€Zz€0Z€        Make all of the matrices the same size:
                 z0                   zip, fill with 0 (all matrices are the same length, but not width, and now are lists of row-wise lists of rows)
                   z€0                zip each, fill with 0 (all rows are the same length within their row-wise lists, and are now lists of row-wise lists of columns)
                      Z€              zip each (flip rows back to lists of row-lists of rows)
                        Z             zip (flip back to matrices); however, if a matrix is smaller on both axes, its rows will not be the same length
                         z€0          zip each, fill with 0 (all rows in each matrix are the same length and the value is now a list of transposed matrices)
                            Z€        zip each (the value is now a list of matrices, all the same length, filled with 0 (empty space))
                              ç"/     reduce by (vectorized) the relation in the Helper Link (to combine all of the final values)
                                 o⁶   logical OR with " "; replace 0s with spaces
                                   Y  join with newlines (formatting)

source: Stack Exchange

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

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

sort: votes


text:
Implement the iOS 11 Calculator
iOS 11 has a bug that makes the result of 1+2+3 to be 24. This is related to the animation speed, but anyway:
The task is to make 1 + 2 + 3 == 24. But only that. So you should provide a function that correctly sums most sequences but returns 24 when the arguments are 1, 2 and 3 in any order.
Example inputs:
1 2 => 3
3 4 => 7
1 2 3 4 5 6 7 8 9 => 45
3 2 1 => 24
2 1 3 => 24
1 1 => 2
1 2 3 => 24
40 2 => 42
1 2 2 4 => 9
1 2 3 4 1 2 3 => 16
1 => 1
1 23 => 24
0 1 2 => 3
3 2 3 => 8

Input can be in any format as long as your code accepts any number of arguments.

Support for negative numbers isn't required (all non negative numbers are required to work, that includes 0)
We assume correct input

Differences from another similar question: "What do you get when you multiply 6 by 9? (42)":

In this case your function is required to accept any number of arguments. The old question specifies exactly 2.
In this case order doesn't matter, while the old question specified that order 6 9 is required and 9 6 should be evaluated correctly.

Also, iOS 11 doesn't work like that. It should be like this instead. (code explanation)

@user202729 The question is probably inspired by iOS 11. I don't think the OP is asking you to replicate it entirely.

@Okx exactly. This is for fun, not to implement it 1 to 1. Of course this could be changed to the user202729 proposal, but if he want he can create new challenge with such task.

Are the inputs integer?

One reason this is a beautiful challenge is because of the property linked to wherein this combination of numbers is very special. The other reason this is a beautiful challenge is that it pokes fun at Apple for prioritizing (their idea of) UX over functionality.

Possibly related: Solving twenty-four puzzles

Java 8, 109 106 101 90 75 74 71 66 bytes
a->{int s=0,p=0;for(int i:a){s+=i;p|=1<<i;}return s<7&p==14?24:s;}

-12 bytes thanks to @OlivierGrégoire.
-31 bytes thanks to @Nevay.
Explanation:
Try it here.
a->{                  // Method with integer-array parameter and boolean return-type
  int s=0,            //  Sum-integer, starting at 0
      p=1;            //  Product-integer, starting at 1
  for(int i:a){       //  Loop over the input-array
    s+=i;             //   Add current item to sum
    p|=1<<i;          //   Take 1 bitwise left-shifted with `i`, and bitwise-OR it with `p`
  }                   //  End of loop
  return p==14        //  If `p` is now exactly 14 (`0b1110`)
    &s<7?             //  and the sum is 6 or lower:
     24               //   Return 24
    :                 //  Else:
     s;               //   Return the sum
}                     // End of method

(Inefficient) proof that only [1,2,3] (in any order) will be the possible results when p is 0b1110 (p==14) and the sum is below 6 or lower (s<7): Try it here.

p==14 (0b1110) evaluates to true iff the input values modulo 32 cover the values 1, 2 and 3 and contain no other values (p|=1<<i) (each value has to occur 1+ times). The sum of input that matches p==14 will be larger than 6 for any input except 1,2,3 (s=a*1+b*2+c*3+u*32 with a>0,b>0,c>0,u>=0).
@Nevay

Old 71 bytes answer:
a->{int s=0,p=1;for(int i:a){s+=i;p*=i;}return a.length==3&p==s?s*4:s;}

Proof that for any three given non-zero natural numbers, only [1,2,3] (in any order) will have a sum equal to its product (1+2+3 == 1*2*3) (with a positive sum):
When the sum equals the product by Leo Kurlandchik & Andrzej Nowicki
(Inefficient) proof that only [1,2,3] (in any order) and [0,0,0] will be the possible results with non-negative numbers and a length of 3: Try it here.
So s*4 will becomes 6*4 = 24 for [1,2,3], and 0*4 = 0 for [0,0,0].

05AB1E, 9 bytes
Os{3LQi4*

Explanation:
Os{         Get the sum of the input, and then get the sorted input list
     Qi     If it is equal to...
   3L       [1, 2, 3]
       4*   Then multiply the sum by four.

Try it online!

MATL, 11 10 bytes
St3:X=6*+s

Try it online! or verify all test cases
Explanation
        % implicit input [3,1,2]
S       % sort
        % STACK: [1,2,3]
t       % duplicate elements
3:      % push range 1..3
        % STACK: [1,2,3], [1,2,3], [1,2,3]
X=      % true if arrays are numerically equal
        % STACK: [1,2,3], 1
6*+     % multiply result of comparison by 6 and add to the original array
        % STACK: [7,8,9]
s       % sum
        % (implicit) convert to string and display

Jelly, 8 bytes
3R⁼Ṣ4*×S

Try it online!

MATL, 13 bytes
stGp=18*Gda*+

Try it online!
It's two bytes longer than the other MATL answer, but it uses a completely different (and IMO more interesting) approach, so I figured it's worth posting.
Explanation:
This solution uses the fact that:

The sum and product of an array with three elements are only equal if the array is a permutation of 1,2,3.

This takes the input, calculates the sum s, and duplicates it t. It then checks if the sum equals the product Gp=. We multiply the boolean 1/0 by 18, 18*, and checks if there are non-identical values in the vector da* (again, multiply by a boolean any(diff(x)). We then multiply the two add the last number to the original sum.
A step by step explanation:
Assume the input is [1, 2, 3]:
s                              % Implicit input, calculate the sum
                               % 6
 t                             % Duplicate the sum:
                               % 6, 6
  G                            % Grab input
                               % 6, 6, [1,2,3]
   p                           % Calculate the product
                               % 6, 6, 6
    =                          % Check if the last two elements are equal
                               % 6, 1 (true)
     18*                       % Push 18, multiply by the last number
                               % 6, 18
        G                      % Grab input
                               % 6, 18, [1,2,3]
         d                     % Calculate the difference between each element
                               % 6, 18, [1,1]
          a                    % any non zero elements?
                               % 6, 18, 1 (true)
           *                   % Multiply last two numbers
                               % 6, 18
            +                  % Add numbers. Result: 24

Haskell, 37 bytes
f[a,b,c]|2^a+2^b+2^c==14=24
f l=sum l

Try it online!
We use pattern matching to catch the exceptional case.
Haskell doesn't have sorting built-in. The equality 2^a+2^b+2^c==14 is satisfied only by [a,b,c] a permutation of [1,2,3] among non-negative integers. A shorter a+b+c=a*b*c almost works, but is satisfied by [0,0,0], and appending the check ,a>0 makes it 1 byte longer.

Python 2, 39 bytes
lambda*a:sum(a)+18*(sorted(a)==[1,2,3])

Try it online!
Uses an alternate method of adding 18 if the sorted input is [1, 2, 3] to beat the other Python answer by a byte.

sorted(a)==[1,2,3] can become set(a)=={1,2,3} to save 3 bytes.

@mypetlion Unfortunately that would yield true for lists with duplicates such as [1, 2, 3, 3]

Woops. I though we were restricted to exactly 3 inputs.

Octave, 34 bytes
@(x)sum(x)+isequal(sort(x),1:3)*18

Try it online!
or
@(x)(s=sum(x))+18*~(s-6|prod(x)-6)

Try it online!
or
@(x)(s=sum(x))+18*~(s-prod(x)|s-6)

This is shorter than the approach others use: @(x){24,sum(x)}{2-isequal(sort(x),1:3)}.
Explanation:
It takes the sum of the vector, and adds 18 if the sorted vector is equal to 1,2,3. This will give 6+18=24 if the vector is a permutation of 1,2,3, and just the sum of the vector if not.

PHP, 116 bytes
This is my first attempt at a golfing challenge ever, AND it's PHP, a language which apparently sucks at golfing since I rarely see it here, so ... uhm, I tried?
<?php
//call as var/www/html/cg_ios.php --'1 2 3 4 5'
$i=$argv[1];$a=(explode(' ',$i));echo((($b=array_sum($a))==6&&count($a)==3&&in_array(3,$a)&&!in_array(0,$a)?24:$b));

Note: I did not include the comment into the bytecount.
Ungolfed
It's nothing special tbh:
$i=$argv[1];             //Read the input from the command line
$a=array_filter($c=explode(' ',$i)) //Split the input string into an array, use Whitespace as delimiter
                         //also, remove all 0 from the array, since they are not important at all
echo(                    //print the result
    ($b=array_sum($a) == 6  //If The SUM of the Array is 6 ...
        &&               //... AND ...
    (count($c) == 3)     //... the array has exactly 3 values ...
        &&               //... AND ...
    in_array(3,$a)       // ... the array contains the value 3 ...
        &&               // ... AND ...
    !in_array(0,$a)      //... the array contains no zeros
        ?
    24                   //print 24
        :
    $b));     //print the sum of the array values we saved earlier

If you want to test this in PHPFiddle and not on console, you can obviously replace $i with anything you'd like.
Thanks to Olivier Grégoire who made me aware of the string combination [0,3,3] which returned 24 before and also helped me saving a few chars by storing the array_sum and returning that instead of running the function again.

Welcome to the site, and nice first post!

What about input values [0, 3, 3]? Also, can't you save the result of array_sum($a) in a variable and reuse it?

@OlivierGrégoire That's fixed too now, I obviously missed that case. I probably could think of a better solution tho, this is - even for my standards - really ... messy.

Golfed code is missing $ on argv[1]

R, 47 bytes 34 bytes 36 bytes
x=scan();all(sort(x)==1:3)*18+sum(x)

Try it online!
Sum the input and add 18 if the input set is 1:3.
Thanks to @mlt for golfing off 11 bytes.
Thanks to @Ayb4btu for identifying an error with the overgolfed code

Javascript ES6, 39 bytes
Thanks to @Herman Lauenstein
a=>a.sort()=="1,2,3"?24:eval(a.join`+`)

f=a=>a.sort()=="1,2,3"?24:eval(a.join`+`)

console.log(f([1,2,3]));
console.log(f([1,2,3,4]));

Previous answer
Javascript ES6, 66 bytes
a=>(n=[1,2,3],a.every(_=>n.includes(_))?24:a.reduce((x,y)=>x+y,0))

Try it

f=a=>(n=[1,2,3],a.every(_=>n.includes(_))?24:a.reduce((x,y)=>x+y,0))

console.log(f([1,2,3]));
console.log(f([1,3,2]));
console.log(f([1,2,3,4]));

58 bytes: a=>(Array.sort(a).join()=="1,2,3"?24:a.reduce((x,y)=>x+y))

a.sort()=="1,2,3" works.

39 bytes: a=>a.sort()=="1,2,3"?24:eval(a.joinBT+BT) (replace BT with backticks)

Swift, 67 Bytes
func z(i: [Int])->Int{return i.sorted()==[1,2,3] ?24:i.reduce(0,+)}

Could make it to 27 bytes with extensions on [Int], but that would be cheating :(

Welcome to the site! This is a code golf competition, please can you golf you code as much as possible, such as by removing spaces. Also, I don't know Swift, but if I'm correct, this saves the input in a variable, which isn't allowed. You are however, allowed to turn this into a function.

Golfed down a little: func z(i:[Int]){print(i.sorted()==[1,2,3] ?24:i.reduce(0,+))}.

Or 55 bytes (-12): {$0.sorted()==[1,2,3] ?24:$0.reduce(0,+)}as([Int])->Int, as anonymous functions are allowed by our standard rules. You can see how it works here.

@Mr.Xcoder you could omit the casting and add it to the f constant you are declaring. or put the type inside the closure and you get rid of as :)

@DominikBucher That way you'd have to add var f= into the byte count, which would eventually waste bytes.

+1 for Swift. Is this the original source code of the iOS calculator?

@GB yes it is original idea.

Mathematica, 28 bytes
If[Sort@#=={1,2,3},24,Tr@#]&

Try it online!

Lua, 116 81 bytes
-7 bytes thanks to Jonathan
Takes input as command line arguments
Z=0S={}for i=1,#arg do
j=arg[i]+0S[j]=0Z=Z+j
end
print(#S>2 and#arg<4 and 24or Z)

Try it online!
Explanation:
Works by creating an sparse array S and adding zeroes in the indices corresponding to the input values. If parameters are 3, 4, 7 the sparse array will only have numbers at those indices. With that array, we get it's length with the operator # that counts from index 1 up to the higher index that has a value in it, if this length is exactly 3, it means that there were elements in the position 1, 2 and 3 wich is what we're looking for. The length of the sparse array will be always between 0 and N where N is the number of parameters. So we just have to check if the length of both the parameters array and the sparse array is 3.

80 bytes

You saw nothing (I edited my comment, since it wasn't after 5 minutes yet. ;P)

Yeah, just found the same flaw in my own answer.. I fixed it by using array-length==3 AND A==S AND S>0. But I guess checking the length of the #args in Lua is a bit too byte-heavy? In that case you can rollback to your 90-bytes answer I guess.. :(

83 bytes

@JonathanS. nice one

R, 55 45 54 49 57 54 48 bytes
Saved many bytes and incorrect solutions thanks to Ayb4btu.
Saved 3 9 bytes thanks to Giuseppe. I keep learning new ways to abuse the fact that F==0.
"if"((s=sum(x<-scan()))-prod(x)|sum(x|1)-3,s,24)

Try it online!
The other R answer won in the end.

Fails for [0,0,0]: returns 24 instead of 0.

I apparently missed both 'non-negative' and 'can be a single number' in the spec. Hold on.

c(1,1,2,3) returns 28 instead of 7

@Ayb4btu Thank you, nice catch.

@BLT I think the issue is still there, it's like the length check isn't working (I don't think it is just TIO not being updated).

@BLT Nevermind, just realised that the code section isn't the code being run.

@Ayb4btu Yep, just updated the TIO link. Should work now.

You can change s*4 to 24 and save a byte.

Me again, c(1,1,6) returns 24. Also, neat that you could get rid of the s variable.

x=scan();s=sum(x);"if"(s-prod(x)|s-6|length(x)-3,s,24) is 54 bytes swapping the condition and using | instead of & so we can subtract.

From Stewie Griffin's MATL answer: "The sum and product of an array with three elements are only equal if the array is 1,2,3.", so 48 bytes

@Giuseppe yes, that's right. the s=6 thing was left over from me trying not to check the length. I ended up having to in the end, and forgot I didn't need to check the value of the sum anymore.

J, 17 bytes
-6 bytes thanks to Frowny Frog
+/*1+3*1 2 3-:/:~

Sum all the numbers +/ and multiply the result by (pseudocode) 1 + 3*(is123 ? 1 : 0).  That is, return the results unchanged unless the sorted list is 1 2 3 in which case we multiply the result by 4.
Try it online!
original answer
+/`(24"_)@.(1 2 3-:/:~)

Check if the sorted input is 1 2 3 -- if yes, invoke the constant function 24 (24"_); if not, return the sum +/
Try it online!

I don't really know J, but can 1 2 3 → i.3?

@Uriel, i.3 produces 0 1 2, so you'd have to do 1+i.3 which saves no chars but is less clear.

right, I forgot J is 0 indexed

[:+/8"0^:(1 2 3-:/:~)

+/@,[*3*1 2 3-:/:~

@FrownyFrog the last one is a really clever golf

+/*1+3*1 2 3-:/:~ now it's golfed :P

C (gcc), 136 131 125 97 91 83 81 bytes
Thanks to @landfill babby, and @ceilingcat (of course we're not using c anymore)
r,t;main(i,v)int**v;{for(;*++v;t|=1<<i)r+=i=atoi(*v);printf("%d",r>6|t-14?r:24);}

Try it online!

83

C# (.NET Core), 57+18=75 bytes
a=>a.OrderBy(x=>x).SequenceEqual(new[]{1,2,3})?24:a.Sum()

Try it online!
+18 for using System.Linq;

C++17, 56 54 bytes
[](auto...i){return(-i&...)+4|(~i*...)+24?(i+...):24;}

Try it online!
Note that the function object created is usable at compile time, so the tests are performed by the compiler without having to run a program.
Explanation:
[]             // Callable object with empty closure,
(auto...i)     // deduced argument types,
{              // and deduced return type
  return       //
      (-i&...) //   If the fold over the bitwise AND of the negation of each argument
    +4|        // is unequal to -4, or
      (~i*...) //   if the product of the bitwise complements of the arguments
    +24?       // is unequal to -24, then
      (i+...): //   return the sum of the arguments, otherwise
      24;}     //   return 24.

Proof that the only nonnegative i... for which (-i&...) equals -4 and (~i*...) equals -24 are the permutations of 1, 2, 3:
We first observe that since -0 = 0, if any i = 0 then (-i&...) = 0, so we conclude that all the i are positive.
Now, note that in 2's complement, -i is equivalent to ~(i - 1), and ~i is equivalent to -(i + 1). Applying De Morgan's rule, we find that (-i & ...) = ~((i - 1) | ...) = -(((i - 1) | ...) + 1), so ((i - 1) | ...) = 3; similarly, -1 ** n * ((i + 1) * ...) = -24, so n is odd and ((i + 1) * ...) = 24.
The prime factors of 24 are 2**3 * 3, so n <= 4. If n = 1, we have i - 1 = 3 and i + 1 = 24, so n = 3. Write the i wlog as a <= b <= c, then clearly a = 1 as otherwise (a + 1)(b + 1)(c + 1) >= 27. Also c <= 4 as otherwise (a - 1)|(b - 1)|(c - 1) >= 4. c cannot be 4 as 5 is not a factor of 24, so c <= 3. Then to satisfy (a - 1)|(b - 1)|(c - 1) = 3 c = 3, b = 2 as required.

Retina, 21 bytes
O`
^1¶2¶3$
24
.+
$*
1

Try it online!
Input is linefeed-separated, but the test suite uses comma-separation for convenience.
Explanation
O`

Sort the numbers (lexicographically, actually, but we only care about the case that the inputs are 1, 2, 3 in some order, where that doesn't make a difference).
^1¶2¶3$
24

If the input is 1,2,3 (in some order), replace it with 24.
.+
$*

Convert each number to unary.
1

Count the number of 1s, which adds the unary numbers and converts them back to decimal.

Out of curiosity, based on your explanation I understand the final line counts all occurrences of the match (all 1s in this case). Does Retina always do this for a single final line? Or is it also possible to count all 1s somewhere in between, and then after that continue with the result to do something else (which uses two lines again for replace-actions)? Also, another related question: which functions in Retina require only a single line? The sorting (`O``) is one of them, and the other functions as well; but any other? Just trying to understand Retina a bit more. :)

@KevinCruijssen Yes you can use a (counting) match stage somewhere in the middle, but you'll have to explicitly mark it as a match stage with M\``. It's only if there is a single trailing line that Retina defaults to Match instead of Replace. AGMTSare all single-line stages,Ris two lines,OandDare one or two lines depending on whether the$` option is used (which turns them into sort/deduplicate-by stages). Feel free to ping me in the Retina chatroom if you have more questions: https://chat.stackexchange.com/rooms/41525/retina

Haskell, 44 bytes
f a|sum a==6,product a==6,a<[6]=24|1<2=sum a

Try it online!
The permutations of [1,2,3] are the only partitions of 6 whose product is 6, barring 6 itself. (This assumes the inputs are non-negative, which seems to be the case for all the test cases… I’ve asked the OP about this.)

43 bytes.

PL/SQL - 135 123 Bytes
Assuming i as an integer array input of any size:
if (select sum(s) = exp(sum(ln(s))) from unnest(i) s) then
    return 24;
else
    return (select sum(s) from unnest(i) s);
end if;

Welcome to PPCG! Could you try to golf it by removing all the extra spaces, even if it makes the answer unreadable (as long as it compiles, though)?

Jq 1.5, 35 bytes
if[1,2,3]==sort then 24else add end

Assumes input is an array e.g. [2,1,3]
Try it online!

Husk, 9 bytes
?K24Σ=ḣ3O

Try it online!
Explanation
?K24Σ=ḣ3O
        O    Sort the input
?    =ḣ3     If it is equal to [1,2,3]:
 K24           Return 24
             Else:
    Σ          Return the sum of the input

Previous solution
Gives the wrong result to [2,2], and probably other inputs too, but it was more interesting.
?ṁD→E§eΠΣ
     §eΠΣ    Build a two-element list with the product and sum of the input
?   E        If the two elements are equal:
             (true for any permutation of [1,2,3] and the list [0,0,0]
 ṁD            Double both elements and sum them
               (This is 4 times the sum: 24 for permutations of [1,2,3], 0 for [0,0,0])
             Else:
   →          Return the last element (the sum)

Try it online!

This gives 24 for 2,2

@recursive actually it gives 16, but you are right. And probably this gives wrong results for some longer arrays too... Damn, I need to switch to a boring solution

Jelly, 10 9 bytes
Ṣ24S⁼?3R¤

Try it online!
-1 byte thanks to Erik
Alternative (by Mr. Xcoder), also for 9 bytes:
3R⁼Ṣ×18+S

Try it online!
How it works
Ṣ24S⁼?3R¤ - Main link. Argument: l (list)

Ṣ         - Sort
     ?    - Ternary if statement
    ⁼     -  Condition: Is l equal to...
      3R¤ -    [1, 2, 3]
 24       -  If condition: Return 24
   S      -  Else: Return the sum of the list

You can do Ṣ24S⁼?3R¤ for 9 bytes.

Or 3R⁼Ṣ×18+S for 9 bytes too.

Python 2, 41 39 bytes
-1 byte thanks to caird
-1 by inspiration from FlipTack's answer
lambda*a:sum(a)*4**(sorted(a)==[1,2,3])

Try it online!
Alternative 39 bytes solution
lambda*a:sum(a)<<2*(sorted(a)==[1,2,3])

40 bytes

APL (Dyalog), 20 15 bytes
5 bytes saved thanks to @EriktheOutgolfer
{4*⍵[⍋⍵]≡⍳3}×+/

Try it online!

{4*⍵[⍋⍵]≡⍳3}×+/

Pushy, 12 bytes
gF3RFx?18;S#

Try it online!
This works by sorting the input and, if it is equal to [1, 2, 3], appending 18. Then, the sum is calculated and printed, yielding 24 is 18 was appended, and the normal answer otherwise.
         \ Implicit: Input on stack.
g        \ Sort input ascendingly
F3RF     \ On auxiliary stack, push range(3) -> [1, 2, 3]
x?       \ If the stacks are equal:
  18     \    Append 18 to the input
;
S#       \ Print sum of input.

Haskell, 47 bytes
import Data.List
f l=sum$l++[18|sort l==[1..3]]

Try it online!

Pyth, 9 bytes
?qS3SK24s

Verify all the test cases.

Pyth, 9 bytes
Different aproach from the other Pyth answer.
*sQ^4qS3S

Explanation:
A port from my Python answer
*sQ^4qS3SQ  # Full program (Q at the end is implicit and represents the input)

*           # A * B where A and B are the next two lines
  sQ        # Sum elements of input
  ^4        # 4 to the power of:
    qS3SQ   # Compares sorted input to [1, 2, 3] and returns 0 or 1

Try it online!

PowerShell, 44 bytes
param($a)($a-join'+'|iex)+18*!(diff(1..3)$a)

Try it online!
Similar algorithm to the Python and JavaScript answers. Takes input as a literal array $a. Then immediately sums $a together, which forms the left-hand operator of the +.
The right-hand is the diff (alias for Compare-Object) of 1,2,3 and $a -- this is either an empty array if they are equal, or a non-empty array of the different items if they are not equal -- enclosed in a Boolean-not. So, if they are equal, that makes the empty array (a falsey value) into $true.
That's then multiplied by 18 which implicitly casts $true to 1 and $false to 0. So the right-hand side will be 18 if the arrays are the same, and 0 otherwise. That gives the correct result of 24 if the input array is 1,2,3 in any permutation, and the summation of the input array otherwise.

Kotlin, 46 44 bytes
if(i.sorted()==listOf(1,2,3))24 else i.sum()

Try it online!
Edits

Mr. Xcoder -2 bytes

Could you use listOf(1,2,3) to save 2 bytes? I don't know Kotlin, so I'm not sure.

C++, 109 bytes
#import<list>
int f(std::list<int>l){l.sort();int s=0;for(int i:l)s+=i;return l==std::list<int>{1,2,3}?24:s;}

Try it online!

Japt -x, 14 11 bytes
n e3õ)?24:U

Try it online!

Nice technique, but I think this would fail on inputs [1,23] and [123].

@ETHproductions Thanks. I wish there were a better way to compare arrays.

Perl 5, 25 bytes
[sort@_]~~[1..3]?24:sum@_

Try it online!

As it stands, this is a code fragment.  You need to include all of the bytes in your score, including command line options.

Racket, 49 bytes
(λ x(if(equal?(sort x <)'(1 2 3))24(apply + x)))

Try it online!

Perl 5, 34 bytes
[sort@_]~~[1..3]?24:0+map{1..$_}@_

Try it online!
This is similar to my other answer, but does not use the import sum function. Instead it creates an array whose size is the sum of the number. But only works for non-negative integers.

Ruby, 29 bytes
->a{a.sort==[*1..3]?24:a.sum}

q/kdb+, 24 bytes
Solution:
(sum x;24)1 2 3~x:asc(),

Try it online!
Note: Link is to a K (oK) port of the K4 version below as there is no TIO for q/kdb+.
Examples:
q)(sum x;24)1 2 3~x:asc(),1
1
q)(sum x;24)1 2 3~x:asc(),1 2
3
q)(sum x;24)1 2 3~x:asc(),1 2 3
24
q)(sum x;24)1 2 3~x:asc(),1 2 3 4
10
q)(sum x;24)1 2 3~x:asc(),1 3 2
24

Explanation:
q is interpreted right-to-left:
(sum x;24)1 2 3~x:asc(), / the solution
                     (), / convert to list if not already a list (cannot sort atom)
                  asc    / sort list ascending
                x:       / store input in variable x
          1 2 3~         / is sorted list equal to list 1 2 3? boolean 0 or 1
(     ;  )               / two item list which we index into
       24                / index 1 (true), the fake result 24
 sum x                   / index 0 (false), sum the input list

Notes:

K4 version that aligns with TIO link: (+/x;24)1 2 3~x@<x:(), for 22 bytes
Q is just syntactic sugar on top of K4, sum is +/, asc is x@<x

C (gcc), 111 153 bytes
#define A(x)if(v[x]>v[x+1]&c>2)t=v[x],v[x]=v[x+1],v[x+1]=t;
i;s;t;f(c,v)int*v;{for(s=i=0;i<c;s+=v[i++]);A(0)A(1)A(0)return c!=3|*v-1|v[1]-2|v[2]-3?s:24;}

Try it Online!
+42: Fixed {3,2,3}, {1,1,1}, {2,2,2}, etc.
I will try to golf more later.
f is a function which takes the length of the array as an int and a pointer to the first element of the array (of unsigned ints) and returns the 'IOS 11 Calculator Sum' of the array.
Ungolfed (Old, broken version):
#define not_one_two_or_three(index) (arr[index] > 3 || arr[index] == 0)
int counter;
int sum;
int ios_sum(int length, unsigned int *arr) {
    sum = 0;
    for (counter = 0; counter < length; counter++) {
        sum += arr[counter];
    }
    if (length != 3 || not_one_two_or_three(0) || not_one_two_or_three(1) || not_one_two_or_three(2))
        return sum;
    else return 24;
}

This doesn't work for input 3, 2, 3.

148 bytes

Add++, 17 bytes
L,dB#3R=''1$o$b+*

Try it online!

OP says negative numbers don't have to be supported, implying that non-negative numbers do... however on this answer 1 + 2 + 3 + 0 = 24

Given 3, 2, 1, this outputs 6.

@FlipTack Very late, but fixed

Ruby, 28 bytes
->s{s&[*1..3]==s&&24||s.sum}

Thunno 2 S, 8 bytes
ṠD3R⁼6×+

Try it online!
Explanation
ṠD3R⁼6×+  # Implicit input
ṠD        # Sort and duplicate
  3R⁼     # Equals [1,2,3]?
     6×+  # Multiply by 6 and add
          # Implicit output of sum

Racket, 52 bytes
(define(c x)(if(equal?(sort x <)'(1 2 3))24(sum x)))

Try it online!

Explanation
We create a function called c that checks whether x is equal to '(1 2 3) when x is sorted. If it is, we return 24, otherwise we take the sum of the list.
(define (calc xs)
  (if (equal? (sort xs <) '(1 2 3))
      24
      (sum xs)))

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


text:
What's assignable to what?
related

What's assignable to what?
In this challenge you will be given two types, A and B and determine if A is assignable to B, B is assignable to A, or neither.
The Type System
(I will use t to represent any type)
Basic Types
Basic types are represented by a single capital letter, such as X. They are basically classes.

X is assignable to Y if Y is either the same as, or a parent class of X.

Intersection Types
Intersection types are represented by intersect<X, Y>, and can have any number of types between the <'s (e.g. intersect<X, Y, Z, D, E>).

t is assignable to intersect<X1, X2... Xn> if t is assignable to all X.
intersect<X1, X2... Xn> is assignable to t if any X is assignable to t.

Union Types
Union types are represented by union<X, Y> and can have any number of types between the <'s (e.g. union<X, Y, Z, D, E>).

t is assignable to union<X1, X2... Xn> if t is assignable to any X.
union<X1, X2... Xn> is assignable to t if all X are assignable to t.

Input
You will receive as input:

The class hierarchy. You may choose the method of input for the class hierarchy. You can input a representation of a tree, or each type with a list of its parents, or anything else that accurately represents the class hierarchy.
Two types (input is flexible, as long as the notation is consistent you may receive these types however you like).

Output
You will output one of three consistent and distinct values, call them X, Y, and Z. Given two types A and B, output X if A is assignable to B, output Y if B is assignable to A and output Z otherwise (If A is assignable to B and B is assignable to A, you may output X, Y, both, or a fourth value).

Test Cases
Format:
# of types
[type, parents...]
[type, parents...]
Type a
Type b

2
[A,B]
[B]
A
B
--
A is assignable to B

3
[A,B,C]
[B,C]
[C]
intersect<A,C>
A
--
A is assignable to intersect<A,C>

3
[A,B,C]
[B,C]
[C]
union<A,C>
A
--
A is assignable to union<A,C>

3
[A,B,C]
[B,C]
[C]
intersect<B,C>
A
--
A is assignable to intersect<B,C>

3
[A,B,C]
[X,Y,Z]
[T,U,V]
intersect<union<A,T,X>,intersect<A,B>,Y>
intersect<T,C,X>
--
intersect<T,C,X> and intersect<union<A,T,X>,intersect<A,B>,Y> are not assignable to each other

1
[A]
A
A
--
A is assignable to A

3
[A,B,C]
[X,Y,Z]
[T,U,V]
intersect<A,intersect<A,B>,Y>
intersect<T,C,X>
--
intersect<T,C,X> and intersect<A,intersect<A,B>,Y> are not assignable to each other

2
[A]
[B]
A
B
--
B and A are not assignable to each other

3
[A,B,C]
[X,Y,Z]
[T,U,V]
intersect<union<A,X>,intersect<A,B>,Y>
intersect<T,C,X>
--
intersect<T,C,X> and intersect<union<A,X>,intersect<A,B>,Y> are not assignable to each other

Here is a link to a working ungolfed Java solution you can use for testing (it takes input in the same way as the test cases)

This is code-golf, so least bytes in each language wins for that language!

Sandbox (deleted)

@ovs no, A has parents B and C.

@HalvardHummel apologies; I've edited the post

Will inherit form a circle?

What should output if both A is assignable to B and B is assignable to A?

Will any intersection / union contain at least 2 types?

@tsh As stated in the main post, if A->B and B->A you may output X, Y, or both... you may also output a fourth value if its easier. Also, an intersection/union could contain a single type.

Python 3, 177 bytes
c is a dictionary of the parents of each type, a and b are the two expression to check. Types are represented by strings, while intersects and unions are represented by lists with of expressions, with the first element set to 0for intersect and 1 for union
Returns 0 if they are not assignable to each other, 1 if a is assignable to b, 2 if b is assignable to a and 3 if both are assignable to each other
lambda c,a,b:y(a,b,c)+2*y(b,a,c)
y=lambda a,b,c:(b in c[a]or a==b if b[0]in c else[all,any][b[0]](y(a,x,c)for x in b[1:]))if a[0]in c else[any,all][a[0]](y(x,b,c)for x in a[1:])

Try it online!

JavaScript (ES6), 138 bytes
(p,a,b,g=(a,b)=>a==b||(p[a]||a.i||a.u||[])[a.u?'every':'some'](t=>g(t,b))||(b.i||b.u||[])[b.i?'every':'some'](t=>g(a,t)))=>g(a,b)||+g(b,a)

p is the parent map, which is a JavaScript object whose keys are the types with parents and whose values are arrays of parent(s). For example, if there are two types A and B and B is the parent of A then p would be {A:['B']}.
Intersection types are represented in a and b as a JavaScript object with a key of i whose value is an array of types, while union types have a key of u. For example, the intersection of two types A and B would be {i:['A','B']}.
The return value is true if a is assignable to b, 1 if a is not assignable to b but b is assignable to a, or 0 if neither is assignable to each other.

C++17, 595 bytes
#include<type_traits>
#define p(x)template<class...T>class x;
#define d(a,b)disjunction<s<a,b>...>{};
#define c(a,b)conjunction<s<a,b>...>{};
#define u(x)u<x...>
#define i(x)i<x...>
#define k struct s
#define e ...A
#define t(a,b)template<class a,class b>
using namespace std;p(i)p(u)t(B,D)k:disjunction<is_base_of<B,D>,is_same<B,D>>{};t(a,e)k<a,u(A)>:d(a,A)t(a,e)k<a,i(A)>:c(a,A)t(a,e)k<u(A),a>:c(A,a)t(a,e)k<i(A),a>:d(A,a)t(e,...B)k<i(A),i(B)>:d(A,i(B))t(e,...B)k<u(A),u(B)>:c(A,u(B))t(e,...B)k<i(A),u(B)>:d(A,u(B))t(e,...B)k<u(A),i(B)>:c(A,u(B))t(A,B)int f=s<A,B>::value?-1:s<B,A>::value?1:0;

Try it online!
A variable template f that accepts as input some types and intersection i<...> or union u<...> of them and returns -1 if A is assignable to B  and 1 if B is assignable to A and 0 otherwise.
Ungolfed:
#include <type_traits>
using namespace std;

template<class...T>class Intersect;
template<class...T>class Union;

template<class A,class B>
struct is_assignable_to:
    disjunction<is_base_of<A,B>,is_same<A,B>>{};

template<class a,class...A>
struct is_assignable_to<a,Union<A...>>:
    disjunction<is_assignable_to<a,A>...>{};

template<class a,class...A>
struct is_assignable_to<a,Intersect<A...>>:
    conjunction<is_assignable_to<a,A>...>{};

template<class a,class...A>
struct is_assignable_to<Union<A...>,a>:
    conjunction<is_assignable_to<A,a>...>{};

template<class a,class...A>
struct is_assignable_to<Intersect<A...>,a>:
    disjunction<is_assignable_to<A,a>...>{};

template<class...A,class...B>
struct is_assignable_to<Intersect<A...>,Intersect<B...>>:
    disjunction<is_assignable_to<A,Intersect<B...>>...>{};

template<class...A,class...B>
struct is_assignable_to<Union<A...>,Union<B...>>:
    conjunction<is_assignable_to<A,Union<B...>>...>{};

template<class...A,class...B>
struct is_assignable_to<Intersect<A...>,Union<B...>>:
    disjunction<is_assignable_to<A,Union<B...>>...>{};

template<class...A,class...B>
struct is_assignable_to<Union<A...>,Intersect<B...>>:
    conjunction<is_assignable_to<A,Intersect<B...>>...>{};

template <class A,class B>
int f = is_assignable_to<A,B>::value?-1:is_assignable_to<B,A>::value?1:0;

Usage:
#include <iostream>
int main(){
    struct B{};
    struct C{};
    struct Y{};
    struct Z{};
    struct U{};
    struct V{};
    struct A:B,C{};
    struct X:Y,Z{};
    struct T:U,V{};
    std::cout << f<Intersect<A,Intersect<A,B>,Y>,Union<T,C,X>>;
}


text:
Name of Frankenstein's Monster
Introduction:
Since it's almost Halloween, I was just thinking of some random Halloween-themed challenges. Eventually I was reading through Frankenstein's wikipedia page, and came across the following text:

The creature
Part of Frankenstein's rejection of his creation is the fact that he does not give it a name, which causes a lack of identity. Instead it is referred to by words such as "wretch", "monster", "creature", "demon", "devil", "fiend", and "it". When Frankenstein converses with the creature in Chapter 10, he addresses it as "vile insect", "abhorred monster", "fiend", "wretched devil", and "abhorred devil".

source
Challenge:
Given two integers (year and chapter), output a string based on the following rules:

If the year is less than 1818: output an empty string †
If the year is exactly 1818 and the chapter is below 10: output a random string from the list ["wretch", "monster", "creature", "demon", "devil", "fiend", "it"]
If the year is exactly 1818 and the chapter is 10 or higher: output a random string from the list ["vile insect", "abhorred monster", "fiend", "wretched devil", "abhorred devil"]
Is the year above 1818 (and thus the book was published), return "Frankenstein's Monster".

Challenge rules:

You can choose whether to output in lowercase, uppercase, or a combination.
The year will always be in the range 1500-2017
The chapter will always be in the range 1-24 (if I googled correctly, the book has 24 chapters)
† Instead of outputting an empty string for option 1, you are also allowed to output null, undefined, false, 0, or any other value of your choice not part of the other three options (please specify what you've used in your answer).
The output may not contain any leading or trailing spaces/tabs, nor any leading new-lines. It may contain one optional trailing new-line.

General rules:

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

Test cases:
year,chapter possible outputs:

1700,1       ""; null; undefined; false; 0; etc.
1700,12      ""; null; undefined; false; 0; etc.
1817,10      ""; null; undefined; false; 0; etc.
1818,1       "wretch"; "monster"; "creature"; "demon"; "devil"; "fiend"; "it"
1818,9       "wretch"; "monster"; "creature"; "demon"; "devil"; "fiend"; "it"
1818,10      "vile insect"; "abhorred monster"; "fiend"; "wretched devil"; "abhorred devil"
1818,11      "vile insect"; "abhorred monster"; "fiend"; "wretched devil"; "abhorred devil"
1818,18      "vile insect"; "abhorred monster"; "fiend"; "wretched devil"; "abhorred devil"
1819,1       "Frankenstein's Monster"; "frankenstein's monster"; "FRANKENSTEIN'S MONSTER"
1819,18      "Frankenstein's Monster"; "frankenstein's monster"; "FRANKENSTEIN'S MONSTER"
2017,24      "Frankenstein's Monster"; "frankenstein's monster"; "FRANKENSTEIN'S MONSTER"

Perl 5, 156 153 151 bytes
-3 bytes thanks to DomHastings.
Run with -p
$_=($d=devil,$m=monster,$w=wretch,<"{creature,demon,it,fiend,vile insect,{abhorr,$w}ed {$d,$d,$m},Frankenstein's $m}">)[/818/?6*/,../+rand 7:$_/606-5]

This output distribution is non-uniform, which is accepted by default. Specifically, if the date is 1818 and the chapter is ≥10, the names “abhorred devil” and “abhorred monster” are weighted twice as much. This lets me use rand 7 for both cases, even though the lists are of different sizes.
The output for years before 1818 is “wretched monster”. Despite some similarities, this string is not part of any of the other three options, making it okay to use.
This fails for years outside of the 1212—2424 range, but luckily the year is guaranteed by the rules to be in the 1500—2017 range.
Try it online!

I didn't know brace expansion was a thing in Perl at all... Using that approach, there's a great solution for the known knowns challenge! Try it online!

@DomHastings Ooh I didn’t know you could quote spaces like that. That’s -3 bytes here!

Glad I was able to help! I'll definitely have to try and remember this, I guess it's because <...> assumes globs?

<> is either readline or glob, depending on… stuff (classic Perl: the grammar is ambiguous, but the parser tries to DWYM). When it’s a glob, it closely mimics shell globs, including the brace expansion that’s a common feature in shells.

Could you perhaps add a TIO-link to your answer. :) It's currently the shortest answer, but I just want to make sure everything works before I accept it as the shortest.

@KevinCruijssen I added a TIO link. Note that the TIO code uses -l for aesthetic reasons only (without it, the outputs are all concatenated on a single line, making them hard to read). Since the trailing newline is optional, that flag shouldn’t be counted in my answer’s score.

@Grimy Thanks for adding the TIO link. And funny how you output wretched monster as <1818 output. :) But you're indeed right, it's not part of the other options, so indeed allowed. I've accepted your answer as the shortest.

Python 2, 227 220 214 bytes
lambda y,c:[[choice([["wretch",m,"creature","demon",d,F,"it"],["vile insect",a+m,F,"wretched "+d,a+d]][c>9]),"Frankenstein's "+m][y>1818],0][y<1818]
from random import*
m,d,F,a='monster','devil','fiend',"abhorred "

Try it online!

You can save 6 more bytes by putting 'abhorred ' to the list at the bottom as well, since it's been used twice. ('wretch' is also possible, but byte-count stays the same.)

Perl 5, 172 bytes
171 bytes code + 1 for -p.
@a=<><10?($}=wretch,$M=monster,creature,demon,$D=devil,fiend,it):("vile insect",($A="abhorred ").$M,fiend,"$}ed $D",$A.$D);$_=($a[rand@a],"frankenstein's $M",0)[$_<=>1818]

Try it online!
Explanation
Pretty standard, only slightly unsual thing is using the 'spaceship operator' (<=>) with 1818 to return -1, 0, or 1, if the input $_ is less than, equal to, or greater than 1818 to return the last, first, or second index of the source data. Also, I like the fish operator!

I was going to question not using $F=fiend, but after testing it ends up being the same length to do so.

@KamilDrakari Yeah, needs to be length of six or more because of the $ sigil :(

$} what a variable name ...

@Titus Yup! Almost anything works, although many have extra special meaning. I only used it there as if I'd used $W I'd have needed to use ${W} as it's next to another letter.

I reckoned that. gotcha none the less :)

C# (Visual C# Compiler), 225 209 bytes
y=>c=>y<1818?"":y>1818?"frankenstein's monster":"wretch,monster,creature,demon,devil,it,fiend,vile insect,abhorred monster,wretched devil,abhorred devil".Split(',')[new System.Random().Next(c>9?6:0,c>9?11:7)];

Try it online!
-16 thanks to Kevin Cruijssen
Not particularly concise, but I would expect C# to take more space to declare and use any repeated strings the way the Python answer does than to just repeat them. The included test runner has a Thread.Sleep(1) inside the enumeration of test cases because default seeding for Random() uses the current time and the actual function runs fast enough to end up with the same seed on subsequent runs without a delay.
Calls to the func use currying syntax, f(year)(chapter) (or whatever name the function is stored in instead of f)

I see you applied the same trick as I had in mind when I posted the challenge, putting fiend in the middle of a single string-array, since it's present in both lists. You can save some bytes by replacing new[]{"wretch","monster","creature","demon","devil","it","fiend","vile insect","abhorred monster","wretched devil","abhorred devil"} with "wretch,monster,creature,demon,devil,it,fiend,vile insect,abhorred monster,wretched devil,abhorred devil".Split(',') (-16 bytes)

@KevinCruijssen Nice trick, It doesn't immediately seem beneficial but changing the delimiter from "," to just , makes up for the longer .Split(',') compared to new[]{} with more than a few items.

Bash, 229, 206, 197, 179  bytes
m=monster
a=("Frankenstein's $m" wretch $m creature demon devil it fiend vile\ insect {abhorr,wretch}ed\ {devil,$m})
echo "${a[$1>1818?0:$1<1818?13:RANDOM%($2>9?5:7)+($2>9?7:1)]}"

the explanation about brace/variable expansions
m=monster
{abhorr,wretch}ed\ {devil,$m}

is first expanded to
abhorred\ {$m,devil} wretched\ {devil,$m}
abhorred\ $m abhorred\ devil wretched\ devil wretched\ $m

then variable m is expanded
abhorred\ monster abhorred\ devil wretched\ devil wretched\ monster

however following doesn't work because $w will be first joined with ed and wed is not defined and will be expanded to empty string.
m=monster
w=wretch
{abhorr,$w}ed\ {devil,$m}

it can be done adding explicit braces arround w but will be longer
m=monster
w=wretch
{abhorr,${w}}ed\ {devil,$m}

TIO

You can save 4 bytes by creating variables for wretch and monster (225 bytes).

not so simple because of brace expansion which occurs before variable expansion

I (almost) never programmed in Bash, so could you clarify what you mean by that? It does seem to work in TIO, but maybe I'm missing something due to the way the programming language behaves.

printf '%s\n' "${b[@]}" after b=(..) will not give wretched devil for example

Ah ok, I get it now. It does seem to work with just m=monster, though. Try it here. Also, shouldn't d%5 be d%6 (the six options are fiend, vile insect, abhorred devil, abhorred monster, wretched devil, and wretched monster)?

in fact it is %5 because wretched monster was not specified in list but generated by cartesian product

@KevinCruijssen thnak you i learnt something when braces are the last element expansion works

Making a variable for devil is actually longer than simply using it twice. :) v=devil $v$v = 12 bytes; devildevil = 10 bytes.

I think you need to swap $m,devil to devil,$m because I think you're excluding wretched devil when you want to exclude wretched monster! :)

@DomHastings, yes, fixed

Java (OpenJDK 8), 275 269 255 207 203 bytes
y->c->y<1818?0:y>1818?"Frankenstein's monster":"wretch;monster;creature;demon;devil;it;fiend;vile insect;abhorred monster;wretched devil;abhorred devil".split(";")[c+=Math.random()*(c>9?5:7)+(c>9?6:0)-c]

Try it online!

You can save 44 bytes by returning an Object instead of printing directly: y->c->y<1818?0:y>1818?"Frankenstein's monster":"wretch,monster,creature,demon,devil,fiend,it,vile insect,abhorred monster,fiend,wretched devil,abhorred devil".split(",")[(int)(Math.random()*(c<9?7:5))+(c<9?0:7)]

And you can save 4 more bytes by putting fiend (which is present in both lists) in the middle: y->c->y<1818?0:y>1818?"Frankenstein's monster":"wretch;monster;creature;demon;devil;it;fiend;vile insect;abhorred monster;wretched devil;abhorred devil".split(";")[(int)(Math.random()*(c<10?7:5))+(c<10?0:6)] (207 bytes)

203 bytes. Use IntFunctions instead of Function<Integer> to get it working.

APL (Dyalog Unicode), 189 bytes
m←'monster'
a←'abhorred ',⊢
f←'fiend'
d←'devil'
{⊃⍵=1818:{⊃⌽⍵<10:(?7)⊃'wretch'm'creature' 'demon'd f'it'⋄(?5)⊃'vile insect'(a m)f('wretched ',⊢d)(a d)}⍵⋄{⊃⍵>1818:'frankenstein''s ',⊢m⋄''}⍵}

Try it online!
To test, just append the test case to the last curly bracket like so:
{⊃⍵=1818:{⊃⌽⍵<10:(?7)⊃'wretch'm'creature' 'demon'd f'it'⋄(?5)⊃'vile insect'(a m)f('wretched ',⊢d)(a d)}⍵⋄{⊃⍵>1818:'frankenstein''s ',⊢m⋄''}⍵}1818 10

Huge thanks to @ngn for helping out with the leading whitespace issue.
How it works:
It's worth noting that APL interprets strings as arrays (vectors) of characters, so 'wretch' 'creature' would be interpreted in other languages as [[w,r,e,t,c,h],[c,r,e,a,t,u,r,e]]
These are helper functions:
m←'monster'      #These are pretty self explanatory, variables m, f and d are being set to 'monster', 'fiend' and 'devil respectively.
f←'fiend'
d←'devil'
a←'abhorred ',⊢  # a is being set to 'abhorred ' concatenated with the argument to it's right.

This is the main function, which will be broken in 3 parts for better understanding:
{⊃⍵=1818:{⊃⌽⍵<10:(?7)⊃'wretch'm'creature' 'demon'd f'it'⋄(?5)⊃'vile insect'(a m)f('wretched ',⊢d)(a d)}⍵⋄{⊃⍵>1818:'frankenstein''s ',⊢m⋄''}⍵}

Part 1:
{⊃⍵=1818:{Part2}⍵⋄{Part3}⍵} # First conditional
        :                   # If
 ⊃                          # the first element
  ⍵                         # of the argument ⍵
   =1818                    # Equals the literal 1818
         {Part2}⍵           # Executes part 2 with argument ⍵
                 ⋄          # Else
                  {Part3}⍵  # Executes part 3 with argument ⍵

Part 2:
{⊃⌽⍵<10:(?7)⊃'wretch'm'creature' 'demon'd f'it'⋄ # Second conditional
(?5)⊃'vile insect'(a m)f('wretched ',⊢d)(a d)}⍵
       :                                         # If
 ⊃                                               # the first element
  ⌽                                              # of the inverse
   ⍵                                             # of the argument ⍵
    <10                                          # is less than 10
           ⊃                                     # pick the nth
       (?7)                                      # random element between [1,7]
            'wretch'm'creature' 'demon'd f'it'   # from this string array
                                              ⋄  # Else
    ⊃                                            # pick the nth
(?5)                                             # random element between [1,5]
     'vile insect'(a m)f('wretched ',⊢d)(a d)    # from this string array
                                             }⍵  # using argument ⍵

Part 3:
{⊃⍵>1818:'frankenstein''s ',⊢m⋄''}⍵ # Third conditional
        :                           # If
 ⊃                                  # the first element
  ⍵                                 # of the argument ⍵
   >1818                            # is greater than 1818
         'frankenstein''s ',⊢m      # print the string "frankenstein's" concatenated with m (which prints monster)
                              ⋄     # else
                               ''   # print an empty string
                                 }⍵ # with argument ⍵

PHP, 184 176 bytes
<?=strtr([0,1,2,Creature,Demon,It,Fiend,30,31,"2ed 1","Vile Insect","Frankenstein´s 0"][[rand(6*$x=$argv[2]>9,6+4*$x),11][$argv[1]<=>1818]],[Monster,Devil,Wretch,"Abhorred "]);

Run with -n and give year and chapter as command line arguments or try it online.
index and thus result evaluate to NULL for year<1818, leading to empty output.

What does $argv[1]<=>1818 do? I've never ever seen that.

@YUNOWORK https://stackoverflow.com/questions/3737139/reference-what-does-this-symbol-mean-in-php/31298778#31298778

Javascript (ES6), 205 bytes
a="abhorred ",d="devil",f="fiend",m="monster"
y=>c=>y<1818?0:y>1818?"frankenstein's "+m:(l=c<10?[f,"wretch",m,"creature","demon",d,f,"it"]:["vile insect",a+m,f,"wretched "+d,a+d])[0|Math.random()*l.length]

Returns 0 if the year is less than 1818

a="abhorred ",d="devil",f="fiend",m="monster"
n=y=>c=>y<1818?0:y>1818?"frankenstein's "+m:(l=c<10?[f,"wretch",m,"creature","demon",d,f,"it"]:["vile insect",a+m,f,"wretched "+d,a+d])[0|Math.random()*l.length]

<input id=y type=number value=1817 /><input id=c type=number value=10 />

0

C, 380 BYTES
void ok(int *year, int* chapter){char*below_10[] = {"wretch", "monster", "creature", "demon", "devil", "fiend", "it"}; char*at_10[] = {"vile insect", "abhorred monster", "fiend", "wretched devil", "abhorred devil"}; year < 1818?printf("0"):(year == 1818?(chapter<10 printf("%s",below_10[rand()%8]):printf("%s",at_10[rand()%7])):printf("Frankenstein's Monster"));}

Hi, welcome to PPCG! In a code-golf challenge the goal is to have as few bytes as possible. So method/variable names are best as single characters. In addition, you can remove all unnecessary spaces and new-lines, and use the "Frankenstein's Monster" directly instead of making a variable for it. Also, where is the year and chapter coming from now? I don't see it as parameters of the method. Tips for golfing in  and Tips for golfing in C might be useful. Enjoy your stay! :)

No problem. And you can golf a bit more: void o(int y,int c){char*b[]={"wretch","monster","creature","demon","devil","fiend","it"},*a[]={"vile insect","abhorred monster","fiend","wretched devil","abhorred devil"};printf("%s",y<1818?0:y==1818?c>9?a[rand()%6]:b[rand()%7]:"Frankenstein's Monster");} 256 bytes Try it here! (I removed all unnecessary spaces, renamed method/variables/parameters to single letter; removed some unnecessary parenthesis at the ternary-if; single printf; changed <10 to >9; etc.) Not sure why rand() isn't working in TIO.. :S

234 bytes

Javascript 199 bytes

M="monster"
A=(y,c)=>y<1818?"":y^1818?"Frankenstein's "+M:[W="wretch",M,"creature","demon",D="devil",F="fiend","it","vile insect",(H="abhorred ")+M,F,W+"ed "+F,H+D][Math.random()*(c>9?5:7)+7*(c>9)|0]

console.log(A(1700,1))
console.log(A(1700,12))
console.log(A(1817,10))
console.log(A(1818,1))
console.log(A(1818,9))
console.log(A(1818,10))
console.log(A(1818,11))
console.log(A(1819,1))
console.log(A(1819,18))
console.log(A(2017,24))

MBASIC, 288 bytes
1 DIM R$(12):FOR I=1 TO 12:READ R$(I):NEXT:INPUT Y,C:IF Y<1818 THEN 5
2 IF Y>1818 THEN O$="Frankenstein's Monster":GOTO 5
3 IF C>9 THEN O=7
4 O$=R$(O+INT(RND(1)*N+1))
5 PRINT O$:DATA wretch,monster,creature,demon,devil,fiend,it,vile insect,abhorred monster,fiend,wretched devil,abhorred devil

05AB1E, 114 110 bytes
0…ë¢¼–±¹.•ʒ¦Ë"ìËM₂G¶тá≠•ì#.•1ÏiT¥Ƶʒ“T¡Äg… 5ÀΘO¼™Ãí?ιË%4₄‡‡λYιi¾н••Jtm•17в£‚…'s 'ì³R7£R’¡¬ÿÿ±¹’¸¸)sŽ7X.S>èsT@èΩ

Outputs 0 when the year is below 1818.
Try it online or verify all test cases.
Explanation:
0                    # Push a 0
…ë¢¼–±¹              # Push dictionary string "creature devil monster"
 .•ʒ¦Ë"ìËM₂G¶тá≠•   "# Push compressed string "demon fiend it wretch "
  ì                  # Prepend it: "demon fiend it wretch creature devil monster"
   #                 # Split by spaces: ["demon","fiend","it","wretch","creature","devil","monster"]
.•1ÏiT¥Ƶʒ“T¡Äg… 5ÀΘO¼™Ãí?ιË%4₄‡‡λYιi¾н•
                     # Push compressed string "abhorred devilabhorred monsterfiendvile insectwretched devil"
 •Jtm•               # Push compressed integer 1249548
      17в            # Converted to Base-17 as list: [14,16,5,11,14]
         £           # Split the string into parts of that size: ["abhorred devil","abhorred monster","fiend","vile insect","wretched devil"]
‚                    # Pair both string-lists together
…'s                 '# Push string "'s "
   'ì³              '# Push dictionary string "liechtenstein"
      R7£R           # Leave the last 7 characters: "enstein"
          ’¡¬ÿÿ±¹’   # Push dictionary string "frankÿÿmonster", where the "ÿ" are automatically
                     # replaced with the strings at the top of the stack: "frankenstein's monster"
                  ¸¸ # Wrap it twice into a list: [["frankenstein's monster"]]
)                    # Wrap everything on the stack into a list
                     # (We now have: [0,[["demon","fiend","it","wretch","creature","devil","monster"],["abhorred devil","abhorred monster","fiend","vile insect","wretched devil"]],[["frankenstein's monster"]]])
 s                   # Swap to get the first (implicit) input
  Ž7X                # Push compressed integer 1818
     .S              # Compare it with the input (-1 if below; 0 if equal; 1 if above)
       >             # Increase it by 1 (0 if below; 1 if equal; 2 if above)
        è            # Use it to index into the list
         s           # Swap to get the second (implicit) input
          T@         # Check if it's larger than or equal to 10 (results in 0 for falsey; 1 for truthy)
            è        # Use it to index into the inner list
             Ω       # And finally get a random value from that list (which is output implicitly)

See this 05AB1E tip of mine (sections How to use the dictionary?; How to compress strings not part of the dictionary?; How to compress large integers?; and How to compress integer lists?) to understand why:

…ë¢¼–±¹ is "creature devil monster";
.•ʒ¦Ë"ìËM₂G¶тá≠• is "demon fiend it wretch ";
.•1ÏiT¥Ƶʒ“T¡Äg… 5ÀΘO¼™Ãí?ιË%4₄‡‡λYιi¾н• is "abhorred devilabhorred monsterfiendvile insectwretched devil";
•Jtm• is 1249548 and •Jtm•17в is [14,16,5,11,14];
'ì³ is "liechtenstein ";
’¡¬ÿÿ±¹’ is "frankÿÿmonster";
Ž7X is 1818.

JavaScript, 194 B
e=Math.random,f=Math.floor;x=(a,b,c=`insect,monster,wretch,creature,demon,devil,fiend,it`.split`,`,d=[`vile `,`abhorred `])=>a<1818||a-1818?`Frankenstein's `+c[1]:(b<10||c[f(e()*2)])+c[f(e()*8)]

doesnt really match the test cases