text:
From Plate to State
This is essentially the inverse of Generate a US License Plate
Challenge: Given a string that matches one of the below license plate formats, output all possible states that match that formatting. In the below table 0 stands for a single digit 0 through 9 inclusive, and A stands for a single letter A through Z inclusive. For the purposes of this challenge, we're ignoring states with complex format rules (like Delaware, which has variable number of digits), and ignoring removal of look-alike letters (e.g., I and 1).
AAA 000: AK, IA, MS, MP, VT
0000: AS
AAA0000: AZ, GA, WA
000 AAA: AR, KS, KY, LA, ND, OR
0AAA000: CA
AA-00000: CT
AA-0000: DC
AAA A00: FL
AA 00000: IL
000A,000AA,000AAA,AAA000: IN
0AA0000: MD
AAA 0000,0AA A00,AAA 000: MI
000-AAA: MN
00A-000: NV
000 0000: NH
A00-AAA: NJ
000-AAA,AAA-000: NM
AAA-0000: NY, NC, PA, TX, VA, WI
AAA 0000: OH
000AAA: OK
AAA-000: PR
000-000: RI
AAA 000,000 0AA: SC
A00-00A: TN
A00 0AA: UT

Examples:
B32 9AG
[UT]

1YUC037
[CA]

285 LOR
[AR, KS, KY, LA, ND, OR] (in any order)

285-LOR
[MN, NM] (in any order)

285LOR
[IN, OK] (in any order)

Rules and Clarifications

The input string is guaranteed non-empty, and guaranteed to be of one of the above formats
Behavior if given a format other than the above is undefined
Input and output can be given by any convenient method
You can print the result to STDOUT or return it as a function result
Either a full program or a function are acceptable
Standard loopholes are forbidden
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins

JavaScript (ES6),  203 202 201  200 bytes
Saved 1 byte thanks to @NahuelFouilleul
s=>'xMiAZGAWaMIOhNvInxMNNmARKSKYLANDOrNMPrAKIAMIMSMPSCVtAsMdxScRiNhUtDcCtxFlxNYNCPATXVAWiInIlINOkNjCaTn'.match(/[A-Z]*./g)[s.replace(/./g,c=>c<'!'?0:1/c?9:6-~(c+1))*3%47%30].toUpperCase().match(/../g)

Try it online!
How?
Input conversion
We turn the input string into an integer \$n\$ by applying the following substitutions:

spaces are replaced with \$0\$
digits are replaced with \$9\$
letters are replaced with \$7\$
hyphens are replaced with \$6\$

As JS code:
c < '!' ?        // if c is a space:
  0              //   replace it with 0
:                // else:
  1 / c ?        //   if c is a digit:
    9            //     replace it with 9
  :              //   else:
    6 - ~(c + 1) //     if c is a hyphen, this gives:
                 //       6 - ~('-1') --> 6 - 0 --> 6
                 //     if c is a letter (e.g. 'A'), this gives:
                 //       6 - ~('A1') --> 6 - ~NaN --> 6 - (-1) --> 7

Hash function
We then apply the following hash function:
$$f(n) = ((3\times n) \bmod 47) \bmod 30$$
This gives a unique ID in \$[1..29]\$. There's actually a collision between 000AA and AAA000 which both result in \$24\$, but that's perfectly fine as these plate formats are used in Indiana exclusively.
 format     | n        | * 3       | mod 47 | mod 30 | states
------------+----------+-----------+--------+--------+----------------------
  'AAA 000' |  7770999 |  23312997 |   10   |   10   | AK,IA,MI,MS,MP,SC,VT
     '0000' |     9999 |     29997 |   11   |   11   | AS
  'AAA0000' |  7779999 |  23339997 |   32   |    2   | AZ,GA,WA
  '000 AAA' |  9990777 |  29972331 |    8   |    8   | AR,KS,KY,LA,ND,OR
  '0AAA000' |  9777999 |  29333997 |   28   |   28   | CA
 'AA-00000' | 77699999 | 233099997 |   19   |   19   | CT
  'AA-0000' |  7769999 |  23309997 |   18   |   18   | DC
  'AAA A00' |  7770799 |  23312397 |   21   |   21   | FL
 'AA 00000' | 77099999 | 231299997 |   25   |   25   | IL
     '000A' |     9997 |     29991 |    5   |    5   | IN
    '000AA' |    99977 |    299931 |   24   |   24   | IN
   '000AAA' |   999777 |   2999331 |   26   |   26   | IN,OK
   'AAA000' |   777999 |   2333997 |   24   |   24   | IN
  '0AA0000' |  9779999 |  29339997 |   12   |   12   | MD
 'AAA 0000' | 77709999 | 233129997 |   33   |    3   | MI,OH
  '0AA A00' |  9770799 |  29312397 |    1   |    1   | MI
  '000-AAA' |  9996777 |  29990331 |    7   |    7   | MN,NM
  '00A-000' |  9976999 |  29930997 |   34   |    4   | NV
 '000 0000' | 99909999 | 299729997 |   46   |   16   | NH
  'A00-AAA' |  7996777 |  23990331 |   27   |   27   | NJ
  'AAA-000' |  7776999 |  23330997 |    9   |    9   | NM,PR
 'AAA-0000' | 77769999 | 233309997 |   23   |   23   | NY,NC,PA,TX,VA,WI
  '000-000' |  9996999 |  29990997 |   15   |   15   | RI
  '000 0AA' |  9990977 |  29972931 |   44   |   14   | SC
  'A00-00A' |  7996997 |  23990991 |   29   |   29   | TN
  'A00 0AA' |  7990977 |  23972931 |   17   |   17   | UT

State encoding
All state patterns are joined together into a single string, with each pattern ending with a lower case letter. Empty slots are filled with an arbitrary x.
[ [], [ 'MI' ], [ 'AZ', 'GA', 'WA' ], [ 'MI', 'OH' ], ... ] --> 'xMiAZGAWaMIOh...'

We split them back into an array of strings with match(/[A-Z]*./g) and pick the correct one according to \$f(n)\$.
Finally, the pattern itself is converted to full upper case and split into groups of 2 characters.

I love how you always come up with such an elegant mathematical solution to a string-related problem. :)

D'oh! I'm not having a good day today, am I?!

Very clever method! The two plate formats that collide are Indiana, not Illinois.

[A-Z]*. instead of .*?[a-z] should save one byte

@NahuelFouilleul I've done that mistake before... Thanks!

T-SQL, 475 bytes
SELECT STUFF(value,1,8,'')
FROM STRING_SPLIT('000 0000NH|000 055 SC|000 555 AR,KS,KY,LA,ND,OR|0000    AS|000-000 RI|0005    IN|00055   IN|000555  IN,OK|000-555 MN,NM|005-000 NV|055 500 MI|0550000 MD|0555000 CA|500 055 UT|500-005 TN|500-555 NJ|55 00000IL|55-0000 DC|55-00000CT|555 000 AK,IA,MI,MS,MP,SC,VT|555 0000MI,OH|555 500 FL|555000  IN|555-000 NM,PR|5550000 AZ,GA,WA|555-0000NY,NC,PA,TX,VA,WI','|')
,i WHERE v LIKE TRIM(REPLACE(REPLACE(LEFT(value,8),5,'[A-Z]'),0,'[0-9]'))

Line breaks are for readability only.
Limited to SQL 2017 or higher by use of the TRIM function. SQL 2016 (required for STRING_SPLIT), is possibly by substituting RTRIM at the cost of 1 byte.
Input is taken via pre-existing table \$i\$ with varchar field \$v\$, per our IO rules
I'm basically doing a reverse LIKE match: I expand the pattern of each plate to a full wildcard pattern matching string like '[A-Z][0-9][0-9] [0-9][A-Z][A-Z]', then compare to the input value, and return the matching states (which is combined into a single field).
Might be able to save some more space by GZIP'ing the lengthy string; I'll see if that helps...

Charcoal, 177 bytes
§⪪”}∧▶⧴βμÞ∕×peＨ✂d‽n➙ＭR⁶↙↷◨5⁶;πＮM﹪θＷ:¡✂⧴O^(P↷kⅉχＲ⁺≔º↶∨§º⊞Ｂ⎚×p↔Ｌ\`²‖6'⁶⁹‴XüR⦃N4U⊙ＹＦ⁻ＺＭχLＳ⁸ＣX\hγ”;⌕⪪”{⊟“◨⦄»Ｕ>⌕⁻9“]±R▷Ｑ↔θü&$▷l⁹Ｚ⁼¡⁷×À›¶aA*βＺ³δ¡⟲²Y«№⌕TμN»πX·ＳΣ"εl⊙=3✂S?Ｋ”;⭆Ｓ⎇№αιA⎇Σι⁰ι

Try it online! Link is to verbose version of code. Explanation:
                 Ｓ              Input string
                ⭆               Map over characters and join
                  ⎇             If
                     ι          Current character
                   №α           Is an uppercase letter
                      A         Then literal string `A`
                       ⎇        Else if
                         ι      Current character
                        Σ       Is non-zero
                          ⁰     Then digit `0`
                           ι    Else original character
        ⌕                       Find index in
          ”...”                 Compressed string of plates
         ⪪     ;                Split on semicolons
§                               Index into
  ”...”                         Compressed string of states
 ⪪     ;                        Split on semicolons
                                Implicitly print

Try all test cases! Link is to verbose version of code. (Slightly different code needed to process multiple cases.)
Unsurprisingly a port of @Arnauld's solution is much shorter at only 121 bytes:
§⪪”}∧↨¦↑↧‴q⁰mπi3ＪE⪫³yＳ⪪c)？0≦·ê⊞Þ«ⅉ⁺&±<pAＲιaγ1A↑1L¶⟧/)Vº;Π∧,b✂≦¤ⅉαX⊕|″IνB[w∕¦Ｈ´Gγ§ν⟲^π!⪪¶ςbFü⊟»2”;﹪×³Ｉ⭆Ｓ⎇№αι⁷⎇⁼ι ⁰⎇⁼ι-⁶9⁴⁷

Try it online! Link is to verbose version of code. The second modulo by 30 is implicit in the indexing into the array.

Perl 5 (-p), 165 bytes
Port of @Arnauld's Javascript answer, also upvote him.

y/0-8/9/;y/- A-Z/607/;$_=('xMiAZGAWaMIOhNvInxMNNmARKSKYLANDOrNMPrAKIAMIMSMPSCVtAsMdxScRiNhUtDcCtxFlxNYNCPATXVAWiInIlINOkNjCaTn'=~/[A-Z]*./g)[$_*3%47%30];s/../\U$& /g

Try it online!

Python 3, 382 378 bytes
import re;f=lambda p,l='[A-Z]',r=re.sub,f=re.findall:f(l+'{2}',f(r(l,'1',r('[0-9]','0',p))+l+'+','0000AS0001IN00011IN000111INOK111000IN000 011SC000 111ARKSKYLANDOR000-000RI000-111MNNM001-000NV011 100MI0110000MD0111000CA100-001TN100-111NJ11-0000DC111 100FL111 000AKIAMIMSMPSCVT111-000NMPR1110000AZGAWA11 00000IL11-00000CT111 0000MIOH111-0000NYNCPATXVAWI1100 011UT000 0000NH')[0])

Try it online!
Replaces numbers with 0 and letters with 1, then searches the string for the plate followed by a string of letters. Then it simply returns every non-overlapping pair of letters in that string.
Not the most byte efficient, but a good start (maybe).
I enjoy challenges based on information that can't just be generated.

05AB1E, 176 bytes
•1–ºʒÉQ÷¦PαN]lā?¨ìÎ₆™@ΔîÅλEŸʒ»ú<Å§a–½ã…ôkƒ¼½Ü%-ò∊aÍÙ•44374в4вε©gIgQi…'-Q'd'a„ðQ)VIεY®Nèè.V}Pë0].•=#îYn«ÈO4êʒIWj∊bÛˆ_ãZÑ"yŠótм‰иÔN–HδÖc°ìSJ9Ç\}ζÎäǝÑïÒ∞V.÷ζkÚ"¿Õнα£!ÉªB…žä•#sÏ`2ô

Try it online!
•1–ºʒÉQ÷¦PαN]lā?¨ìÎ₆™@ΔîÅλEŸʒ»ú<Å§a–½ã…ôkƒ¼½Ü%-ò∊aÍÙ•44374в4в
                        push all patterns as base 4 integers (0="-", 1=number, 2=letter, 3=" ")

ε                       for each pattern
  ©                       copy it for later use inside another for for-loop
  gIgQi                   if it has the same length, as input
    …'-Q'd'a„ðQ)V           store ["'-Q", "d", "a", "ðQ"] in Y (05AB1E codes for "equals '-', is positive, is letter and equals ' ')
    Iε                      for each letter of input
      Y®Nèè                   get the 05AB1E code corresponding to the current index of the pattern
      .V                      run it
    }
    P                       check if all positions of that pattern were true
  ë                       else
    0                       push false
]

.•=#îYn«ÈO4êʒIWj∊bÛˆ_ãZÑ"yŠótм‰иÔN–HδÖc°ìSJ9Ç\}ζÎäǝÑïÒ∞V.÷ζkÚ"¿Õнα£!ÉªB…žä•#
                        push list of states matching the pattern

sÏ                      get the entry of that list, that is true in the other list
`2ô                        split into groups of 2 letters and print


text:
CUT OUT HEXAGONS
Write a full program or a function taking an unsigned integer number N and doing this cut out work:

Cut out a hollow hexagon 'donut' shape with side B-C equal to 2N times '/'
Translate the piece above by 3 lines.
Repeat the job N times (from the piece obtained) decrementing by 2 '/' side B-C , until smallest hexagon (2 times '/').

This is the smallest hexagon which will be cut out last:
    side B-C     C____D
    is 2'/' ->   /    \
               B/      \
 side  C-D      \      /
is 4'_'          \____/
                A

Test cases:
N = 0 may output a blank sheet (nothing), but you don't heave to handle it.
N = 1:
  ____
 /    \
/      \
\      /
 \____/
/      \
\      /
 \____/

N = 3:
          ____
        _/    \_
      _//      \\_
     // \      / \\
    //   \____/   \\
   //   /______\   \\
  / \   \      /   / \
 /   \   \____/   /   \
/   / \          / \   \
\   \  \________/  /   /
 \   \            /   /
/ \   \          /   / \
\  \   \________/   /  /
 \  \              /  /
  \  \____________/  /
   \                /
    \              /
     \____________/

N = 8:
                              ____
                            _/    \_
                          _//      \\_
                        _// \      / \\_
                      _///   \____/   \\\_
                    _////   /______\   \\\\_
                  _//// \   \______/   / \\\\_
                _/////   \   \____/   /   \\\\\_
               //////   /_\          /_\   \\\\\\
              ///// \   \__\________/__/   / \\\\\
             /////   \   \____________/   /   \\\\\
            /////   / \   \          /   / \   \\\\\
           //// \   \  \   \________/   /  /   / \\\\
          ////   \   \  \              /  /   /   \\\\
         ////   / \   \  \____________/  /   / \   \\\\
        /// \   \  \   \                /   /  /   / \\\
       ///   \   \  \   \              /   /  /   /   \\\
      ///   / \   \  \   \____________/   /  /   / \   \\\
     // \   \  \   \  \                  /  /   /  /   / \\
    //   \   \  \   \  \________________/  /   /  /   /   \\
   //   / \   \  \   \                    /   /  /   / \   \\
  / \   \  \   \  \   \                  /   /  /   /  /   / \
 /   \   \  \   \  \   \________________/   /  /   /  /   /   \
/   / \   \  \   \  \                      /  /   /  /   / \   \
\   \  \   \  \   \  \____________________/  /   /  /   /  /   /
 \   \  \   \  \   \                        /   /  /   /  /   /
/ \   \  \   \  \   \                      /   /  /   /  /   / \
\  \   \  \   \  \   \____________________/   /  /   /  /   /  /
 \  \   \  \   \  \                          /  /   /  /   /  /
  \  \   \  \   \  \________________________/  /   /  /   /  /
   \  \   \  \   \                            /   /  /   /  /
    \  \   \  \   \                          /   /  /   /  /
     \  \   \  \   \________________________/   /  /   /  /
      \  \   \  \                              /  /   /  /
       \  \   \  \____________________________/  /   /  /
        \  \   \                                /   /  /
         \  \   \                              /   /  /
          \  \   \____________________________/   /  /
           \  \                                  /  /
            \  \________________________________/  /
             \                                    /
              \                                  /
               \________________________________/

Rules:
 - Margins are not specified.
 - Standard loopholes are forbidden.
 - Standard input/output methods.
 - Shortest answer in bytes wins.
Sandbox : https://codegolf.meta.stackexchange.com/a/18143/84844

For n=3, it looks like you decrement it and then raise it one line, but I don't see that specified in the directions...Also where is the strip across the center coming from in the bottom twin of the smallest two?

@Jonah they are raised by 3 lines, I think you refer to the line you see just below the smallest one, if so it is a line of the biggest piece in background. I removed the diagonal strip because it was misleading.

Try it online!  maybe I am wrong but it looks like this to me..

Close, yet so far away.. Let's just say I'm using translucent paper.. xD Will continue when I have some more time, after I've figured out a rule to determine which parts are/aren't displayed in the final result to overwrite them with spaces.

@Arnauld the shapes are stacked "donut"-ish hexagons, so the outer part is opaque and inner - transparent (with the exception of the bottom one)

Suggested test case: n=8. Contains multiple lines both inside and below the top 'donut'. Here the output of my WIP attempt again to see the lines when everything is translucent.

@Kevin Cruijssen can you add this n=8 test case please?

@AZTECCO Done :)

Charcoal, 80 bytes
Ｆ⮌…·¹Ｎ«→↘Ｆ²«Ｍ⁺³×⁴ι↑Ｐ×_⊗ι↙Ｆ⊗ι«ＦκＰ× ⁴↙¹»→Ｆι«ＦκＰ× ⁴↘¹»Ｆ⊖ι«ＦκＰ× ⁻×³ιλ↘¹»\Ｐ×_⊗ι»»‖ＢＯ²

Try it online! Link is to verbose version of code. Explanation:
Ｆ⮌…·¹Ｎ«

Loop from the largest to the smallest hexagon.
→↘Ｆ²«Ｍ⁺³×⁴ι↑

Draw each hexagon twice in the desired location.
Ｐ×_⊗ι

Draw half of the top line of the hexagon.
↙Ｆ⊗ι«ＦκＰ× ⁴↙¹»

Draw the top left diagonal, but for each row erase 4 spaces first if this is the second hexagon.
→Ｆι«ＦκＰ× ⁴↘¹»

Draw half of the bottom left diagonal, still erasing 4 spaces first if this is the second hexagon.
Ｆ⊖ι«ＦκＰ× ⁻×³ιλ↘¹»

Draw almost all of the rest of the bottom left diagonal, erasing until the middle of the hexagon if this is the second hexagon.
\Ｐ×_⊗ι

Finish the bottom left diagonal and draw half of the bottom line of the hexagon.
»»‖ＢＯ²

Mirror everything at the end.
Alternative approach, also 80 bytes:
Ｆ⮌…·¹Ｎ«→↘Ｆ²«Ｍ⁺³×⁴ι↑ＦκＧ→⊗ι↓³←⊖⊗ι↙⊖⊗ι↘⊖⊗ι→⊖⊗ι↓³←⊗ι↖⊕⊗ι↗⊕⊗ι Ｐ×_⊗ι↙↙⊗ι→↘⊗ι↑Ｐ×_⊗ι»»‖Ｍ

Try it online! Link is to verbose version of code. Explanation:
Ｆ⮌…·¹Ｎ«

Loop from the largest to the smallest hexagon.
→↘Ｆ²«Ｍ⁺³×⁴ι↑

Draw each hexagon twice in the desired location.
ＦκＧ→⊗ι↓³←⊖⊗ι↙⊖⊗ι↘⊖⊗ι→⊖⊗ι↓³←⊗ι↖⊕⊗ι↗⊕⊗ι

Before drawing the second hexagon, erase the area between it and the next smaller hexagon.
Ｐ×_⊗ι↙↙⊗ι→↘⊗ι↑Ｐ×_⊗ι»»‖Ｍ

Draw the left half of each hexagon, and then mirror everything at the end.

Canvas, 113 112 bytes
«/＊α_×－／═↔⁸３＋ ＊－╶Ｒ⇵｛；Ｘ：«ｗ╷/###/＊Ｋｋｙ┤_×＋－ｙ#×/×－ｙ_×－／═ŗ∙ #⟳#¶#╋# ⟳_╋↔ｘ“kｙv╴e┌/ｉ┴⁰U＜ａlisｓfr↖；,ｉmＦE！↷qB╪²－‟＃ŗ｝#∙ ╋↔║

Try it here!
A part of the answer is literally evaluating the JavaScript p.p.overlap(p.p,0,p.p,(a,b)=>b==0?a:b)..

I was wondering where the evaluation would be useful. Pretty cool!

C (clang), 374 bytes
#define F(X,R)*d=*(d=o+x*(l*3+35-g)+x/2+X+R)-32?*d:R?
i,z,x,l,w,r,g,m;f(n){int*d,o[i=z=(x=n*8+1)*(n*5+4)],*c=o;for(;l=i--;)*c++=i%x?32:10;for(;l++<n;)for(g=35;i=g-29;g-=3){for(r=m+=m=w=l*2;r--;F(~-w*x-w,r)g:g)F(w*~x,r)95:95,F(w*x-w,r)95:95;for(;w--;)for(r=4;r--;F(m-~w*~-x,-r)g:47)F(w-m-w*x,r)g:47,F(w-m-~w*x,r)g:92,F(m+~w-w*x,-r)g:92;}for(;i<z;++i)printf(o[i]-35?o+i:" ");}

Try it online!
-33 more saved by @ceilingcat improvement
C (clang),   433 412   407 bytes
#define F(Y,X,W,R)*d=*(d=c-Y+X+W+R)-32?*d:R?
i,z,x,l,w,r,d,G,g,m;f(n){int*c,*d,o[i=z=(x=n*8+1)*(n*5+4)];for(c=o;l=i--;)*c++=i%x?32:10;for(;l++<n;)for(G=0;i=G<4;G+=3){g=35-G;c=o+x*l*3+G*x+x/2;for(r=m+=m=w=l*2;r--;F(x-w*x,-w,0,r)g:g)F(w*x,-w,0,r)95:95,F(-w*x,-w,0,r)95:95;for(;w--;)for(r=4;r--;F(~w*x,m,~w,-r)g:47)F(w*x,-m,w,r)g:47,F(~w*x,-m,w,r)g:92,F(w*x,m,~w,-r)g:92;}for(;i<z;)i+=printf(o[i]-35?o+i:" ");}

Try it online!
-21 thanks to @ceilingcat
-5 @ceilingcat + y removed
   ###\
    ###\   <= we  draw only on spaces ' '
\###
 \###        first time we draw '#' for collisions

 /####\
/######\
\######/
 \####/

  ____
 /####\        then we move our drawing pointer
/######\     3 lines below
\######/
 \____/         and we draw spaces
/      \       instead of #
\      /
 \____/

      ____
    _/####\
   //######\     and we repeat for bigger donuts
  /#\######/   moving our drawing pointer
 /###\____/
/###/      \
\###\      /
 \###\____/
  \####??####/
   \________/

source: Stack Exchange

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

sort: votes


text:
Fill a bowl with alphabet soup
We seem to never get tired of alphabet-related challenges...

The recipe
Given

a string of letters S, and
two positive integers M, N,

produce an alphabet soup with the letters of S occupying random positions in a rectangular bowl of size M×N, framed by a non-alphabetic, non-space character to represent the rim of the bowl.
Positions not used by letters should be displayed as spaces. See the examples below.
Aditional rules

The size M×N refers to the interior of the bowl. The size including the rim is M+2×N+2.
Each character from S should appear once in the bowl, in a different position; that is, one character cannot overwrite another.
S may contain duplicates. For instance, if S is the string 'abcc', the soup must contain one a, one b, and two c (all in different positions).
The inputs will satisfy the restrictions M >= 1, N >= 1, 1 <= length(S) <= M*N.
The rim of the bowl can be any non-alphabetic, non-space character, consistent across program runs and input values.
Letter positions in the bowl are random, so the result may differ every time the program is run with the same inputs.
Given the input, every possible set of letter positions should have a non-zero probability. Since this cannot be checked from a few realizations of the program, please explain how your code fulfills this.
Leading or trailing whitespace around the rim is allowed.
S will contain are only uppercase letters. If wou wish, you can choose to take only lowercase letters.
Input and output are flexible as usual. For example, the output can be a string with newlines, a 2D character array, or a list of lines.
Programs or functions are allowed, in any programming language. Standard loopholes are forbidden.
The shortest code in bytes wins.

Examples
Inputs are shown as S, [M N], where M is number of rows and N is number of columns. The character # is used for the rim.
'O', [1 1]:

###
#O#
###

'HEY', [1 3]:

#####
#YHE#
#####

'HELLO', [4 11]:

#############
#  O        #
#         H #
#    LE     #
#   L       #
#############

'ADVNJSGHETILMVXERTYIOJKCVNCSF', [8 12]:

##############
#K  V  L   S #
# A   V  X H #
#T    M C    #
# I       O N#
#  YC        #
# G  I   R SE#
#   J      F #
#JT  D  V EN #
##############

'OOOOOOOOOOXXXXX', [13 31]:

#################################
#    X                          #
#                O              #
#                               #
#                  X            #
#                        O      #
#             X           O     #
#      O                        #
#         X                     #
#                        O      #
#       X                       #
#                    O          #
#  O      O      O              #
#                             O #
#################################

'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ', [11 41]

###########################################
#                                       JU#
#     Q         C M    G     R T U Y  H   #
#  KI          E   H    M   YO            #
#      V BW        I    JC                #
#     SV           D     P   B          U #
#           A     F    RF   J  KP E       #
#            E   N      TH        Z       #
#    N  BM  O     Q   I        AS N  WX   #
#   S     O  K       G L       P       Q  #
#Z     L T         R   L       A      F DD#
#      V   Y           WX   C       G XZ  #
###########################################

Loosely related

"Letter positions in the bowl are random, [...]" <-- do you mean can be random or must be random? And can all lines have the same number of chars, all the time?

@IsmaelMiguel Must. And every configuration must have a nonzero probability of occurring (stated in the challenge). So that rules out the -always-same-length approach

Can the rim be consistent across program runs and input values, but use multiple non-letters, e.g. drawing an ASCII art border with |+-?

@Adám Hm I’m going to say no, that’s too big a change

05AB1E, 20 18 16 15 14 bytes
*j.rS²ô2Føε8.ø

Takes three inputs in the order: height, width, string. Output as a 2D list of characters.
Uses 8 as border, but could be any digit.
-1 byte thanks to @Grimy.
Try it online or verify all test cases. (TIO contains }}J» in the footer to pretty-print the result; feel free to remove it to see the actual output 2D list of characters instead.)
Explanation:
*               # Multiply the (implicit) width and height inputs
 j              # Pad the (implicit) input-string with up to that amount of leading spaces,
                # so the total string-length is equal to that value
  .r            # Shuffle the characters in the string
    S           # Convert the string to a list of characters
                # (edge-case for the zip below with strings of size 1 with 1x1 dimensions)
     ²          # Push the width input again
      ô         # Split the list of characters into parts of that size
       2F       # Loop 2 times:
         ø      #  Zip/transpose the 2D list; swapping rows/columns
          ε     #  Inner map over each line:
           8.ø  #   And surround this line-list with a leading/trailing "8"
                # (after the loop, the result is output implicitly)

@LuisMendo I actually just say the challenge 3 minutes ago. ;) It's a pretty straight-forward implementation. Will try to golf it down from here.

Very nice, I didn't think about *j! Here's 13 for legacy, or an ugly 14 for modern (outputs a 2D character array).

@Grimy The 13-byter seems to fail for input 1,1,"O", so I think it has to be the 14-byter for the legacy as well. Thanks for -1 though.

APL (Dyalog Unicode), 25 bytesSBCS
'#',∘⌽∘⍉⍣4{⍵⍴⊃¨↓∘⍺¨?⍨×/⍵}

Try it online!
-22 thanks to @ngn, -7 thanks to @ngn and @Adám
Explanation:
'#',∘⌽∘⍉⍣4{⍵⍴⊃¨↓∘⍺¨?⍨×/⍵}
          {            ⍵} ⍝ Function that generates the content
                          ⍝  argument: ⍵ (width and height), ⍺ (string)
                     ×/   ⍝ get the product
                   ?⍨     ⍝ For each randomized elements
               ↓∘⍺¨       ⍝ take the character in ⍺
           ⍵⍴⊃¨           ⍝ turn it back into a matrix of shape ⍵
    ∘ ∘ ⍣4                ⍝ Then, 4 times, do these 3 things:
'#',                      ⍝ - prepend a # to the axis
     ⌽                    ⍝ - reverse the columns
       ⍉                  ⍝ - swap columns and lines

APL (Dyalog Extended), 21 bytesSBCS
The rim's angles are different characters
{⌂disp⊂⍵⍴⊃¨↓∘⍺¨?⍨×/⍵}

Try it online!
Using the dfn to display the box.

29: '#',∘⌽∘⍉⍣4⊢⍴∘(?⍨∘≢⊃¨⊂)↑⍨∘(×/) Try it online!

28: {'#',∘⌽∘⍉⍣4⊢⍵⍴⍺\⍨(≢⍺)>?⍨×/⍵} (or ≥ instead of > if ⎕io=1)

actually, 27: '#',∘⌽∘⍉⍣4{⍵⍴⍺\⍨(≢⍺)>?⍨×/⍵}

25: '#',∘⌽∘⍉⍣4{⍵⍴⊃¨↓∘⍺¨?⍨×/⍵}

Regarding the 21

Python 3, 110 bytes
lambda s,m,n,r=['#']:[r+(n*r+[i for i,j in{*zip(s+m*n*' ',range(m*n))}]+n*r)[k*n:-~k*n]+r for k in range(m+2)]

Try it online!
Randomizes by using a set comprehension and returns a 2D character array.

Nice use of set comprehension to randomize. +1. But your codes relies on the name 'f' of the function. Therefore I think the lambda solution isn't valid...

@agtoever Thanks! The function is not recursive, so it can be anonymous. Are you referring to the f'{s:{m*n}}' part? Because that is the syntax for a formatted string, which just coincidentally also happens to start with an f.

This code seems to violate PEP 8 in several ways.

@Christofer-Ohlsson absolutely!

@ChristoferOhlsson Welcome to the world of code-golf, haha. ;) No comments/docs whatsoever; single character variables/methods without any (unnecessary) spaces/newlines; potentially hundreds of compiler-warnings we simply ignore; increasing performance from O(log(N)) to O(N^N); etc. If it can save even a single byte, it's all fine and totally worth it for code-golfing. ;)

@KevinCruijssen oh sure, I was just trying to be funny :)

J, 30 29 bytes
-1 byte thanks to Jonah
'#'|.@|:@,^:4[$*/@[(?~@[{{.)]

Try it online!

Because TIO uses a fixed random seed. 9!:1]6!:9'' fixes that

Really like the way used the zero fill of {..  Slight tweak for 29 '#'|.@|:@,^:4[$*/@[(?~@[{{.)]: Try it online!

Bash + coreutils, 139 125 characters
r=`printf %$3s@@|tr \  @`
echo $r
printf %$[$2*$3]s $1|fold -1|shuf|tr -d \\n|fold -$3|paste -d@ <(:) - <(:)|head -$2
echo $r

Sample run:
bash-5.0$ bash soup.sh HELLO 4 11
@@@@@@@@@@@@@
@  H        @
@      OE   @
@    L      @
@          L@
@@@@@@@@@@@@@

Try it online!
Bash + coreutils + boxes, 97 characters
printf %$[$2*$3]s $1|fold -1|shuf|tr -d \\n|fold -$3|boxes -dsimple -s$[$3+2]x$[$2+2] -pa0 -itext

Sample run:
bash-5.0$ set -- HELLO 4 11

bash-5.0$ printf %$[$2*$3]s $1|fold -1|shuf|tr -d \\n|fold -$3|boxes -dsimple -s$[$3+2]x$[$2+2] -pa0 -itext
*************
* O   L  E  *
*      H    *
*           *
*     L     *
*************

Try it online! (Partially, as boxes is not installed on TIO.)

PowerShell, 163 111 93 bytes
param($w,$h,$s)'#'*$w+-join($s|% *ht($w*$h)|% t*y|sort{Random})+'#'*$w-replace".{$w}",'#$0#
'

Try it online!
Takes input as $width, $height, $string.
Constructs a string of # of the appropriate $width, string-joins that with some computation, and then that same # string again. The computation starts with taking the input $string, and doing a .padRight up to the $width by $height length (i.e., make a string long enough to completely take up the rectangular space. We then convert that string toCharArray, and sort it Randomly. That gives us the mixed-up middle portion. Finally, we -replace it into chunks of equal $width, and surround those chunks with #s.
-52 thanks to inspiration from AZTECCO
-18 bytes thanks to mazzy

You have 2 x random (12) while JS has one, he added spaces to fill M*N size and sorted, after that you still pay 21 for '$' unfortunately

@AZTECCO Thanks for the inspiration!

Thanks @mazzy - very clever with the -replace instead of splitting and joining.

JavaScript (ES7), 125 bytes
Returns a string. Uses 0 as the frame character.
(s,h,w)=>(a=[...s.padEnd(w++*h++)].sort(_=>Math.random()-.5),g=x=>y+~h?(x%w&&y%h&&a.pop())+[`
`[x-w]]+g(x<w?x+1:!++y):a)(y=0)

Try it online!
Commented
(s, h, w) => (               // s = string; h = height; w = width
  a =                        // build an array a[] consisting of:
    [...s.padEnd(w++ * h++)] //   all original characters in s padded with spaces for a
    .sort(_ =>               //   total length of w * h, in a random order
      Math.random() - .5     //   (this is not guaranteed to be uniform, but it is not
    ),                       //   required to be)
  g = x =>                   // g is a recursive function taking x:
    y + ~h ?                 //   if we haven't reached the end of the grid:
      ( x % w &&             //     if we're not located on a vertical border
        y % h &&             //     nor on a horizontal border,
        a.pop()              //     extract the last character from a[]
      ) +                    //     (otherwise, append '0')
      [`\n`[x - w]] +        //     if we've reached the end of the row, append a linefeed
      g(                     //     append the result of a recursive call:
        x < w ? x + 1 : !++y //       using either (x+1, y) or (0, y+1)
      )                      //     end of recursive call
    :                        //   else (end of grid):
      a                      //     a[] is now empty and can be used as an empty string
)(y = 0)                     // initial call to g with x = y = 0

PHP 7.4, 107 99 94 characters
fn($s,$r,$c)=>_.chunk_split(($b=str_pad(_,$c,_)).str_shuffle(str_pad($s,$r*$c)),$c,"_
_").$b._

Thanks to:

Ismael Miguel for reminding me about PHP 7.4's arrow functions (-10 characters)
Night2 for
efficiently reversing the concatenations and the join() (-8 characters)
Night2 for showing how to use chunk_split()'s $end parameter (-5 characters)

Try it online!
PHP 7.3, 117 112 108 characters
function s($s,$r,$c){echo _.chunk_split(($b=str_pad(_,$c,_)).str_shuffle(str_pad($s,$r*$c)),$c,"_
_").$b._;}

Thanks to:

Night2 for efficiently reversing the concatenations and the join() (-5 characters)
Night2 for showing how to use chunk_split()'s $end parameter (-4 characters)

Sample run:
php > function s($s,$r,$c){echo _.chunk_split(($b=str_pad(_,$c,_)).str_shuffle(str_pad($s,$r*$c)),$c,"_
php " _").$b._;}
php > s('HELLO', 4, 11);
_____________
_  L        _
_        L  _
_E          _
_    OH     _
_____________

Try it online!

I believe that fn($s,$r,$c)=>($b=str_repeat(9,$c+2))."\n9".join("9\n9".str_split(str_shuffle(str_pad($s,$r*$c)),$c))."9\n$b"; should work in PHP 7.4 (https://wiki.php.net/rfc/arrow_functions_v2), and a release canditate has been released (https://wiki.php.net/todo/php74), so, it is an available "compiler" that came before this challenge, and anyone can use it.

Doh, you are right. Read about, but forgot. (Note to myself: next time not just read Night2's tip. Upvote it too, maybe helps remembering.)

99 bytes

Thank you, @Night2. I can't imagine what I messed yesterday, as I tried moving more stuff inside the join(), but failed to reduce the size. ☹

Got even a shorter one using chunk_split: 94 bytes I also removed the last semicolon as I believe it is not needed, you have written a function, so the code which is going to assign it to a variable shouldn't count.

It probably could be shorter using wordwrap fucntion, but sadly it removes spaces, so it doesn't work for this challenge as it requires space character in the soup.

Thank you, @Night2. Me stupid. After observing for years how fellow members use Python3 print()'s end parameter, when I tried my luck with chunk_split() I failed to remember it. ☹ BTW, started this PHP solution attracted by that promising wordwrap()…

APL (Dyalog Extended), 23 bytesSBCS
Anonymous tacit infix function. Takes [M,N] as left argument and S as right argument.
'#',∘⌽∘⍉⍣4⊣⍴×/⍛(?⍨⍤⊣⊇↑)

Try it online!
×/⍛(…) apply the following function between the arguments, replacing the left argument with its product:
 ↑ take M×N characters from S, padding with spaces on the right
 ⊇ reorder that to the following order:
 ?⍨⍤ the shuffled indices 1 through…
 ⊣ the left argument (M×N)
⍴ reshape that to the following shape:
⊣ the left argument (i.e. M rows and N columns)
'#'…⍣4 apply the following function four times, each time with the hash character as left argument:
 ∘⍉ transpose the right argument
 ∘⌽ mirror the right argument
 , concatenate a column of hashes to the left side of that

Red, 120 116 114 112 bytes
-2 bytes thanks to @Kevin Cruijssen!
func[s m n][random pad s m * n insert/dup t: copy"00"0 n
print t loop m[print rejoin[0 take/part s n 0]]print t]

Try it online!

-2 bytes by getting rid of the + 1 and using to"""00"0 n instead.

@KevinCruijssen Thanks! I replaced it with copy, for the same byte count.

That indeed looks a bit cleaner! I don't know Red except for the answers I've seen from you, so I was just fiddling around a bit. ;) Would putting the t line as leading/trailing item before looping to save on the two loose print t be shorter? I doubt it, but since I don't know how to add items to a list I'm not sure.

MATL, 22 19 bytes
tZ"ibpyn&Z@(TT35&Ya

Try it online!
Thanks @LuisMendo for saving 3 bytes, so now it has the same bytecount as @flawr's answer, but sufficiently different to post anyway. High-level agorithm overview:
 Z"                  % Create n x m matrix of spaces
           (         % Index into this matrix:
   i                 %  The alphabet vermicelli (explicit input)
        &Z@          %  at a random locations (randperm), which are
      yn             %   length(S) numbers, ranging
t   bp               %   from 1 to n*m
            TT35&Ya  % And finally add a border

You can change Z}&O by Z", and that also allows you to remove the final c

@LuisMendo Oh that helps a lot! Come to think of it, I should've at least done 1$O.

Perl 6, 74 67 bytes
-5 bytes thanks to Jo King
{0 X~0 x$^n,|comb($n,[~] $^s.comb[pick *,^$^m*$n]X//' '),0 x$n X~0}

Try it online!
Explanation
{                                                                 }
                                         ^$^m*$n  # Range 0 .. M*N-1
                                  pick *,  # Shuffle
                         $^s.comb  # Split S into chars
                                 [              ]  # Pick shuffled elements
                                                 X//' '  # undef to space
                     [~]  # Join
             # Split into n-character strings
             comb($n,                                  )
            |  # Flatten
     # Add top and bottom of bowl
     0 x$^n,                                            ,0 x$n
 # Add left and right of bowl
 0 X~                                                          X~0

69 bytes

k4, 32 28 bytes
{4{|+x,'"#"}/y#a?(a:-*/y)$x}

edit: -4 thanks to Galen Ivanov!
called like
f["hey";3 3]

explanation:
                 (a:-*/y)    / neg product of y and assign to a
                         $x  / left pad x so we have char vector the length of the inner area
               a?            / take `a` random drawings. if a is negative, draw with no duplicates/replacements
             y#              / reshape to y's dimensions
 4{        }/                / do {} 4 times
   |+x,'"#"                  / append "#" along right-side of x then transpose (+) and reverse (|)

I think you can save some bytes if you only append # at the end of each line and transpose/reverse 4 times, something like this.

@GalenIvanov nice, updated!

Ruby, 121 bytes
Creates the bowl, queries the indices of all spaces within the bowl, samples a number of spaces equal to the size of the string, and fills them in. sample does not return a sorted list, so there is no need to shuffle. Searching indices up to 9*m*n (which almost certainly goes out of range) will still get all spaces and is 1 byte shorter than r.size.
->s,m,n{r=[t=?@*(n+2),*["@#{' '*n}@"]*m,t]*$/;i=-1;(0..9*m*n).select{|j|r[j]==' '}.sample(s.size).map{|j|r[j]=s[i+=1]};r}

Try it online!

Perl 5 -lF, 99 97 bytes
-2 bytes courtesy of @NahuelFouilleul
%k=map{$_=>$F[$_]||$"}0..($m=<>)*($n=<>)-1;say+($p='#'x($n+1)),map"#
#"x!($i++%$n).$_,values%k,$p

Try it online!

($i++%$n==0) could be changed by !($i++%$n)

T-SQL 2017, 232 bytes
Testing this online is an older version of sql-server costing another character. I posted the shorter version.
Golfed:
DECLARE @ varchar(max)=''SELECT top 999 @+=substring(@i,number+1,1)FROM spt_values
WHERE type='P'and number<@a*@b
ORDER BY newid()WHILE-@b<1SELECT @=stuff(@+' ',@b*@a+1,0,'#
#'),@b-=1PRINT stuff(replicate('#',2+2*@a),2+@a,0,trim(@))

Try it online
Ungolfed:
DECLARE @ varchar(max)=''

SELECT top 999 @+=substring(@i,number+1,1)
FROM spt_values
WHERE type='P'and number<@a*@b
ORDER BY newid()

WHILE-@b<1
SELECT @=stuff(@+' ',@b*@a+1,0,'#
#'),@b-=1
PRINT stuff(replicate('#',2+2*@a),2+@a,0,trim(@))

Java (JDK), 180 178 bytes
Not a single extra import:
(y,m,n)->{for(m*=n;y.length()<m;y+=" ");var s="";for(;m-->0;y=s)for(var c:y.split(s=""))s=Math.random()<.5?s+c:c+s;s="#".repeat(n);return(s+y+s).replaceAll(".{"+n+"}","\n#$0#");}

Try it online!
It was quite the struggle to get this golfed down. In particular, the imports involved with Collections.shuffle()/Arrays methods were too much to accept, so I had to create my own String shuffling algorithm (probably neither efficient nor uniformly distributed). Massive thanks to Steven for proving any set of positions can be generated from the algorithm.
Formatted (with explanation):
(y, m, n) ->                                                   // y = yummies in the soup,
{                                                              // m = height, n = width
    for (m *= n; y.length() < m; y += " ")                     // set m to m*n and
        ;                                                      // add spaces to y to fill up
    var s = "";                                                // the rest of the soup
    for (; m-- > 0; y = s)                                     // for m*n iterations, scramble y
        for (var c : y.split(s = ""))                          // with random appends
            s = Math.random() < .5 ? s + c : c + s;
    s = "#".repeat(n);                                         // create the top/bottom of the rim
    return (s + y + s).replaceAll(".{" + n + "}", "\n#$0#"); // add all sides of the rim
};

Nice answer! +1 from me. One small thing to golf: .replaceAll("(.{"+n+"})","\n#$1#") can become .replaceAll(".{"+n+"}","\n#$0#")

@KevinCruijssen Thanks for the improvement :)

Charcoal, 27 bytes
ＮθＮη↖Ｂ⁺²θ⁺²η#ＦＳ«Ｗ℅ＫＫＪ‽θ‽ηＰι

Try it online! Link is to verbose version of code. Takes input in the order width, height, string. Explanation:
ＮθＮη

Input the width and height.
↖Ｂ⁺²θ⁺²η#

Frame the bowl.
ＦＳ«

Loop over the characters in the string.
Ｗ℅ＫＫＪ‽θ‽η

Jump to a random position in the bowl until an empty spot is found.
Ｐι

Print the current character without moving the cursor.

Is that Move(:UpLeft) necessary? It works fine without it, but maybe you've added it for a reason I don't think about?

@KevinCruijssen Without it I would never be able to write letters into the bottom row or rightmost column.

Ah, so that was it. That explains it, thanks!

Japt -R, 21 18 bytes
úV*W ö¬òW ²Ô²û2W+2

Try it
úV*W ö¬òW ²Ô²û2W+2     :Implicit input of string U=S and integers V=M & W=N
úV*W                   :Right pad U with spaces to length V*W
     ö¬                :Random permutation
       òW              :Split to array of strings of length W
          ²            :Push 2
           Ô           :Reverse
            ²          :Push 2
             û2W+2     :Centre pad each element with "2" to length W+2
                       :Implicit output, joined with newlines

MATL, 29 27  19 bytes
pZ@iy~hw)1GeTT35&Ya

Try it online!
Thanks @LuisMendo for -8 bytes!
Explanation: p computes the number of soup-pixels. Then Z@ produces a random permutation of size of number of soup pixels. We will use this as indices to iy~h which is the input string with enough spaces added. w) swaps the two and indexes one with the other. We then reshape 1Ge the shape into the desired rectangle and #-pad it using TT35&Ya.

Clever! My attempt was 22 bytes

@Sanchises Go post it anyway!

Icon, 136 133 131 118 bytes
procedure f(s,n,m)
s||:=repl(" ",m*n-*s)
!s:=:?s&\z
write(t:=repl(0,m+2))
write(0,s[1+(0to n)*m+:m],0)&\z
write(t)
end

Try it online!

C (clang),  169 ...   156 bytes
i,b;f(n,m,s)char*s;{char o[b=i=-~++n*(m+=3)],*a=o;for(srand(&a);--i;)*a++=i%m?-~i%m<3|i<m|i>m*n?35:32:10;for(*a=0;*s;*a=*a-32?*a:*s++)a=o+rand()%b;puts(o);}

Try it online!
Saved 7 @ceilingcat suggestion to use -~variable and auto storage for string o plus many improvements.
Saved 4 again from @ceilingcat
Degolf :
char*a,// pointer for set operations
*o=malloc(b=i=(m+=3)*(n+=2));  => o[b=i=(m+=3)*-~++n]
// before allocating for the whole bowl as a char array
// increments m by 3 (2 for rims and 1 for '\n') and n by one but allocates for 2(rims)
// and assigns bowl size to i and b.
srand(time(0));// seeds rand function
for(// loop to make empty bowl
a=o;// using pointer as iterator
 --i ;)//  i decremented as a counter

 *a=// sets every char to..
 i%m?// if(not) over right side of bowl (m+3)
   -~i%m<3|i<m|i>m*n-m?35// if on rim '#'//-~i == (i+1)
   :32 // else ' '
  :10;// i%m==0

for(*a=0;// before loop terminates bowl with \0
 *s;// for every letters(exit on '\n')
 *a=*a-32?*a:*s++)
 // puts letter if bowl at a is a space and
 // go to next letter

 a=o+rand()%b;
 // sets a to o offsetted by random

puts(o);// prints bowl

Jelly, 16 bytes
P⁶ẋaẊs⁸ṪṾ€«”~ZƊ⁺

A dyadic Link accepting a list of integers, [M, N], on the left and a list of characters, S, on the right which yields a list of lists of characters, the lines. Uses the tilde character, ~, as the border.
Try it online!
All possible outputs have a non-zero chance of being yielded since we shuffle (Ẋ) a list of the characters of S along with the appropriate number of spaces.
The code Ṿ€«”~ZƊ⁺ saves the byte which I imagine would be required to join with newlines that full programs using an integer such as zero would need to employ (e.g. P⁶ẋaẊs⁸Ṫ;€0ZUƊ4¡Y or P⁶ẋaẊs⁸Ṫj@€Ø0Z$⁺Y). Maybe there's a way to save more...?

C# (.NET Core), 274 bytes
[Without LINQ]
Embarrassing number of bytes, but, this is what I got.
(x,y,z)=>{var f=new string('#',x+2)+'\n';char[] b=new string(' ',y*x).ToCharArray();Random r=new Random();while(z.Length>0){var d=r.Next(0,y*x);if(b[d]==' '){b[d]=z[0];z=z.Substring(1);}}z=f;for(var j=1;j<y*x+1;)z+=(j%x==1?"#":"")+b[j-1]+(j++%(x)==0?"#\n":"");return(z+=f);}

Try it online!

Ruby, 105 78 bytes
Takes an array of characters and two integers; returns a string.
->s,h,w{((e=?#*w)+(s+[" "]*(h*w-s.size)).shuffle*""+e).gsub /.{#{w}}/,'#\&#
'}

Attempt This Online!

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


text:
Spreadsheet Columns
Spreadsheet Columns
In most spreadsheet programs, columns go A, B, C, ... X, Y, Z. After this comes AA, AB, AC ... AX, AY, AZ, BA and so on.
Your task is to convert one of these strings in to a column number. You must support inputs up to the maximum length of your language, to a minimum of 3.
Test Cases:
A   => 1
B   => 2
Z   => 26
AA  => 27
AC  => 29
AZ  => 52
BA  => 53
FC  => 159
ID  => 238
AAA => 703

Standard loopholes are forbidden.

Related, borderline dupe.

Also a subset of this challenge, which would probably be a better dupe target.

@Shaggy you were one step away from the exact dupe :-)

@Giuseppe, A-ha! That was the challenge I set out to find but it didn't show up when searching for "spreadsheet" or "Excel".

@Shaggy No! I've been duped!

@Giuseppe Above, but SE only allows one mention.

Back to the drawing board, I guess.

@gadzooks02 yes, alas, a good challenge but one already done. Feel free to post in The Sandbox to get feedback if you want any; this can sometimes help catch dupes, although sometimes challenges just languish there for way too long. In that case, drawing additional attention to it in chat can help as well.

@Giuseppe Yeah. I already have another idea :)

Um, you did put this in the Sandbox, where I told you it was a dupe. What's the point of ignoring feedback?

@JoKing Ah yes, I hadn't noticed.


text:
Shortest way to get an EOF Error
It's simple, simply output text to STDERR containing the string EOF.
Input/Output
Your input will be none; however, you should output the message to STDERR.
Rules

Since this is code-golf, the shortest answer wins.
No standard loopholes please.
Any method approved by Standard I/O is allowed.
Your code may not contain the "EOF" that you will output as-is in your error.
Outputting "EOI" is technically allowed, because the input can also be considered as a separate file.

Not a duplicate of this one because the TypeError challenge is only defined for one specific language.

What are compiled languages supposed to do? Do we have to write a program that makes the compiler output "EOF" among other things?

@someone output text to STDERR containing the string EOF (…), you should also exit the program with a 1 value.

Error messages are usually a feature of the compiler, not the language itself. The given example id( throws a syntax error when using PyPy instead of CPython. I suggest to include the compiler/interpreter in the answer header, e.g. "Python using CPython".

Is this valid?

@nimi Invalidated.

This feels like a more boring version of https://codegolf.stackexchange.com/questions/70045/helloworld-error with built-in easier to be applied.

btw there are some answers that have "end of input" instead of "EOF" in the output.

I don't think it's a duplicate. The "HelloWorld error" challenge asks to output a specific string to stderr, this one asks to trigger a specific compiler/interpreter condition. Theses are different tasks, even if some programs may work in both scenarios.

Seeing as several answers output end of input or end of file instead of EOF, you should clarify explicitly whether this is allowed.

Is there a requirement for it to be a valid program?
Several answers here assume there is not.

@A_ wait, what? How can a program be syntactically valid if some part is missing and EOF is thrown?

voting to close as unclear.  First sentence says to raise an EOF error. Next sentence says to output text to stderr containing EOF. I/O section says you should output a message to STDERR that proves that the program generates an EOFError. All three are asking different things.

Can we include 'FOE' in our program?

Yes, because the program outputs 'EOF' but not 'FOE'.

APL (Dyalog Unicode) 17.0, 0 bytes

Dyalog 17.0 expects programs to terminate themselves cleanly and will throw an EOF INTERRUPT (and exit with a code 2) if they don't: Try it online!
In contrast, here is the minimal program which does terminate itself cleanly, causing no error (and code 0 upon exit): Try it online!

Python 3, 1 byte
(

Try it online!
A plain opening bracket is interpreted as the start of a tuple. Just having one bracket is enough to raise an EOF error. Also works with [ and {.

Keg, 1 byte
?

Try it online!
When there's no input, an EOF is raised:
Traceback (most recent call last):
 File "/opt/keg/Keg.py", line 500, in <module>
   exec(header + code + footer)
 File "<string>", line 6, in <module>
 File "/opt/keg/KegLib.py", line 119, in Input
   item = input()
 EOFError: EOF when reading a line

Also works with ¿

JavaScript, 1 byte / 7 solutions
The following tokens trigger SyntaxError: Unexpected end of input, or a similar message depending on the JS engine.
!
(
+
-
[
{
~

Or to summarize:

unary operators
opening parenthesis / bracket / brace

Exhaustive test on all ASCII characters
for(n = 0; n < 127; n++) {
  code = String.fromCharCode(n);
  res = false;

  try {
    eval(code);
  }
  catch(e) {
    res = e.toString() == 'SyntaxError: Unexpected end of input';
  }
  if(res) {
    console.log(code);
  }
}

Try it online!

Turbo Assembler, 0 bytes
Borland Turbo Assembler will print an "Unexpected end of file" when assembling a zero-byte file.

For the python users; the ones posting one character code, technically that is a SyntaxError which happens to read as an EOFERROR. (FYI, here's an example of all printable single characters that would cause this same error I'm getting a total of 34:)
from string import printable

chars = []
for c in printable:
    try: eval(c)
    except Exception as e:
        if 'EOF' in str(e):
            chars += [c]
print(chars)

This prints:
['!', '#', '$', '%', '&', '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?', '@', '[', ']', '^', '`', '{', '|', '}', '~', ' ','\t', '\n', '\r', '\x0b', '\x0c']

I'm not sure if raise EOFError would be considered an answer as unfortunately that's the shortest code I can think of to raise a legitimate EOFError in Python 3:

Python 3, 14 bytes
raise EOFError

Try it online!
OR
Without implicitly raising the error in Python 2 you could use this at the expense of an extra byte:

Python 2, 15 bytes
input('\u0004')

Try it online!

raise EOFError is considered invalid because the output contains the exact text EOFError that appears in the source code.

Why does it not count as an EOF error if it only “happens to read as” one? It does not matter where the EOF comes from, so long as it is an EOF — in the case of single brackets, a source input EOF.

Because I am avoiding the trivial answer: hard-coding the EOF error output like the program EOF.

Either way I was simply stating that the one char method doesn’t technically produce a real EOFError but in py2 the input method does

PHP, 1 byte
1

Try it online!
Run like this: php -r 1
Error: PHP Parse error: syntax error, unexpected end of file in ...
Any other characters apart from ;, #, space and new line should cause a similar error. So PHP probably has ASCII characters count - 4 single byte solutions.

Haskell using hugs, 1 byte
{

The error message contains unexpected end of input.
Try it online!

Japt v2.0a0, 1 byte
Each throws: SyntaxError: Unexpected end of input
´
¥
¶
ª
©
«
§
¨
±
µ
÷
Á
Â
Ò
Ó

Test it (Errors are displayed below the output field)
There are also a number of other possibilities, not specific to Japt, that are covered in Arnauld's JS solution, such as:
!
&
|
~
^

R, 1 byte, 10 solutions
Any of these characters alone will trigger Error: unexpected end of input.
"
'
`
(
{
+
-
!
?
~

You missed ~ to bring it to an even 10 :-)

Python 3, 1 byte
Sorry for the edit, misunderstood the question at first :P.
We can do [ or ( or { to get unexpected EOF error. In first case, it expects a list, in second a tuple and so on.

[

Try it online!

Perl, 1 byte
(
Try it with
 perl -e "("
 syntax error at -e line 1, at EOF
 Execution of -e aborted due to compilation errors.

Java, 1 byte
e

Try it online!

Old method that's more fun :]
void a()throws Exception{new java.io.DataInputStream(System.in).readInt();}

Try it online!

I was expecting a one-byte solution... Clever encoding of EOFException though.

I'll find one for ya.

@A_ turns out many single characters yield an EOF, haha. At least I've got a runtime version as well :P

T-SQL, 21 bytes
RAISERROR('EOF',11,1)

Bash, 1
"

Output
.code.tio: line 1: unexpected EOF while looking for matching `"'
.code.tio: line 2: syntax error: unexpected end of file

Try it online!

Ruby, 1 byte
!

Try it online!
Any of ["!", "(", "*", "+", "-", ":", "[", "{", "~"] will work depending on the environment.

You could add ["\"", "%", "'", "/", "\"]`. It depends on the exact requirement, though. Some will raise SyntaxError mentioning "end of file" or "end-of-input", but I couldn't find any which includes "EOF".

Ruby, 1 byte
/

Outputs unterminated regexp meets end of file
Try it online!

Perl 5, 1 byte
"

Try it online!
Not very inspired, but it is the shortest possible in the language.
Outputs Can't find string terminator '"' anywhere before EOF at .code.tio line 1.

Go, 0 bytes
All Go files must begin with package [identifier]. The error message is:
can't load package: package main:
src/test.go:1:1: expected 'package', found 'EOF'


text:
C4_4 Reflection!
In this challenge, your task is to input a rectangle ASCII pattern (You may assume only printable characters need to be handled, and you may assume a trailing newline or not), C4_4 symmetrify, and output it.
Here, C4_4 symmetric means symmetric under 90-degree rotation around a corner of the corner character. The corresponding "symmetrify" process is copy and rotate 90-degree clockwise three times, and then put all four copies together. For the precise arrangement, you can look at Test Cases.
Test Cases
Input:
asdf
jkl;

Output:
    ja
    ks
asdfld
jkl;;f
  f;;lkj
  dlfdsa
  sk
  aj

Input:
.O.
..O
OOO

Output:
.O.O..
..OO.O
OOOOO.
.OOOOO
O.OO..
..O.O.

Input:
gc
oo
ld
fe

Output:
  gc
  oo
  ldflog
  feedoc
codeef
golfdl
    oo
    cg

I'd suggest to add a test case where the height of the input is strictly greater than its width.

Hmm... emoticons? 4_4

Charcoal, 6 bytes
Ａ⟲Ｃ²⁴⁶

Try it online! Link is to verbose version of code. Explanation: Ａ implicitly prints the input, ⟲ performs the rotation, Ｃ signifies to keep copies, and ²⁴⁶ represents the numbers of 45-degree rotations to make. (Charcoal defaults to rotating around the bottom-right corner as desired.)

Yet another fastest gun! Yeah, Charcoal is very suitable for this challenge. Have a +1!

Python 3, 193 bytes
def f(s):q=len(s[0])-len(s);s=[[" "]*len(s[0])]*q+s;s=[[" "]*-q+l for l in s];j=lambda a,b:[x+y for x,y in zip(a,b)];r=lambda x:[*map(list,zip(*x[::-1]))];return j(s,r(s))+j(r(r(r(s))),r(r(s)))

Try it online!

I was not expecting this to happen. Nice work!

J, 38 bytes
(,|."1@|.)@(,.|:@|.)@((2$_1*>./)@${.])

Try it online!
No doubt it can be golfed much further.

JavaScript (ES6),  178  173 bytes
Takes input as an array of strings. Returns a string.
m=>(g=x=>~y?(Y=y<w?y:W-y,X=x<w?x:W-x,Z=y<w^x<w?Y:X,(m[Z-z*d]||0)[(X^Y^Z)+!z*d]||' ')+[`
`[x-W]]+g(x<W?x+1:!y--):'')(0,w=m[0].length,h=m.length,d=w-h,(z=d>0)?0:w=h,y=W=w*2-1)

Try it online!

Red, 217 bytes
func[a][n: max(l: length? a)length? a/1
p: copy""insert/dup p" "n
loop n - l[insert a copy p]forall a[pad/left a/1 n]repeat y n[repeat x n[append
a/:y a/(n - x + 1)/:y]]repeat y n[append a reverse copy a/(n - y + 1)]]

Try it online!
Returns a list of strings

pad, append, reverse! This is plain English. I like it.

@TwilightSparkle Thanks! I like it too :)

I'm curious why Red uses [] unlike lisp.

@TwilightSparkle I don't know.. [] is a block (list), () is used for grouping

Is this block the same kind of "block" in GolfScript?

@TwilightSparkle I don't know GolfScript. In Red blocks are doubly-linked lists that can consist of everything.

And can be executed?

Yes. Unlike LISP the blocks are quoted and need to be reduced in order each word (symbol) be evaluated, or executed with do. A short How Red works explanation

Thanks for your explanation. I think I will probably get deeper into this language, maybe.

Python 3, 140 bytes
def f(a):l=len(a[0]);k=len(a)-l;b=[k*' '+i for i in-k*[l*' ']+a];b+=[*map(''.join,zip(*b))][::-1];return[i+j[::-1]for i,j in zip(b,b[::-1])]

Try it online!
Expects and returns a list of lines.
Explanation
def f(a):
 l=len(a[0]);k=len(a)-l;                     # Extract dimensions
 b=[k*' '+i for i in-k*[l*' ']+a];           # Make it square
 b+=[*map(''.join,zip(*b))][::-1];           # Construct left half of the output
 return[i+j[::-1]for i,j in zip(b,b[::-1])]  # Construct the right half and return

A nice approach!

Icon, 255 206 bytes
procedure f(a)
n:=*a;n<:=t:=*a[1]
1to n-*a&push(a,repl(" ",t))&\z
(!a)[1:1]:=repl(" ",n-t)&\z
i:=1to n&j:=1to n&a[i]||:=a[n-j+1,i]&\z
i:=1to n&put(a,"")&j:=1to 2*n&a[n+i]||:=a[n-i+1,2*n-j+1]&\z
return a
end

Try it online!

No Red answer? :P

@TwilightSparkle Maybe I'll write one :)

I'm waiting for it then LOL

APL (Dyalog Unicode), 22 bytes
{(⌽⍪⊖)(⍉,⌽)⍵↑⍨-2/⌈/⍴⍵}

Try it online!


text:
Is this skew symmetry?
In this challenge, your task is to detect (vertical) Skewer Symmetry. This means that one half of the pattern can be produced by mirroring the other half along a vertical axis, and then moving it vertically.
For example, the following pattern has skewer symmetry:
asdf
jkl;fdsa
    ;lkj

Because if you start from the left half...
asdf
jkl;

...then mirror it along a vertical axis...
    fdsa
    ;lkj

...then move it down by a character (filling the empty rows with spaces)...

    fdsa
    ;lkj

...you get the second half.
Rules:

You may assume the input is rectangle and has an even number of columns.
If the pattern itself exhibits reflection symmetry, it is considered skewer symmetry.
This is strict character by character symmetry, so [[ is considered symmetrical, but not [].
You should output truthy if the input has skewer symmetry, falsy otherwise.
Default I/O rules apply, standard loopholes are banned.

Test Cases
Truthy cases:
asdf
jkl;fdsa
    ;lkj

asdffdsa

[

 [

  ba
abdc
cd

Falsy cases:
[
 ]

ab
ba

aa
a
 a

a  a
b b

ab
  b
   a

suggested test case: ["abfe","cdhg","efba","ghdc"]. i don't know what the result should be.

Suggested test case: ["ab  ", "  b ", "   a"] (where the columns are symmetric with the spaces stripped, but not with spaces present)

@Mnemonic that’s not a valid input since it has an odd number of columns. Thus submissions are allowed to behave in any way for this input.

@ngn This is similar to the ["ab", "ba"] test case, result should be falsy (it’s a symmetry+rotation, while skew symmetry is only symmetry+translation).

@Grimy Formatting ate the array.  It's supposed to be four columns, with 'a' in the first and last and 'b' in the second and third.  So ["ab..", "..b.", "...a"], with the dots replaced with spaces.

Suggested test case: ["  ba","abdc","cd  "] -> truthy (left part is moved downwards). May we assume, that the input contains only printable ASCII (' ' (space) to '~')?

@nimi Yes, you may assume.

APL (Dyalog Unicode), 44 34 bytesSBCS
crossed out 44 is still regular 44 ;(
Hats off to @Bubbler, @ngn and @TesselatingHeckler as they managed to shave some bytes off of my solution, more or less independently but coming up with the same simplifications.
{1∊(l↓⍵)⍷⍨a/⍨∨⌿' '≠a←⊖⍵↑⍨l←2÷⍨≢⍵}⍉

Try it online!
Now I'll explain how it works:
{                                   }⍉  ⍝ We define a monadic function that we apply right after transposing (⍉) the input [this means we will be operating on columns instead of rows]
                              2÷⍨≢⍵    ⍝ Start by finding how many  columns the input has (≢),split that in half (2÷⍨)
                            l←          ⍝   and assign that to l (l←) ...
                        ⍵↑⍨            ⍝ Using it right away to take (↑⍨) l columns from the original input ⍵
                       ⊖               ⍝   which we then reverse (⊖) [effectively flipping the columns upside down]
                     a←                 ⍝   and assign to a (a←)
                 ' '≠                   ⍝ We then compare each character in a to ' '
               ∨⌿                       ⍝   and we "interleave" the logical OR (∨) over the columns (⌿) [to find columns where at least one character is different from ' ']
           a/⍨                          ⍝   finally selecting those columns from a (a/⍨)
         ⍷⍨                             ⍝ Now we superimpose that piece of the original character matrix over all possible locations
   (l↓⍵)                               ⍝   of the columns of ⍵ that remain after we drop (↓) the first l columns [i.e. we take the second half of the columns]
 1∊                                    ⍝   and we look for matches by checking if there is a 1 (Truthy) in any position (∊)

Quick golf using transposed array gives 36 bytes.

@Bubbler Quick for you ⍨ ahah, thanks for the help!

33: {1∊(w/⍨∨⌿' '≠w←⊖l↓⍵)⍷⍵↓⍨l←2÷⍨≢⍵}⍉

J, 34 23 38 bytes
1 e.[:(e.&:((-:@#{.])"1)|."1\.)"2],:|.

Try it online!
thanks to nimi for catching a bug
Will attempt to regolf the fixed version later.

Haskell, 137 135 133 bytes
f s=uncurry(#)$unzip$splitAt(div(length$s!!0)2)<$>s
a#b@(x:y)|e$last a++x=init a#y|e$last b++a!!0=b#a|r<-reverse<$>b=a==r
e=all(<'!')

Try it online!


text:
Diamondize Some Text
Given an input string of length 2 or longer consisting solely of alphabetical characters [A-Z] or [a-z] (your choice if they're all uppercase or all lowercase), output a continuous string of characters forming a double diamond pattern.
The input string starts on the center line and extends down-and-right at a diagonal until the end of the input string is reached. Then, the pattern continues up-and-right at a diagonal until you're as far above the center line as the length of the input string minus 1. Continue down-and-right back to the center line, then down-and-left, then up-and-left (going "behind" the center character), and finally down-and-left back to the starting character.
That's a little wordy, and it's better demonstrated by some examples:
"YOU"
  U   Y
 Y O U O
Y   O   U
 O Y U Y
  U   O

  ^   ^
 ↙ ↖ ↗ ↘
↘   ↗   >
 ↘ ↗ ↖ ↙
  V   V

See how the YOU starts at the center line and follows down-and-right, then up-and-right, etc., until it loops back to the beginning. Note especially how the Y on the up-and-left portion is "behind" the O and therefore not shown.
Some further examples:
"HI"
 I I
H H H
 I I

"TEST"
   E     E
  S T   T S
 T   T T   T
T     S     T
 E   E E   E
  S T   T S
   T     T

"HELLO"
    L       L
   O L     E L
  H   E   H   O
 E     H O     H
H       L       E
 E     L L     L
  L   E   L   L
   L H     E O
    O       H

Input and output can be given by any convenient method.
The input is guaranteed to be at least two letters long (i.e., you'll never receive "" as input).
You can print it to STDOUT or return it as a function result.
Either a full program or a function are acceptable.
Any amount of extraneous whitespace is acceptable, so long as the characters line up appropriately (e.g., feel free to pad as a rectangle).
Standard loopholes are forbidden.
This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.

Not sure that it matters, really, but why does the second (up left) pass go behind the first (up right) pass? Makes less intuitive sense and also a little annoying to either skip or re-draw that letter.

@BradC I was playing with a Möbius strip at my desk when I came up with the challenge, and the strip kinda goes "behind" so that's why. No other reason.

Might be an idea to include a "drawing" of the path using arrow characters, to help us visualise it.

@Shaggy Added a drawing.

Nice one, This one is more challenging then first glance..

Charcoal, 17 bytes
ＧＨ<↗↘>↖↙ＬθθＧＨ<Ｌθθ

Try it online! Link is to verbose version of code. Explanation:
ＧＨ

Draw along a path.
<↗↘>↖↙

Draw in the directions ↘↗↗↘↙↖↖↙ (the < and > are shorthands for those two pairs, but the other pairs don't have shorthands.)
Ｌθ

Each path segment has the same length, including the ends, of the length of the input.
θ

Use the input as the text to be written along the path.
ＧＨ<Ｌθθ

Print the first two parts of the path again so that the middle character is correct.

This challenge seems tailor made for Charcoal

@Jonah Sadly, the text path command doesn't draw the last character if the path is closed, so you can't use the reverse drawing trick here. (Although if it did, it would be the same byte count anyway, since rotating the string costs 6 bytes.)

05AB1E, 12 bytes
gIR7._•ÍÎ·•Λ

Try it online!
           Λ    use the canvas function
g               with the length of input for each segment
 IR7._          the input reversed and rotated left by 7 characters (we will draw this backwards to have the right center character)
      •ÍÎ·•     and the directions 1, 3, 3, 1, 7, 5, 5, 7 as a compressed number.

Did you mean 1, 3, 3, 1, 7, 5, 5, 7?

Oh, you're right. I mixed up the numbers a little bit

JavaScript (ES6),  157 155  154 bytes
Returns a matrix of characters.
s=>(y=n=s.length,y+=i=X=Y=-1,m=[...Array(y+n)].map(_=>r=Array(4*n-3).fill` `),g=x=>x?g(x-=r[m[y][++i==6*n-6||+x]=s[i%n],y-=m[y-Y]?Y:Y=-Y,x-X]?X:X=-X):m)``

Try it online!
How?
Given the length \$n\$ of the input string, we build a matrix of size \$w\times h\$, with:

\$w = 4n-3\$
\$h = 2n-1\$

We run a simulation of a 'ball' bouncing in this matrix, starting at \$(0,n-1)\$ and heading South-East, until it's back to its initial position.
The 0-based index of the center character that must be skipped in the diamond shape is:
$$p=6n-6$$
Example for \$n=4\$:

Commented
s => (                           // s = input string
  y = n = s.length,              // n = length of s
  y += i = X = Y = -1,           // y = n - 1; i = X = Y = -1
  m =                            // create a matrix m[]:
    [...Array(y + n)].map(_ =>   //   - of height 2n-1
      r = Array(4 * n - 3)       //   - of width 4n-3 (save one of these rows in r[])
          .fill` `               //   - initially filled with spaces
    ),                           //
    g = x =>                     // g is a recursive function taking x
      x ?                        //   if x is truthy:
        g(                       //     do a recursive call:
          x -= r[                //       update x:
            m[y][                //         update m[y][x]:
              ++i == 6 * n - 6   //           unless this is the 2nd pass through the
              || +x              //           center cell, set it to the next character
            ] = s[i % n],        //           in s (otherwise we write to m[y][true]
                                 //           instead, which has no effect)
            y -=                 //         update y:
              m[y - Y] ? Y       //           bounce vertically if m[y - Y] is undefined
                       : Y = -Y, //
            x - X                //         bounce horizontally
          ] ? X                  //         if r[x - X] is undefined
            : X = -X             //
        )                        //     end of recursive call
      :                          //   else:
        m                        //     stop recursion and return m[]
)``                              // initial call to g with x = [''] (zero-ish but truthy)

I have a 136 byte solution that's inspired by your solution, although I think by now it might be different enough to qualify as a separate answer.

@Neil You should probably post it as a new answer.

J, 79 77 75 bytes
(|.@$~8*])`([:;/(1,~<:@])+/\@,(_2{&1 _1\#:33495)}.@#~])`(' '$~1+2 4*])}<:@#

Try it online!

JavaScript (ES6), 136 bytes

f=
(s,l=s.length-1,z=l*4,a=[...Array(l-~l)].map(_=>Array(z+1).fill` `),g=x=>x--?g(x,a[a[y=(x+l)%z]?y:z-y][x>z?z+z-x:x]=s[x%-~l]):a)=>g(z+z)
<input oninput=o.textContent=f(this.value).map(c=>c.join``).join`\n`><pre id=o>

Returns a two-dimensional array. Works by drawing the string into the array directly computing the destination co-ordinates working backwards from the end so that the centre cell is overwritten automatically. Explanation:
(s

Input string.
,l=s.length-1

Distance between "bounces", also half the last row index and one less than the length.
,z=l*4

Last column index, also half of the length of text to draw.
,a=[...Array(l-~l)].map(_=>Array(z+1).fill` `)

Array of spaces.
,g=x=>x--

Count down from the last cell to the first.
  ?g(x

Recursive call to process the remaining cells.
    ,a[a[y=(x+l)%z]?y:z-y]

Calculate the row of this cell.
      [x>z?z+z-x:x]=s[x%-~l])

Calculate the column of this cell and the character that belongs there.
  :a

Finish by returning the array.
)=>g(z+z)

Start at the end of the text.

That's a nice one, +1

C (clang),  201 196  188 bytes
x,y,i,v,m,n;f(s,z){char*a=s,o[i=(y=z*2-1)*(x=y+y)];for(v=x*2-2;i;n=m=1)o[--i]=i%x?32:10;for(i=x*--z;v--;i+=x*m+n)o[i]==32?o[i]=*a:0,a=*++a?a:s,n=i%x>x-3?-1:n,m=i/x?i/x<y-1?m:-1:1;puts(o);}

Try it online!
-13 @ceilingcat suggestions

Python 2, 137 bytes
s=input();n=len(s);m=2*n-2
for r in range(m+1):print''.join([s[[x,-8-x][(x<=m)==(m>2*r)]%n],' '][r!=(x+1-n)%m!=m-r]for x in range(4*n-3))

Try it online!
A full program that takes a string as input as prints out the diamondized version.


text:
What's the current zodiac?
Display the emoji of the eastern zodiac of given time, according to given country.
The eastern zodiac is a classification scheme that assigns an animal and its reputed attributes to each year in a repeating 12-year cycle. It is also assigned to hours.
Rules:

The country must be given as ISO 3166-1 alpha-3 code. The list is here.
The input format must be like this: <ISO code> HH:MM. The input must be a single string. Any input that doesn't fit this format falls in don't care situation.
If the given time lies in boundary of the chart given below, you can output either zodiac.
As this is a code golf, the shortest code in bytes wins.

The zodiacs:
The zodiacs without specified country are defaults.

The first zodiac (23:00 – 01:00):

Rat  (U+1F400)
Mouse  (U+1F401) in Persia (IRN)

The second zodiac (01:00 – 03:00):

Ox  (U+1F402)
Water Buffalo  (U+1F403) in Vietnam (VNM)
Cow  (U+1F404) in Persia

The third zodiac (03:00 – 05:00):

Tiger  (U+1F405)
Leopard  (U+1F406) in Persia

The fourth zodiac (05:00 – 07:00):

Rabbit  (U+1F407)
Cat  (U+1F408) in Vietnam

The fifth zodiac (07:00 – 09:00):

Dragon  (U+1F409)
Crocodile  (U+1F40A) / Whale  (U+1F40B) in Persia (you can output either)
Snail  (U+1F40C) in Kazakhstan (KAZ)

The sixth zodiac (09:00 – 11:00):

Snake  (U+1F40D)

The seventh zodiac (11:00 – 13:00):

Horse  (U+1F40E)

The eighth zodiac (13:00 – 15:00):

Ram  (U+1F40F)
Goat  (U+1F410) in Vietnam
Sheep  (U+1F411) in Persia

The ninth zodiac (15:00 – 17:00):

Monkey  (U+1F412)

The tenth zodiac (17:00 – 19:00):

Rooster  (U+1F413)
Chicken  (U+1F414) in Persia

The eleventh zodiac (19:00 – 21:00):

Dog  (U+1F415)

The twelfth zodiac (21:00 – 23:00):

Pig  (U+1F416)
Boar  (U+1F417) in Japan (JPN)
Elephant  (U+1F418) in Thailand (THA)

The code points are from here.
Example:
Given the following input:
KOR 19:42

The output must be:

Interesting - I knew these cycled every 12 years. I never heard of the 24 hour cycle. Still, the challenge is clearly specified as it stands. "Correcting" it to 12 years may lead to confusion.

What's up with Persia having so many different versions? Any specific reasons?

@cairdcoinheringaahing I'm not an Iranian, so I don't know.

@cairdcoinheringaahing an old Persian poet and dictionary writer called "Abou Nasr Farahi" or in Persian "ابونصر_فراهی" has a short poem in one of his books, which names those animals in that order in it and thus they are the animals used in Iran for every of those 12 years. He has not been a very famous poet, so not many English resources can be found about him, but I checked his book's text in Persian and the poet was there.

Related.

05AB1E, 66 64 63 bytes
þт÷;ò12%Ð•kÄ$ó·;@è₂Èαвλã…7q¼#∍o•5в6ä.•xиʒaàÒ¾Äλ•u3ôIákèsèžy₄*Oç

Try it online!

JavaScript (ES6),  168 165 160 157  155 bytes
Saved 4 bytes thanks to @Neil
Returns the crocodile for the 5th zodiac in Persia.
([a,b,c,,d,e])=>String.fromCodePoint(127998-~'00111321211'[k=-~(d+e)%24>>1]+k*2-~(1e12+{IRN:121010020100,VNM:1010001e4,KAZ:3e7,JPN:1,THA:2}[a+b+c]+a)[k+1])

Try it online!
How?
We define \$k\$ as the 0-based index of the zodiac, which can be deduced from the hour \$h\$ with:
$$k=\lfloor ((h+1)\bmod 24)/2\rfloor$$
We define \$x_k\$ such that the base offset \$b_k\$ of the code point for a given zodiac is:
$$b_k = 2k+x_k$$
The final code point is \$128000+b_k+c_k\$, where \$c_k\$ is the country offset.
This is summarized in the following table:
   k =  |   0 |   1 |   2 |   3 |   4 |   5 |   6 |   7 |   8 |   9 |  10 |  11
--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----
  b(k)  |  +0 |  +2 |  +5 |  +7 |  +9 | +13 | +14 | +15 | +18 | +19 | +21 | +22
  = 2k  |   0 |   2 |   4 |   6 |   8 |  10 |  12 |  14 |  16 |  18 |  20 |  22
  +x(k) |   0 |   0 |   1 |   1 |   1 |   3 |   2 |   1 |   2 |   1 |   1 |   0
--------+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----
   IRN  |  +1 |  +2 |  +1 |     |  +1 |     |     |  +2 |     |  +1 |     |
   VNM  |     |  +1 |     |  +1 |     |     |     |  +1 |     |     |     |
   KAZ  |     |     |     |     |  +3 |     |     |     |     |     |     |
   JPN  |     |     |     |     |     |     |     |     |     |     |     |  +1
   THA  |     |     |     |     |     |     |     |     |     |     |     |  +2

Commented
( [ a, b, c,               // a,b,c = country code
    ,                      // the space is ignored
    d, e ] ) =>            // d,e = hour (minutes are ignored)
  String.fromCodePoint(    // return the character whose code point is:
    127998                 //   127998
    -~'00111321211'[       //   + 1 + x(k)
      k = -~(d + e)        //   where k is defined as:
          % 24 >> 1        //     floor(((hour + 1) mod 24) / 2)
    ] +                    //
    k * 2                  //   + 2k
    -~(                    //   + 1 + the country offset
      1e12 +               //     each pattern being encoded as 10**12
      {                    //     + a specific value, leading to:
        IRN: 121010020100, //       IRN -> 1121010020100
        VNM: 1010001e4,    //       VNM -> 1010100010000
        KAZ: 3e7,          //       KAZ -> 1000030000000
        JPN: 1,            //       JPN -> 1000000000001
        THA: 2             //       THA -> 1000000000002
      }[a + b + c]         //     according to the country code
      + a                  //     coerced to a string
    )[k + 1]               //   extract the correct offset for this zodiac
  )                        //   (gives something NaN-ish for the other countries)

String.fromCodePoint(128e3+~~ saves 4 bytes.

PHP, 185 chars, 263 bytes
Thanks to Dannyu NDos for bug fix.
fn($i)=>strlen($b=[[,],[,,],[,],[,,],[,,,],,,[,,],,[,],,[,4=>,5=>]][(($t=$i[4].$i[5])%2?$t+1:$t)%24/2])?$b:$b[strpos(____IRN_VNM_KAZ_JPN_THA,substr($i,0,3))/4]

Try it online!
Just a simple array mapping, there should be better ways to golf this. Hour part of input time is converted to an even number (0-22) and then it is divided by 2 to get array index 0 to 11 in the mapping. Time periods with special cases are a sub-array with index 0 mapped to default sign and 1-5 mapped to the special sign for IRN, VNM, KAZ, JPN and THA in same order.

Charcoal, 73 bytes
℅⁺×¹²⁸φΣＥ⮌…⪪”＆↖∨∧h↘Ｘ⁷↘H⪫³Ｊºρ⁷s,⟲⌈3A‖Cc>χ§₂25:×” ⊕﹪÷⊕Ｉ…η²¦²¦¹²⊕⎇κ÷Ｌι³⌕⪪ι³θ

Try it online! Link is to verbose version of code. Explantion:
℅⁺×¹²⁸φ

0x1F400 = 128,000 (φ is predefined to 1,000). This is added to the sum of the rest of the expression and converted to a character for implicit print.
⊕﹪÷⊕Ｉ…η²¦²¦¹²

The hour is extracted and converted to a zodiac index.
…⪪”＆↖∨∧h↘Ｘ⁷↘H⪫³Ｊºρ⁷s,⟲⌈3A‖Cc>χ§₂25:×” ...

The compressed string IRN VNMIRN IRN VNM IRNIRNKAZ   VNMIRN  IRN  JPNTHA is split on spaces and truncated to the length given by that index.
ΣＥ⮌...

The array is then reversed, mapped over, and summed.
⊕⎇κ÷Ｌι³⌕⪪ι³θ

For the first element, the string is split into groups of three characters and the country index is taken, otherwise the number of countries is counted. For the first element, the index needs to be converted from 0-indexing to 1-indexing while for the other elements the result needs to be incremented for the default country, so this is done outside of the ternary.

Python 3, 168 bytes
lambda s,a='BA EDC GF HIH KJMJ N O RQP S UT V WWWXYW'.split():chr(ord(a[(int(s[4:6])+1)//2][min('IRNVNMKAZJPNTHA'.find(s[:3])//3,len(a[(int(s[4:6])+1)//2])-1)])+127935)

Try it online!

147 bytes if you don't mind switching to Python 3.8.


text:
North Korean dictionary order
The objective
Given a string of Hangul syllables, sort the characters in North Korean dictionary order.
Introduction to Hangul syllables
Hangul(한글) is the Korean writing system invented by Sejong the Great. Hangul syllables are allocated in Unicode point U+AC00 – U+D7A3. A Hangul syllable consists of an initial consonant, a vowel, and an optional final consonant.
The initial consonants are:
ㄱ ㄲ ㄴ ㄷ ㄸ ㄹ ㅁ ㅂ ㅃ ㅅ ㅆ ㅇ ㅈ ㅉ ㅊ ㅋ ㅌ ㅍ ㅎ

The vowels are:
ㅏ ㅐ ㅑ ㅒ ㅓ ㅔ ㅕ ㅖ ㅗ ㅘ ㅙ ㅚ ㅛ ㅜ ㅝ ㅞ ㅟ ㅠ ㅡ ㅢ ㅣ

The final consonants are:
(none) ㄱ ㄲ ㄳ ㄴ ㄵ ㄶ ㄷ ㄹ ㄺ ㄻ ㄼ ㄽ ㄾ ㄿ ㅀ ㅁ ㅂ ㅄ ㅅ ㅆ ㅇ ㅈ ㅊ ㅋ ㅌ ㅍ ㅎ

For example, 뷁 has initial consonant ㅂ, vowel ㅞ, and final consonant ㄺ.
South Korean dictionary order
The consonants and vowels above are sorted in South Korean dictionary order. The syllables are firstly sorted by initial consonants, secondly by vowels, and finally by (optional) final consonants.
The Unicode block for Hangul syllables contains every consonant/vowel combinations, and is entirely sorted in South Korean dictionary order.
The Unicode block can be seen here, and the first 256 characters are shown for illustrative purpose:

가각갂갃간갅갆갇갈갉갊갋갌갍갎갏감갑값갓갔강갖갗갘같갚갛개객갞갟갠갡갢갣갤갥갦갧갨갩갪갫갬갭갮갯갰갱갲갳갴갵갶갷갸갹갺갻갼갽갾갿걀걁걂걃걄걅걆걇걈걉걊걋걌걍걎걏걐걑걒걓걔걕걖걗걘걙걚걛걜걝걞걟걠걡걢걣걤걥걦걧걨걩걪걫걬걭걮걯거걱걲걳건걵걶걷걸걹걺걻걼걽걾걿검겁겂것겄겅겆겇겈겉겊겋게겍겎겏겐겑겒겓겔겕겖겗겘겙겚겛겜겝겞겟겠겡겢겣겤겥겦겧겨격겪겫견겭겮겯결겱겲겳겴겵겶겷겸겹겺겻겼경겾겿곀곁곂곃계곅곆곇곈곉곊곋곌곍곎곏곐곑곒곓곔곕곖곗곘곙곚곛곜곝곞곟고곡곢곣곤곥곦곧골곩곪곫곬곭곮곯곰곱곲곳곴공곶곷곸곹곺곻과곽곾곿

For example, the following sentence (without spaces and punctuations):
키스의고유조건은입술끼리만나야하고특별한기술은필요치않다

is sorted to:
건고고기끼나다리만별술술스않야요유은은의입조치키특필하한

In C++, if the string is in std::wstring, the sorting above is plain std::sort.
North Korean dictionary order
North Korean dictionary has different consonant/vowel order.
The initial consonants are sorted like:
ㄱ ㄴ ㄷ ㄹ ㅁ ㅂ ㅅ ㅈ ㅊ ㅋ ㅌ ㅍ ㅎ ㄲ ㄸ ㅃ ㅆ ㅉ ㅇ

The vowels are sorted like:
ㅏ ㅑ ㅓ ㅕ ㅗ ㅛ ㅜ ㅠ ㅡ ㅣ ㅐ ㅒ ㅔ ㅖ ㅚ ㅟ ㅢ ㅘ ㅝ ㅙ ㅞ

The final consonants are sorted like:
(none) ㄱ ㄳ ㄴ ㄵ ㄶ ㄷ ㄹ ㄺ ㄻ ㄼ ㄽ ㄾ ㄿ ㅀ ㅁ ㅂ ㅄ ㅅ ㅇ ㅈ ㅊ ㅋ ㅌ ㅍ ㅎ ㄲ ㅆ

Like South, the syllables are firstly sorted by initial consonants, secondly by vowels, and finally by (optional) final consonants.
If the sentence above is given, the output must be:
건고고기나다리만별술술스조치키특필하한끼않야요유은은입의

Rules

If the input contains a character not within U+AC00 – U+D7A3, it falls in don't care situation.
As this is a code-golf, the shortest code in bytes wins.

Partly related.

If that makes sense, I'd suggest to add a test case where the characters are sorted differently because of the final consonant exclusively (using ㄲ or ㅆ with the same initial consonant and the same vowel).

(More generally speaking, adding a few more test cases would be great.)

Suggested test cases: 가까나다따라마바빠사싸아자짜차카타파 (all initial consonants), 가개갸걔거게겨계고과괘괴교구궈궤귀규그긔기 (all vowels), 가각갂갃간갅갆갇갈갉갊갋갌갍갎갏감갑값갓갔강갖갗갘같갚갛 (all trailing consonants).

Well, so much for that... 86 different Korean SQL collations; all of them sort in the "South Korean" manner. Nice (tough) question.

05AB1E, 47 45 38 bytes
Σ•¡®šúIтÝ„Š’#„λ†x!·“•4B33¡€.ā`ââyÇ68+è

Try it online!
Σ                        # sort characters of the input by:
 •...•                   #  compressed integer 13096252834522000035292405913882127943177557
      4B                 #  converted to base 4: 211211121231211111033010101010231002310010331121111111111111111121111111
        33¡              #  split on 33: [2112111212312111110, 010101010231002310010, 1121111111111111111121111111]
           €.ā           #  enumerate each (pairs each digit with its index)
              `ââ        #  reduce by cartesian product (yields a list with 11172 elements)
                 yÇ      #  codepoint of the current character
                   68+   #  + 68
                      è  #  index into the large list (with wraparound)

JavaScript (ES6),  150 148  137 bytes
Saved 10 bytes thanks to @Grimy
I/O: arrays of characters.
a=>a.map(c=>"ANBCODEFPGQSHRIJKLM"[(n=c.charCodeAt()-44032)/588|0]+"AKBLCMDNERTOFGSUPHIQJ"[n/28%21|0]+~(n%28%18==2)+c).sort().map(s=>s[4])

Try it online!
Splitting Hangul syllables
Given a Hangul character of code point 0xAC00 + \$n\$, the initial consonant \$I\$, vowel \$V\$ and final consonant \$F\$ are given by:
$$I=\left\lfloor\frac{n}{588}\right\rfloor,\ V=\left\lfloor\frac{n}{28}\right\rfloor\bmod 21,\ F=n\bmod 28$$
Commented
a => a.map(c =>                  // for each character c in the input:
  "ANBCODEFPGQSHRIJKLM"[         //   start with a letter from 'A' to 'S'
    (n = c.charCodeAt() - 44032) //   for the initial consonant
    / 588 | 0                    //
  ] +                            //
  "AKBLCMDNERTOFGSUPHIQJ"[       //   append a letter from 'A' to 'U'
    n / 28 % 21 | 0              //   for the vowel
  ] +                            //
  ~(                             //   append "-2" for ㄲ or ㅆ (the only North
    n % 28 % 18 == 2             //   Korean final consonants that are sorted
  ) +                            //   differently) or "-1" otherwise
  c                              //   append the original character
)                                // end of map()
.sort()                          // sort in lexicographical order
.map(s => s[4])                  // isolate the original characters

Charcoal, 80 bytes
Ｆ”&→∧⁶⍘⎚%γD¦ρJG”Ｆ”E⎇↓Ｎη⊙��⭆Ｗs@}4”Ｆ”E↖hＹ9 t⟧⊙γIO↶5ε∧¬⁶⦃”Φθ⁼℅μΣ⟦⁴⁴⁰³²×⌕βι⁵⁸⁸⍘⁺κλ²⁸

Try it online! Link is to verbose version of code. Explanation: Works by generating all 11172 Hangul syllables in North Korean dictionary order and checking to see which ones are present in the input (so all other characters get deleted; also somewhat slow: takes 18 seconds on TIO). Explanation:
Ｆ”&→∧⁶⍘⎚%γD¦ρJG”

Loop over the compressed string acdfghjmopqrsbeiknl. This represents the list of South Korean initial consonants (numbered using the Western lowercase alphabet) in North Korean dictionary order.
Ｆ”E⎇↓Ｎη⊙��⭆Ｗs@}4”

Loop over the compressed string 02468cdhik1357bgj9eaf. This represents the list of South Korean vowels (numbered using ASCII digits and lowercase alphabet) in North Korean dictionary order.
Ｆ”E↖hＹ9 t⟧⊙γIO↶5ε∧¬⁶⦃”

Loop over the compressed string 013456789abcdefghijlmnopqr2k. This represents the list of South Korean final consonants (using the same numbering as the vowels) in North Korean dictionary order.
Φθ⁼℅μΣ⟦⁴⁴⁰³²×⌕βι⁵⁸⁸⍘⁺κλ²⁸

Concatenate the vowel and final consonant and decode as a base 28 number, then add on 588 times the initial vowel and 0xAC00. Print all characters from the input that have that as their ordinal.

Are the replacement characters valid syntax?

@DannyuNDos It represents byte value \xFF in Charcoal's code page.