text:
I forgot towel day
I forgot towel day
Sandbox link
PHP script for both examples (error, formatting the string)
Corrected php script, the input is self explanatory
PHP script with more input comment/uncomment $argv to see different results
As you may know, May 25 is well known as Towel Day, because of the many uses a towel can have.
A simple extract of the book "The Hitchhiker's Guide to the Galaxy" (personally I took this book as an "everyday guide") states:

"A towel is about the most massively useful thing an interstellar hitchhiker can have. Partly it has great practical value."

If you need more information about towels check this SE.scifi answer

The Challenge
Hopefully you will do this with a towel used as a blanket for your legs.
Write a full program or function in any valid programming language that takes two inputs
size        Integer  : #The size
message     string   : #A sentence

How to draw a towel with these values?
First using size:
Draw a towel depending on the size input, ascii-art for our towel
  width = 12*size

  #the line that has the "bar" its always present with different sizes

  Width is defined as:
  from the first | to the second | has to be equal to size*12 including both ||

      <-   width->
  [===|          |====]
      | 12 chars ||   1  height starts here, just after the "bar"
      | SIZE = 1 ||   2
      |          ||   3   height = 5*size
      |          ||   4
      |          ||   5  height ends here just before the first line |=======|
      |==========||   # the lines with the #
      |==========||   # are always fixed
      """"""""""""|   # it means, every towel
       |          |   # always has this 5 rows
       """"""""""""   # no matter the size

Second, give it the message
You have to give it a message, what is a towel without a beautiful message sewed in golden thread?
Example 1
  input: size=1, message="a simple message can stay with size"

  width = 12*size

  #the line that has the "bar" it's always present with different sizes
  #no words allowed at the bar level

  [===|          |====]
      | a simple ||   1  height starts here, just after the "bar"
      | message  ||   2
      | can stay ||   3   height = 5*size
      | with size||   4
      |          ||   5  height ends here just before the first line |=======|
      |==========||   # the lines with the #
      |==========||   # are always fixed
      """"""""""""|   # it means, every towel
       |          |   # always has this 5 rows
       """"""""""""   # no matter the size

Example 2
input size=2
message="Don't Panic and bring a towel to SE Programming Puzzles and CodeGolf"

The size is 2
That means 24 width and 10 heigth

    <-    24 chars width  ->
[===|                      |====]
    | Don't Panic and bring||   1
    | a towel to SE        ||   2
    | Programming Puzzles  ||   3
    | and CodeGolf         ||   4
    |                      ||   5
    |                      ||   6
    |                      ||   7
    |                      ||   8
    |                      ||   9
    |                      ||   10
    |======================||   #  The lines with the "#"
    |======================||   #  always present and
    """"""""""""""""""""""""|   #  adapted to
     |                      |   #  the towel width
     """"""""""""""""""""""""   #

Accepted answer criteria

This is codegolf so normal rules apply.

Rules

You are guaranteed that all the input strings will fit the size, so no input like size=1; message="This string is just tooooooooooooooooooooo long to fit the width and height of your towel".
The string format is up to you, if you want to center the substrings for example.
Word-breaks are disallowed.

Edits
I am truly sorry about any confussion, because the ansii towels i draw did not matched the parameters, added a PHP script for both examples for you to check the expected outputs.
Also thank you to all the people who voted up and considered my first challenge :D.

Give me a few minutes to fix it (just saw this). What happened was that i made a program on php to draw the towel but it was much simpler than the one i presented, i had a program for the examples and  i forgot to modify it.

@Lynn added a php ungolfed solution with both test cases, sorry about any confussion.

Can we choose where the line breaks go?

The line break should be added when the current line + next word will exceed the limit  permited for your towel @Jakob as the php script i posted it decides.

can we take the proper text width and/or height as arguments instead of computing them?

@JohnM the height and width of your tower are defined by the input: size (integer) part of the challenge is to format the string so it can fit wittin that area, but as u can see here the input string always will fot the towel size. Is part of the condition for the challenge.

Python 2, 223 210 209 204 bytes
def f(s,m):w=12*s-2;l='    |';print'[===|'+' '*w+'|====]';exec"j=(m+' ').rfind(' ',0,-~w);print l+'%*s||'%(w,m[:j]);m=m[j+1:];"*s*5;print(l+w*'='+'||\n')*2+' '*4+'"'*12*s+'|\n '+l+' '*w+'|\n    ','"'*12*s

Try it online!

JavaScript (Node.js), 375 bytes
This is the worst submission you will get, but at least I tried xD half of bytes are spaces though
(s,_,w=12*s-2,h=5*s)=>`
[===|${j=' '.repeat(w)}|====]
${[...Array(h)].map((g,i)=>_.split` `.reduce((a,b)=>((l=a.split`,`)[l.length-1]+b).length>w-1?a+','+b:a+' '+b,'').split`,`[i]).map(a=>`    |${a?(r=a.length)<w?a+' '.repeat(w-r):a:j}||    `).join`\n`+
`
    |${'='.repeat(w)}||    `.repeat(2)}
    ${y='"'.repeat(w+2)}|
     |${j}|
     ${y}
`

Try it online!

JavaScript (Node.js), 347 345 343 337 334 328 326 bytes
b=>d=>`
[===|${M=" "[X="repeat"](c=12*b-2)}|====]
${[...Array(5*b)].map((a,b)=>d[Y="split"]` `.reduce((a,b)=>((l=a[Y]`,`)[l[Z="length"]-1]+b)[Z]>c-1?a+","+b:a+" "+b)[Y]`,`[b]).map(a=>`    |${a?(r=a[Z])<c?a+" "[X](c-r):a:" "[X](c)}||    `).join`
`+`
    |${"="[X](c)}||    `[X](2)}
    ${y='"'[X](c+2)}|
     |${M}|
     ${y}
`

Try it online!

Explanation :
b =>                                   // lambda function taking arg 1 : size
    d =>                               // arg 2 : message
        `                              // begin string template for drawing
[===|${                                // draw first part and now open literal
        M = ' '[X='repeat'(c=12*b-2)]  // set 3 variables, M, X , c to be used again
    }|====]                            // close and draw the next part ====]
${[...Array(5*b)]                      // open and create an array of length 5 * b =width
.map(a,b=>                             // begin map function two args : a,b
        d[Y='split']` `                // use d(message), split at whitespace, set to Y
.reduce((a,b) =>                       // reduce to single value, arg 1 : a, arg 2 : b
        ((l = a[Y]`,`)                 // declare l and then find in l
        [l[Z='length']-1]              // set Z as length
        + b)                           // add value of b
        [Z]                            // find the length
        > c-1 ?                        // check if it's less than c - 1
        a+','+b                        // then add `${a},${b}`
        : a + ' ' + b                  // otherwise `${a} ${b}`
        )[Y]`,`                        // close and split at comma
        [b]                            // use b again
        )                              // close
        .map(a =>                      // map over that arg 1 : a
                `    |${               // four space + | and open
        a ?                            // if a is true or a truthy value
            (r=a[Z])                   // set value of r as a's length
            < c ?                      // check if it's less than c
                a+' '[X](c-r)          // then draw a + space repeated c-r times
                : a + ' '[X](c)        // else draw a + space repeated c times
            }                          // close
            ||    `                    // add || and 4 spaces and close
        )                              // end
        .join`
`                                      // and turn to string with new line as separator
    +                                  // add to that
    `
    |{                                 // new line , 4 spaces and |
        '='[X](c)}                     // repeat = c times
        ||    `[X](2)}                 // and repeat that 2 times
    ${                                 // new line + 4 space
    y = '"'[X](c+2)                    // repeat " c + 2 times and set to y
    }|                                 // close and add |
    |{                                 // add | and open
        M}|                            // put M and close and add |
    {y}                                // new line , 4 spaces and variable y
`                                      // end with new line.

Charcoal, 79 bytes
Ｎθ≔×⁵θε≔×¹²θδ←Ｐ←====[↓⁺³ε×"δ↖Ｐ↑⁺³ε←Ｇ↑²←⁻δ²↓²=↓↓↓¹×"δ↖↑⁺⁴ε====]Ｆ⪪Ｓ «×⸿›⁺ⅈＬι⁻δ² ι

Try it online! Link is to verbose version of code. Explanation:
Ｎθ≔×⁵θε≔×¹²θδ

Calculate the size of the towel.
←Ｐ←====[↓⁺³ε×"δ↖Ｐ↑⁺³ε←Ｇ↑²←⁻δ²↓²=↓↓↓¹×"δ↖↑⁺⁴ε====]

Draw the towel.
Ｆ⪪Ｓ «

Loop over each word of the message.
×⸿›⁺ⅈＬι⁻δ² ι

Print each word without overflowing the width.

Marvelous, and thank you for taking your time for the challenge.

V, 142, 128, 121, 119 bytes
:let @h=5*@a
:let @w=12*@a-2
O[===|@wá 4á=á]
:set tw=w
Vgq@hï{+@hjI    |kf|@hjjyt=pjp+@hjkl@wr=Ùjlr|Ù@w««r"YkP0xÁ|

Try it online!

This is the kind of code i would love to say "Hey, if you do this you can save n Bytes"....but i can't...yet :D.


text:
Divide two strings
One day, I saw the challenge to multiply two strings and I thought I might be able to do one better.
That challenge was fake. It was elementwise maximum. It was not real multiplication. So I set out to make something real. Real division between two strings.
I quickly realized that this would make an amazing challenge, as the algorithm was surprisingly complex and interesting to implement.
I then realized that it was actually easily reduced into a mere few operations. I'm still doing the challenge, though.
Enough with the backstory. Let's go.
Method
To divide two strings, do the following, where x is the first string and y the second:

If x does not contain y, return a space and a period concatenated to x.

For example, testx and blah would become .testx, with a space at the beginning.

Otherwise, return every occurrence of y in x, a period, then y divided by x with every occurrence of y removed, with all the periods removed.

For example, eestestst and est would become estest.est.

Challenge
Write a program or function that, given two strings via standard input, returns the first string divided by the second.
You may assume that both input strings will only contain letters between ASCII codepoints 33 and 45, and between codepoints 47 and 126 (yes, space and period are intended to be excluded), and that the operation does not require more than 10 layers of recursion.
You are not required to divide the empty string by itself.
Test cases
test, es => es. es
test, blah =>  .test
okayye, y => yy. y
testes, es => eses. es
battat, at => atat. at
see, es =>  .see
see, e => ee. e
same, same => same.
aabb, ab => ab.ab
eestestst, est => estest.est
aheahahe, aheah => aheah.aheah ah
-={}[];:"'!@#$%^&*()~`\|/.<>_+?, ^&*()~` => ^&*()~`. ^&*()~`
best,  => .

Scoring
As this is code-golf, the submission with the least amount of bytes wins.

Can we assume that the input strings only contain characters from a to z? 2. Why isn't the output of the first one es.tt? 3. Why is there a space after the periods in your testcases?

No, besides the assumptions already listed. As for
2 and 3, note that the solution is recursive. test and es is es divided by tt, which is .es as tt is not in es, and the period is removed. A similar thing happens for the other testcases with spaces. Note that the presence of a period after a period varies.

Then can you include testcases with characters other than a to z? What exactly are the characters that will appear? Can you phrase it in a positive instead of a negative?

Why is same.  the output of same, same?

@LeakyNun Because same, same is same. concatenated to same divided by nothing, which is . concatenated to nothing divided by same, which is  . concatenated to nothing. We remove the period again and get just a space, which we put onto the original same. to get same. .

Can you include a test case of dividing by nothing?

Yes. Thank you for reminding me, I was about to do that but got sidetracked.

Your .testx string reads .textx instead.

Python 2, 88 85 84 77 bytes
f=lambda x,y,d='.':y in x and y*x.count(y)+d+f(y,x.replace(y,''),'')or' '+d+x

Try it online!

Saved

-1 byte, thanks to LyricLy
-7 bytes, thanks to Dead Possum

84 bytes by removing unneeded parentheses.

77 bytes

@DeadPossum wow clever, thanks ;)

I'm not sure of an implementation yet, but perhaps you can use the fact that y*x.count(y) returns a falsy value to drop the y in x check?

Java (JDK 11), 146 bytes
String f(String x,String y){int c=x.replace(y," ").split(" ",-1).length-1;return c<1?" ."+x:y.repeat(c)+"."+f(y,x.replace(y,"")).replace(".","");}

Try it online using Java 10! This TIO emulates String::repeat of Java 11 by writing Kevin Cruijssen's implementation as a helper method with the same amount of bytes.
Explanations
String f(String x,String y){                     //
  int c=x.replace(y," ").split(" ",-1).length-1; // Count the number of occurrences of y in x.
                                                 // replace(y," ") fixes the issue on special characters for the split hereafter
                                                 // .split(" ",-1) makes sure that there are trailing elements
  return c<1
    ?                                            // If there are no occurrence, return
      " ."+x                                     // " ."+x
    :                                            // Else return
        y.repeat(c)                              // y, c times
      + "."                                      // append a dot
      + f(y,x.replace(y,"")).replace(".","");    // y divided by x without y, and remove all dots
}

String.repeat(int) only exists since Java 11, hence the JDK 11 header. Alas and to my knowledge, there are currently no Java 11 online compiler / tester...

For anyone wondering: Prove it indeed works by replacing y.repeat(c) with new String(new char[c]).replace("\0",y).

Thanks @KevinCruijssen I'll integrate that in my answer. I should have done that, actually...

@KevinCruijssen Thank you, I've been doing this quickly on the side and didn't check better. My bad. The random ascii characters don't work probably because they contain special characters used in regex (implicitly used by split). I'll try to fix this.

Ah of course, the split. Hmm, java.util.regex.Pattern.quote(y) is a potential solution, it's pretty dang long, though.. :(

How about using x.replace(y," ").split(" ",-1)?

Works like a charm! Thanks @Jakob, that's very imaginative!

Python 2, 72 bytes
lambda f,s:(s*f.count(s)+'.'*(s in f))+s*(s in f)+(' .'+f)*(f.find(s)<0)

Proton, 75 bytes
f=(x,y)=>(u=x.count(y))?y*u+'.'+f(y,x.replace(y,'')).replace('.',''):' .'+x

Try it online!

Physica,  81 75  67 bytes
f=>x;y;d='.':y∈x&&y*x.count[y]+d+f[y;Replace[x;y;''];'']||' '+d+x

Try it online!
Utilizes Dead Possum's golfs on TFeld's answer.

Retina, 105 bytes
¶.*$
$&¶.
/^(.*)¶.*\1/{*>|""L`(?<=(.*)¶.*)\1|\.$
(?<=(.*)¶.*)\1|\.$

)`(.*)¶(.*)
$2¶$1
.*¶(.*)¶(.*)
 $2$1

Try it online! Link includes test suite, but code normally takes y then x on separate lines. Explanation:
¶.*$
$&¶.

Append a newline and a . This expression is cumbersome in order to deal with an empty second input, where $ would otherwise match twice.
/^(.*)¶.*\1/{

Repeat while x contains y.
*>|""L`(?<=(.*)¶.*)\1|\.$

Output all of the matches of y in x, plus the . on the first pass.
(?<=(.*)¶.*)\1|\.$

And then delete them all.
)`(.*)¶(.*)
$2¶$1

Swap over x and y and repeat.
.*¶(.*)¶(.*)
 $2$1

Output the . if x never contained y, and y.

JavaScript (Babel Node), 90 bytes
Based on Olivier Grégoire Answer
(_,x)=>(l=_.match(RegExp(x,`g`)))?l.join``+`.`+f(x,_.replace(x,'')).split`.`.join``:` .`+_

Try it online!

Stax, 28 bytes
Çûù=a┐µ¬▄↑ivÜ°{⌐╨[£èvÇu┴▓<v~

Run and debug it

source: Stack Exchange

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

sort: votes


text:
Decoding the Kaadi system
You have come across an old Indian manuscript, one that describes mounds of buried treasure. The manuscript also tells you the location of the treasure, except that some crucial numbers have been encoded indirectly into the text. You figure out that the text uses a 'Kaadi' system, a restricted subset of the more common 'Katapayadi' system.
(The Katapayadi system is an ancient Indian system to encode numerals as letters, often used as mnemonics to remember long numbers.)
Your task here is to decode text encoded in the Kaadi system and print out the numerical value.
Details
Input characters
The Kaadi system is based on the Katapayadi system's rules, but uses only the first row of consonants. Your text here has been transliterated to Latin alphabet, and is known to contain only:

vowels 'a','e','i','o','u'
consonants 'g','k','c','j', and their capital forms (to represent the aspirated form of those consonants), and 'ṅ' and 'ñ'.

(You may choose to receive and handle 'ṅ' as 'ng' and 'ñ' as 'ny' if that's more convenient in your language.)
Value assignment
In this system,

each consonant when followed by a vowel has a digit associated with it. These are:
'k'=>1, 'K'=>2,
'g'=>3, 'G'=>4,
'ṅ'=>5,
'c'=>6, 'C'=>7,
'j'=>8, 'J'=>9,
'ñ'=>0

Note however, that these values apply only when these consonants are followed by a vowel. kacCi has the same value as kaCi (ka,Ci=(1,7)) since the middle c is unaccompanied by a vowel.

Additionally, an initial vowel or sequence of two vowels represents a 0. aikaCi would be: ai,ka,Ci = (0,1,7)
Extra vowels anywhere else in the middle of the text have no value: kauCia is the same as kaCi, the extra vowels can be ignored.

Final numeric value
Once the digit values of the letters have been figured out, the final numerical value is obtained as the reverse order of those digits i.e. the first digit from the text is the least significant digit in the final value.
Eg.
GucCi has Gu and Ci, so (4, 7), so the final value is 74.
kakakaGo is (1,1,1,4), so the the answer is 4111.
guṅKo is (3,2), so encodes 23. (gungKo if using ASCII-equivalent.)
Input

A string containing a Kaadi-encoded text

will contain only vowels and the above consonants
the vowels are always in lowercase and occur in groups of no more than 2
you may choose to accept the letters for 5 and 0 either as their Unicode characters 'ṅ' and 'ñ' or as their ASCII equivalents 'ng' and 'ny' (they're in lowercase in either form)
you may assume there are no spaces or punctuations

Output

The numerical value of the text, as given by the above rules

for empty input, an empty output or any false-y output in your language of choice is acceptable, in addition to 0
for invalid input (input with anything other than vowels and the above consonants), the output is undefined - anything goes

Test cases
"GucCi"
=> 74
"kakakaGo"
=> 4111
"aiKaCiigukoJe"
=> 913720
""
=> 0 //OR empty/falsey output
"a"
=> 0
"ukkiKagijeCaGaacoJiiKka"
=> 1964783210
"kegJugjugKeg"
=> 2891
"guṅKo"
=> 23
"Guñaaka"
=> 104
"juñiKoṅe"
=>5208

(the last ones can be:
"gungKo"
=> 23
"Gunyaaka"
=> 104
"junyiKonge"
=>5208

if you prefer that.)
Standard rules for I/O and loopholes apply. May the best golfer win!

Can aiaKaci be input? (3 leading vowels)

There is also no test case which ends in a consonant; can we assume the input will always end in a vowel?

No for 3 leading vowels. In fact, I don't think it makes sense for 3 consequent vowels to occur anywhere in the input (2 English vowels are sometimes needed to represent one Sanskrit vowel sound, but never 3). Can I add that in as an input constraint now or is it too late?

Input can end in a consonant, I'll add a test case for that.

It's not too late to clarify that the input won't have 3 leading vowels. That won't break any submissions, and I doubt anyone have written longer code to take that into account, and if they have they can simply remove it. Nice first question by the way! :)

In case it helps in some languages: ord(c)%47%10 gives a unique index in [0..9] for each consonant. (With ord("ṅ")=7749 and ord("ñ")=241.)

JavaScript (ES6), 83 bytes
s=>s.replace(s=/(^|[ṅcCjJñkKgG])[aeiou]/g,(_,c)=>o=(s+s).search(c)%10+o,o='')&&o

Try it online!
How?
We use the following regular expression to match either the beginning of the string or one of the Kaadi consonants, followed by a vowel:
/(^|[ṅcCjJñkKgG])[aeiou]/g

For each match in the input string, we invoke the following callback function that takes the content c of the capturing group as parameter:
(_, c) => o = (s + s).search(c) % 10 + o

We find the value of the consonant by looking for its position in the regular expression (coerced to a string by adding it to itself).
The consonants are ordered in such a way that their value is equal to their position modulo 10:
string   : /  (  ^  |  [  ṅ  c  C  j  J  ñ  k  K  g  G  ]  )  [  a  e  i  o  u  ]  /  g
position : 0  1  2  3  4  5  6  7  8  9  10 11 12 13 14 15 ...
modulo 10: -  -  -  -  -  5  6  7  8  9  0  1  2  3  4  -  ...

When we match the beginning of the string instead of a consonant, c is an empty string whose position in the regular expression is 0 -- which, conveniently, is the expected result in that case.
Finally, we insert this digit at the beginning of the output string o.

Retina, 41 bytes
T`ñkKgGṅcCjJ`d`.[aeiou]
^[aeiou]
0
\D

V`

Try it online! Link includes test cases. Explantion:
T`ñkKgGṅcCjJ`d`.[aeiou]

Translate the consonants that are followed by vowels.
^[aeiou]
0

Handle a leading vowel.
\D

Delete everything else.
V`

Reverse the result.

Python 2, 93 bytes
lambda s,h=u'ñkKgGṅcCjJ'.find:''.join(`h(c)`*(0>h(v)<h(c))for c,v in zip(u'ñ'+s,s))[::-1]

An unnamed function accepting a Unicode string which returns a string representation of the base ten result.
Try it online!

Java 8, 136 126 bytes
s->{for(int i=s.length,t;i-->0;)if("aeiou".contains(s[i]))System.out.print(i<1?0:(t="ñkKgGṅcCjJ".indexOf(s[i-1]))<0?"":t);}

Try it online.
Explanation:
s->{                           // Method with String-array parameter and String return-type
  for(int i=s.length,t;i-->0;) //  Loop backwards over the input-characters
    if("aeiou".contains(s[i])) //   If the current character is a vowel:
      System.out.print(        //    Print:
         i<1?                  //     If we're at the first character:
          0                    //      Print a 0
         :                     //     Else:
          (t="ñkKgGṅcCjJ".indexOf(s[i-1]))<0?
                               //      If the character before the vowel is also a vowel:
           ""                  //       Print nothing
          :                    //      Else:
           t);}                //       Print the correct digit of the consonant

Python 2, 101 bytes
lambda s,S=u'ñkKgGṅcCjJ':''.join(`S.find(c)`for c,n in zip(u'ñ'+s,s)if c in(n in'aeiou')*S)[::-1]

Try it online!
Python 3, 104 102 bytes
lambda s,S='ñkKgGṅcCjJ':''.join(str(S.find(c))for c,n in zip('ñ'+s,s)if c in(n in'aeiou')*S)[::-1]

Try it online!

Saved

-3 bytes, thanks to Rod

Well, you can if you add the header, but I forgot the unicode prefix in the strings, after all, it would save a single byte

@Rod, ah thanks, I'd forgotten about the unicode prefix :)

Jelly, 27 bytes
Żµe€Øẹœpṫ€0F“kKgGṅcCjJ”iⱮUḌ

Try it online!
Jelly has built-in for... 1-byte ṅ.
Explanation

Żµ             Prepend 0 to the string.
  e€  œp       Split at...
    Øẹ           the vowels. (0 is not a vowel)

ṫ€0            For each sublist `l` takes `l[-1:]`.
                 If the initial list is empty the result is empty,
                 otherwise the result is a list contain the last element.
   F           Flatten. (concatenate the results)

“kKgGṅcCjJ”iⱮ  Find the index of each character in the list.
                 Get 0 if not found (i.e., for `0` or `ñ`)
UḌ             Upend (reverse) and then convert from decimal.

I didn't find a way to save bytes with that, but O%47%10 gives a unique index in [0...9] for each consonant. (Which means that O%47 with the implicit modulo of ị would allow to pick up the correct value in an array of 10 entries.)

@Arnauld 6;µe€Øẹœpṫ€0O%47ị“ ʠḷ’Œ?’¤Ṛ but also 27 unless it can be golfed.

JavaScript (Node.js), 126 bytes
_=>(l=_.match(/[kgñṅcj][aeiou]/gi))?l.map(a=>"ñkKgGṅcCjJ".indexOf(a[0])).reverse``.join``+(/[ aiueo]/.test(_[0])?0:''):0

Try it online!

you can save a few bytes by changing x=[..."ñkKgGṅcCjJ"] to just x="ñkKgGṅcCjJ" since indexOf works with Strings too

This doesn't seem to treat initial vowels as 0, so fails the test cases 3 and 6 (as can be seen in the Output on TIO).

@sundar My bad, Fixed.

Red, 152 143 bytes
func[s][t:"ñkKgGṅcCjJ"c: charset t
d: copy{}parse s[opt[1 2 not c(alter d 0)]any[copy n c not c(insert
d(index? find/case t n)- 1)| skip]]d]

Try it online!
Readable:
f: func[s] [
    t: "ñkKgGṅcCjJ"
    c: charset t
    d: copy {}
    parse s [
        opt [ 1 2 not c (alter d 0) ]
        any [
              copy n c not c (insert d (index? find/case t n) - 1)
            | skip
        ]
    ]
    d
]

MATL, 48 47 45 bytes
'ng'98Ztt'y'whw11Y2m)'ykKgGbcCjJ'tfqXEt10<)oP

Try it online!
('b' instead of 'd' to save a byte)
(-2 bytes thanks to Luis Mendo)
MATLAB (and hence MATL) treating strings as a dumb series of bytes made porting @TFeld's Python solution harder than I imagined (maybe a straight loop solution would have been easier here?). Ended up using the alternate 'ng', 'ny' input method, and replacing ng with b at the beginning for easier processing.
Explanation:
        % Implicit input (assume 'junyiKonge')
 'ng'   % string literal
 98     % 'b'
 Zt     % replace substring with another (stack: 'junyiKobe')
 t      % duplicate that (stack: 'junyiKobe' 'junyiKobe')
 'y'    % string literal
 w      % swap elements in stack so 'y' goes before input (stack: 'junyiKobe' 'y' 'junyiKobe')
 h      % horizontal concatenation (prepend 'y' to input string) (stack: 'junyiKobe' 'yjunyiKobe')
 w      % swap stack (stack: 'yjunyiKobe' 'junyiKobe')
 11Y2   % place 'aeiou' in stack (stack: 'yjunyiKobe' 'junyiKobe' 'aeiou')
 m      % set places with a vowel to True i.e. 1 (stack: 'yjunyiKobe' 0 1 0 1 0 1 0 0 1)
 )      % index into those places (stack: 'jyKd')
 'ykKgGdcCjJ' % string literal
 tfq    % generate numbers 0 to 9 (stack: 'jyKd' 'ykKgGdcCjJ' 0 1 2 3 4 5 6 7 8 9)
 XE     % replace elements in first array which are found in second,
        %  with corresponding elements from third
 t10<)  % keep only elements that are less than 10 (removes extraneous vowels)
 o      % convert from string to double (numeric) array (stack: 8 0 2 5)
 P      % flip the order of elements (stack: 5 2 0 8)
        % (implicit) convert to string and display

Thanks, done. Do you know if MATLAB/Octave has anything to index into/iterate through a string across Unicode codepoints instead of bytes? Doesn't look like it, their Unicode support seems atrociously bad in general, but maybe I missed something.

Also, the MATL manual mentions " if input is a string or character array" in a couple of places - are those two different things? Anything to do with the fancy new double-quoted strings in MATLAB?

Matlab has unicode2native, but I think that's now what you want. I agree, Unicode support in MATLAB is not the best. And don't get me started with Octave :-D As for MATL, it was designed before the new string data type existed in MATLAB (and I don't like it much anyway), so in MATL a "string" is the same as it used to be in old MATLAB versions: a row vector of chars. I've made a note to clarify that in the documentation, thanks for noticing!

Stax, 27 bytes
âΔxñW⌡╪c§âaQ&δ▓äHê╠$╞╣;→◄vΓ

Run and debug it

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


text:
Count the number of fields in each csv record
Imagine a text file where each  csv record may have different numbers of fields.   The task is to write code to output how many fields there are in each record of the file. You can assume there is no header line in the file and can read in from a file or standard input, as you choose.
You can assume a version of rfc4180 for the csv rules which I will explain below for the definition of each line of the file.  Here is a lightly edited version of the relevant part of the spec:
Definition of the CSV Format

Each record is located on a separate line, delimited by a line
break (CRLF).  For example:
aaa,bbb,ccc CRLF

zzz,yyy,xxx CRLF

The last record in the file may or may not have an ending line
break.  For example:
aaa,bbb,ccc CRLF

zzz,yyy,xxx
(Rule 3. does not apply in this challenge)

Within each record, there may be one or more
fields, separated by commas.   Spaces are considered part
of a field and should not be ignored.

Each field may or may not be enclosed in double quotes.  If fields are not enclosed with double quotes, then double quotes may not appear inside the fields.  For example:
"aaa","bbb","ccc" CRLF

zzz,yyy,xxx

Fields containing line breaks (CRLF), double quotes, and commas
should be enclosed in double-quotes.  For example:
"aaa","b CRLF

bb","ccc" CRLF
zzz,yyy,xxx

If double-quotes are used to enclose fields, then a double-quote
appearing inside a field must be escaped by preceding it with
another double quote.  For example:
"aaa","b""bb","ccc"

Example
Input:
,"Hello, World!"
"aaa","b""bb","ccc"
zzz,yyy,
"aaa","b
bb","ccc","fish",""

Should give the output:
2, 3, 3, 5

Your can give the output values in any way you find most convenient.
Libraries
You can use any library you like.

Awesome answers so far but we are missing a command line/bash answer which would be particularly cool.

Stax, 19 12 bytes
èJ§3‼}vAà○L>

Run and debug it
Unpacked, ungolfed, and commented, it looks like this.
_'"/    split *all* of standard input by double quote characters
2::     keep only the even numbered elements
|j      split on newlines (implicitly concatenates array of "strings")
m       for each line, execute the rest of the program and output
  ',#^  count the number of commas occurring as substrings, and increment

Run this one

How does it work?

@Anush: I've added some more information.

R, 40 bytes
(x=count.fields(stdin(),","))[!is.na(x)]

Try it online!
Per the documentation of count.fields, fields with line breaks get a field count of NA for the initial line, so we filter them out.

JavaScript (ES2018), 42 59 bytes
s=>s.replace(/".+?"/sg).split`\n`.map(c=>c.split`,`.length)

f=
s=>s.replace(/".+?"/sg).split`\n`.map(c=>c.split`,`.length)

console.log(f(
`,"Hello, World!"
"aaa","b""bb","ccc"
zzz,yyy,
"aaa","b
bb","ccc","fish",""`))

Technically this is ES2018 due to the s flag on the regex. Not that it matters that much ;-) And nice use of it, btw!

This function only appears to work on one record at a time.  I think the problem description requires handling an entire file of multiple records.

@ETHproductions, good point, will update.

@recursive, you're right, I misunderstood the inputs.  Now updated, at the loss of many many bytes.

Jelly, 12 bytes
ṣ”"m2FỴ=”,§‘

A port of recursive's Stax answer - go give credit!
Try it online!
How?
ṣ”"m2FỴ=”,§‘ - Link: list of characters, V
 ”"          - a double quote character = '"'
ṣ            - split (V) at ('"')
   m2        - modulo slice with two (1st, 3rd, 5th, ... elements of that)
     F       - flatten list of lists to a list
      Ỵ      - split at newlines
        ”,   - comma character = ','
       =     - equal? (vectorises)
          §  - sum each
           ‘ - increment (vectorises)
             - (as a full program implicit print)

Maybe you prefer ṣ”"m2ẎỴċ€”,‘ - Ẏ is tighten and ċ€ counts the commas in each.

Perl 5.10.0, 55 53 bytes
$_=shift;s/"(""|[^"])*"//g;s/^.*$/1+$&=~y:,::/gem;say

Try it online!
Explanation:
$_=shift;          # first command-line arg
s/"(""|[^"])*"//g; # remove quoted fields
s/^.*$/            # replace each line
  1+$&=~y:,::      # by the number of commas plus 1
/gem;
say                # print

Python, 63 bytes
import csv
def f(s):return map(len,csv.reader(s.split("\n"))

Returns the output in an iterable map object.

Using a lambda function you can get this down to 54 bytes

Wolfram Language (Mathematica), 30 bytes
Length/@ImportString[#,"CSV"]&

Try it online!

Java 10, 101 bytes
s->{for(var p:s.replaceAll("\"[^\"]*\"","x").split("\n"))System.out.println(p.split(",",-1).length);}

Try it online.
Explanation:
s->{                                    // Method with String parameter and no return-type
  for(var p:s.replaceAll("\"[^\"]*\"","x")
                                        //  Replace all words within quotes with an "x"
             .split("\n"))              //  Then split by new-line and loop over them:
    System.out.println(p.split(",",-1)  //   Split the item by comma's
                        .length);}      //   And print the length of this array

Jelly, 17 bytes
=”"ÄḂżṣ⁷Ż¤ṣ€0,”,Ẉ

Try it online!
-1 thanks to Jonathan Allan. duh duh duh...

POSIX shell (ShellShoccar-jpn/Parsrs + usp-engineers-community/Open-usp-tukubai), 19 bytes
Dependencies are

parsrc.sh Version : 2017-07-18 02:39:39 JST
count Version : Fri Oct 21 11:26:06 JST 2011

parsrc.sh|count 1 1

Output format
For each line, the following line is output:
<row number> <number of columns>

How it works
parsrc.sh is a parser for CSV who converts such text into list of cells and their value.
Open-usp-tukubai's count takes a range of field number from parameters and space-separated values to count in such range to summarize.
Here are some comments:
# raw CSV
parsrc.sh |
# 1: row number 2: column number 3: value where LFs are represented as "\n" while real backslashes as "\\"
count 1 1
# 1: row number 2: number of columns in the row

Example run on Termux
Because Termux is not a completely POSIX-compatible so command -p getconf PATH fails, I am dropping the boilerplate to set PATH environment variable so the shell calls completely POSIX-compatible utilities first. Also because I am lazy to prepare Python 2, I am doing with COMMANDS.SH/count.


text:
A Capital Cipher
Your task is to decipher a non-empty string consisting of printable ASCII characters in the range [32..126].
Reading the string character per character:

each time you encounter a letter in lowercase, associate it with the next letter in uppercase, starting with 'A'
each time you encounter a letter in uppercase, replace it with the letter in lowercase it's associated with
other characters do not require any special processing and are just left unchanged

Example
For the input string "endlAsEBAEE":

Associate e to A, n to B, d to C and l to D
Replace A with e
Associate s to E
Replace EBAEE with sness

The final output is "endlessness".
Clarifications and rules

The input string is guaranteed to contain each lowercase letter at most once. All further instances will be replaced with the corresponding capital letter.
The input string is guaranteed to be valid. (You will not encounter a capital letter that is not yet associated with a lowercase letter.)
Once a capital letter has been associated to a lowercase letter, it may or may not be used later in the string. For instance, C and D are not used in the above example.
This is code-golf, so the shortest answer in bytes wins!

Test cases
Inputs:
abcd
honk! ABCD!
abrAcAdABCA
endlAsEBAEE
helCo wDrCd!
dermatoglyphics
progBamFinD AuzJles & cCdL DCKf
sphinx of black quKrtz, jOdge my vGw. K NODLM IPGZE HGF SOWBA GYVP QCV JKRX TGU.
petBr AiABD AEckBd a ABFG of AEFGlBH ABAABDs. hJw mIny AEFGLBH ABAABDM HEH ABCBD AEABD AEFG?

Answers:
abcd
honk! honk!
abracadabra
endlessness
hello world!
dermatoglyphics
programming puzzles & code golf
sphinx of black quartz, judge my vow. a quick brown fox jumps over the lazy dog.
peter piper picked a peck of pickled peppers. how many pickled peppers did peter piper pick?

I think the inverse of this task - encoding a string of lowercase + punctuation -  would also make an interesting challenge.

Jelly, 8 7 bytes
fØaØA,y

Try it online!
How it works
fØaØA,y  Main link. Argument: s (string)

 Øa      Yield the lowercase alphabet.
f        Filter; keep only characters that appear in the lowercase alphabet.
          Call the result r.
   ØA    Yield the uppercase alphabet (u).
     ,   Pair; yield [u, r].
      y  Translate s, using the substitutions in [u, r].

05AB1E, 6 bytes
Code:
AÃAus‡

Uses the 05AB1E encoding. Try it online!

Your answers put me to shame usually ʒ.l}Aus‡.

JavaScript (ES6), 62 bytes
s=>s.replace(/[A-Z]/g,c=>s.match(/[a-z]/g)[parseInt(c,36)-10])

Each capital letter is converted to its base 36 value, less 10.
We then match on the lowercase letter that's at that index.

let f=

s=>s.replace(/[A-Z]/g,c=>s.match(/[a-z]/g)[parseInt(c,36)-10])

console.log(f('abcd'))
console.log(f('abrAcAdABCA'))
console.log(f('endlAsEBAEE'))
console.log(f('helCo wDrCd!'))
console.log(f('progBamFinD AuzJles & cCdL DCKf'))
console.log(f('sphinx of black quKrtz, jOdge my vGw. K NODLM IPGZE HGF SOWBA GYVP QCV JKRX TGU.'))
console.log(f('petBr AiABD AEckBd a ABFG of AEFGlBH ABAABDs. hJw mIny AEFGLBH ABAABDM HEH ABCBD AEABD AEFG?'))

Pyth, 36 bytes
JKr1GVQI&}NG!}NH=XHNhK=tK)p?}NJ@_HNN

Try it here
Explanation
JKr1GVQI&}NG!}NH=XHNhK=tK)p?}NJ@_HNN
JKr1G                                  Let J and K be the uppercase alphabet.
     VQ                                For each character in the input...
       I&}NG!}NH         )             ... if the character is lowercase and not
                                       yet in H, ...
                =XHNhK                 ... add the letter and the next uppercase
                                       letter to H...
                      =tK              ... and move to the next uppercase letter.
                          p?}NJ@_HNN   Print either the next character or the
                                       letter it represents.

Stax, 11 bytes
Ñ·í=Üò°f1èb

Run and debug it

R, 79 bytes
function(x){s=utf8ToInt(x)
s[j]=s[s>96&s<123][s[j<-s>64&s<91]-64]
intToUtf8(s)}

Try it online!

Very nice ! You can probably save a few bytes by using scan(,""  to make it a full program instead of a function, apart from that I am struggling to find any improvement...

Perl 5 with -p, 27 bytes
eval"y/A-Z/".y/a-z//cdr."/"

Try it online!
-2 bytes thanks to @breadbox!

Save a couple of bytes by replacing the s///gr with y///cdr.

@breadbox of course, thank you!

Z80Golf, 37 bytes
00000000: 2505 cd03 8030 0176 fe7b 300c fe61 3011  %....0.v.{0..a0.
00000010: fe5b 3004 fe41 3003 ff18 e7d6 414f 0a18  .[0..A0.....AO..
00000020: f777 2318 f3                             .w#..

Try it online!
z80 does pretty good at this! Here is a disassembly:
  dec h         ; HL = cipher write pointer
  dec b         ; BC = cipher read pointer
                ; meaning of 'A'..'Z' is written to $ff00~$ff19
next:
  call $8003    ; getchar
  jr nc, ok     ; not EOF?
  halt
ok:
  cp '{'
  jr nc, other  ; a ≥ '{'
  cp 'a'
  jr nc, lower  ; 'a' ≤ a ≤ 'z'
  cp '['
  jr nc, other  ; '[' ≤ a ≤ '`'
  cp 'A'
  jr nc, upper  ; 'A' ≤ a ≤ 'Z'
other:
  rst $38
  jr next
upper:
  sub 'A'
  ld c, a
  ld a, (bc)
  jr other
lower:
  ld (hl), a
  inc hl
  jr other

We point both HL and BC at the $ff00 range with dec, and use rst $38 as a short alternative to call $8000, but otherwise there isn't much trickery going on.

Retina, 25 bytes
~["T`L`"|""L$`[a-z]
$&-$&

Try it online! Explanation:
[a-z]

Match lowercase letters.
$`
$&-$&

Replace each letter with a degenerate range of itself. (This prevents the later transliteration from treating it as a character class; backslash can't be used because some lower case letters have a special meaning after a backslash.)
["T`L`"|""L

List the degenerate ranges, but without line separators, and with a preceding T`L`.
~

Evaluate the resulting transliteration program on the original input.

Python 2, 78 bytes
lambda s:''.join('@'<c<'['and filter(str.islower,s)[ord(c)-65]or c for c in s)

Try it online!

Java (JDK 10), 109 bytes
s->{var r=s.replaceAll("[^a-z]","");for(char i=64;i++<64+r.length();)s=s.replace(i,r.charAt(i-65));return s;}

Try it online!

C (gcc), 105 bytes
C;f(char*Z){for(char*z=--Z,c,*s;c=*++z;putchar(c))for(C=64,s=Z;*z>64&91>*z&&C^*z;c=*s)C+=*++s>96&*s<123;}

Try it online!

Jelly, 11 bytes
ØAi
Çị¥¹Ç?€

Try it online!

Pyth, 7 bytes
Fork of Dennis' brilliant Jelly answer
XQr1G@G

All testcases.


text:
Interpreted arithmetic
A little known fact is that if you turn on enough language extensions (ghc) Haskell becomes a dynamically typed interpreted language!  For example the following program implements addition.
{-# Language MultiParamTypeClasses, FunctionalDependencies, FlexibleInstances, UndecidableInstances #-}

data Zero
data Succ a

class Add a b c | a b -> c
instance Add Zero a a
instance (Add a b c) => Add (Succ a) b (Succ c)

This doesn't really look like Haskell any more.  For one instead of operating over objects, we operate over types.  Each number is it's own type.  Instead of functions we have type classes. The functional dependencies allows us to use them as functions between types.
So how do we invoke our code? We use another class
class Test a | -> a
 where test :: a
instance (Add (Succ (Succ (Succ (Succ Zero)))) (Succ (Succ (Succ Zero))) a)
  => Test a

This sets the type of test to the type 4 + 3.  If we open this up in ghci we will find that test is indeed of type 7:
Ok, one module loaded.
*Main> :t test
test :: Succ (Succ (Succ (Succ (Succ (Succ (Succ Zero))))))

Task
I want you to implement a class that multiplies two Peano numerals (non-negative integers).  The Peano numerals will be constructed using the same data types in the example above:
data Zero
data Succ a

And your class will be evaluated in the same way as above as well.  You may name your class whatever you wish.
You may use any ghc language extensions you want at no cost to bytes.
Test Cases
These test cases assume your class is named M, you can name it something else if you would like.
class Test1 a| ->a where test1::a
instance (M (Succ (Succ (Succ (Succ Zero)))) (Succ (Succ (Succ Zero))) a)=>Test1 a

class Test2 a| ->a where test2::a
instance (M Zero (Succ (Succ Zero)) a)=>Test2 a

class Test3 a| ->a where test3::a
instance (M (Succ (Succ (Succ (Succ Zero)))) (Succ Zero) a)=>Test3 a

class Test4 a| ->a where test4::a
instance (M (Succ (Succ (Succ (Succ (Succ (Succ Zero)))))) (Succ (Succ (Succ Zero))) a)=>Test4 a

Results
*Main> :t test1
test1
  :: Succ
       (Succ
          (Succ
             (Succ
                (Succ (Succ (Succ (Succ (Succ (Succ (Succ (Succ Zero)))))))))))
*Main> :t test2
test2 :: Zero
*Main> :t test3
test3 :: Succ (Succ (Succ (Succ Zero)))
*Main> :t test4
test4
  :: Succ
       (Succ
          (Succ
             (Succ
                (Succ
                   (Succ
                      (Succ
                         (Succ
                            (Succ
                               (Succ
                                  (Succ
                                     (Succ (Succ (Succ (Succ (Succ (Succ (Succ Zero)))))))))))))))))

Draws inspiration from Typing the technical interview

Heh... This post seems meme-y even though it's not.

130 121 bytes
-9 bytes thanks to Ørjan Johansen
type family a+b where s a+b=a+s b;z+b=b
type family a*b where s a*b=a*b+b;z*b=z
class(a#b)c|a b->c
instance a*b~c=>(a#b)c

Try it online!
This defines closed type families for addition (+) and multiplication (*). Then a type class (#) is defined that uses the (*) type family along with an equality constraint to convert from the world of type familes to the world of typeclass prolog.

If you swap the equations, you can replace Zero by z.

@ØrjanJohansen Done. I save 9 bytes for someone and 9 bytes is saved for me.

I don't know how to use type families, but maybe a function like this so you don't need to define + is useful?

@Lynn that ends up coming out longer. TIO

I know it has been a while, but I just beat this.  Although I think you might have the expertise to beat me back.

@WheatWizard I just realized that the code I posted in the comment because it came out longer is essentially the tail recursive version of your answer.

139 bytes
class(a+b)c|a b->c;instance(Zero+a)a;instance(a+b)c=>(s a+b)(s c)
class(a*b)c|a b->c;instance(Zero*a)Zero;instance((a*b)c,(b+c)d)=>(s a*b)d

Try it online!
Defines a type operator *. Equivalent to the Prolog program:
plus(0, A, A).
plus(s(A), B, s(C)) :- plus(A, B, C).
mult(0, _, 0).
mult(s(A), B, D) :- mult(A, B, C), plus(B, C, D).

Potato44 and Hat Wizard saved 9 bytes each. Thanks!

You don't need to count your data declarations to your byte total. I'LL make this clearer in the question when I get a chance

Also I think you can use a general f instead of Succ.

You can save 9 bytes by ditching the colons.

I think Hat Wizard also saved 9, not 6. There were three occurrences of Succ.

Family-Version, 115 bytes
type family(a%b)c where(a%b)(s c)=s((a%b)c);(s a%b)z=(a%b)b;(z%b)z=z
class(a#b)c|a b->c
instance(a%b)Zero~c=>(a#b)c

Try it online!
This is uses a closed type family like potato44's.  Except unlike the other answer I use only 1 type family.
type family(a%b)c where
  -- If the accumulator is Succ c:
  -- the answer is Succ of the answer if the accumulator were c
  (a%b)(s c)=s((a%b)c)
  -- If the left hand argument is Succ a, and the right hand is b
  -- the result is the result if the left were a and the accumulator were b
  (s a%b)z=(a%b)b
  -- If the left hand argument is zero
  -- the result is zero
  (z%b)z=z

This defines an operator on three types.  It essentially implements (a*b)+c.  Whenever we want to add our right hand argument to the total we instead put it in the accumulator.
This prevents us from needing to define (+) at all.  Technically you can use this family to implement addition by doing
class Add a b c | a b -> c
instance (Succ Zero % a) b ~ c => Add a b c

Class-Version, 137 bytes
class(a#b)c d|a b c->d
instance(a#b)c d=>(a#b)(f c)(f d)
instance(a#b)b d=>(f a#b)Zero d
instance(Zero#a)Zero Zero
type(a*b)c=(a#b)Zero c

Try it online!
This class version loses some ground to the family version, however it is still shorter than the shortest class version here.  It uses the same approach as my family version.

Nice, I see that your type family is mathematically implementing a*b+c.
Is that mention of "division" meant to be "addition"?

btw, you happen to be violating your own spec at the moment. "implement a class that multiplies two Peano numerals" What you have currently isn't a class, it does happen to be of kind Constraint though. So you should either update the spec or revert back to the form that uses a class instead of a type synonym. If I were to use the type synonym I could get my answer down to 96 bytes, so it saves me one more byte than you

@Potato44 I was under the impression that a class was just something with a kind that results in a contraint.  Perhaps that was due to a lack of clarity in the question.  I will revert back to my 115 answer then.


text:
Minimum operations to get from one number to another
Let's define a simple language that operates on a single 8-bit value.
It defines three bitwise operations (code explanation assumes 8-bit value variable):

! Negate the least significant bit (value ^= 1)
< Wrapping left-shift (value = value << 1 | value >> 7)
> wrapping right-shift (value = value >> 1 | value << 7)

Input:
Two 8-bit numbers, a and b. As they are 8-bit, you can alternatively take them as characters.
Output:
The shortest way to get from a to b, with the three operations defined above.
You can return a string or an array of characters, or define a constant, distinct values for each operation and return an array of those (yes, you could also say < means > and > means <), but please explain your output format in your answer.
If there are multiple, equally long ways, you can output any or all of them.
Rules:

You can submit a program or function
Standard loopholes apply
The submission with fewest bytes in each language wins (no answer will be accepted)

Solutions without brute-forcing (or at least not only brute-forcing) might get my upvote.
Test cases:
12, 13 => '!'
1, 2 => '<'
254, 253 => '<'
5, 5 => ''
98, 226 -> '<!>'
64, 154 -> '!>!>>>!>'
177, 164 -> '!>>!>>>!'
109, 11 -> '>>!>!>>'
126, 92 -> '!>!>!>!<' or '!>!>>!<!'
26, 85 -> '<!<<!<!<' or '<!<<!<!>' or '<!<<<!>!'
123, 241 -> '!>!<<!' or '>!<!<!'
236, 50 -> '<<!<!>' or '<<<!>!'
59, 246 -> '<<!>'
132, 95 -> '!<<!<!<!'
74, 53 -> '!>>>!>!'
171, 127 -> '<<!<<!<'
109, 141 -> '!>>>'
185, 92 -> '!>'
166, 201 -> '!<!>>>' or '<!>!>>'
77, 155 -> '<!'
124, 181 -> '!<<<<!>>' or '!>>>>!>>'
108, 85 -> '!<<<!<!<!<' or '!<<<!<!<!>' or '!<<<!<<!>!' or '!>>>!>!>!<' or '!>>>!>!>!>' or '!>>>!>>!<!'
185, 144 -> '<!<<!<!'
70, 179 -> '<<<!<!>' or '<<<<!>!' or '>>>>!>!'

Here is a program to generate a few more.

JavaScript (ES6), 100 96 86 bytes

f=(a,b,[c,d,...e]=[a,''])=>c-b?f(a,b,[...e,c^1,d+1,c/2|c%2<<7,d+2,c%128*2|c>>7,d+0]):d
<div oninput=o.textContent=f(a.value,b.value).replace(/./g,c=>`<!>`[c])>a: <input type=number min=0 max=255 value=0 id=a> b: <input type=number min=0 max=255 value=0 id=b>

Somewhat slow breadth-first search without double-checking. Slightly more efficient 114-byte version:

f=(a,b,c=[],[d,e,...g]=[a,''])=>c[d]?f(a,b,c,g):d-b?f(a,b,c,[...g,d^1,c[d]=e+1,d/2|d%2<<7,e+2,d%128*2|d>>7,e+0]):e
<div oninput=o.textContent=f(a.value,b.value).replace(/./g,c=>`<!>`[c])>a: <input type=number min=0 max=255 value=0 id=a> b: <input type=number min=0 max=255 value=0 id=b>

Both versions encode <!> as 012 but the snippets decode this for you. Edit: Saved 10 utterly useless bytes thanks to @RickHitchcock.

@wastl Thanks, I'd misremebered what the third symbol was.

Brilliant, and I think you can save 10 bytes:  f=(a,b,[c,d,...e]=[a,''])=>c-b?f(a,b,[...e,c^1,d+1,c/2|c%2<<7,d+2,c%128*2|c>>7,d+0]):d

@RickHitchcock Wow, those must be the most useless 10 bytes I've ever had in a single answer...

Jelly, 32 bytes
ṃ“ṙ1“ṙ-“¬8¦”
+⁹BḊ€0ÇẎv¥⁼ƭƒ@¥1#ḢÇ

Try it online!
<: ['ṙ', '1']
>: ['ṙ', '-']
!: ['¬', '8', '¦']
Note: This is a function, that's why the footer is there.
Brute force. :(

JavaScript (ES6), 105 bytes
Takes the 2 bytes in currying syntax (a)(b).
Returns a string with:

0 = !
1 = >
2 = <

or an empty array if a is equal to b.
a=>g=(b,m=1)=>(h=(n,s=[])=>n^b?s[m]?0:h(n^1,s+0)+h(n/2|n%2<<7,s+1)+h(n%128*2|n>>7,s+2):r=s)(a)?r:g(b,m+1)

Try it online!
(with codes translated back to !<>)

Python 2, 111 bytes
l=[input()+('',)]
for(a,b,i)in l:a==b>exit(i);l+=[(x,b,i+y)for x,y in zip((a*2%256|a>>7,a/2|a%2<<7,a^1),'<>!')]

Try it online!

Since functions have to be reusable, I don't think you can use exit to produce output.

@Dennis I thought this would be covered by functions can output in the same way as full programs, but exiting isn't part oft the output, I guess. Does this mean functions can't output via exit code?

I think so. Allowing functions to output as full programs can doesn't override (imo) the rules for function submissions.

C (gcc), 201 199 198 196 193 bytes

Saved two bytes thanks to ceilingcat; golfing a/2+a*128 to (a+2*a*128)/2 to a*257/2.
Saved a byte; golfing a*2+a/128 to (a*2*128+a)/128 to (257*a)/128 to 257*a>>7.
Saved two five bytes thanks to ceilingcat, golfing the return type.

C (gcc), 193 bytes
*P,D,Q,j;f(a,b,d){if(a&=255,Q&&a==b)for(Q=j=0;++j<D;printf("%d",j[P]));Q&&++d<D&&f(a^1,b,d,P[d]=1)&f(257*a>>7,b,d,P[d]=2)&f(a*257/2,b,d,P[d]=3);}F(a,b){for(D=Q=1;Q;D++){int p[D];f(a,b,0,P=p);}}

Try it online!


text:
The Unique Padlock PIN List!
Introduction
In a private chat, a friend of mine apparently recently stumbled across a security system which has the following two restrictions on its valid pins:

Each digit must be unique (that is "1" may only appear once)
The order of the digits doesn't matter ("1234"="4321")

So to illustrate how bad this padlock system is, let's actually enumerate all valid PINs!
Input
Your input will consist of a single, positive integer, which denotes the length of the PIN.
Output
Your output consists of a list of non-negative integers or strings*, which enumerate all valid PINs of the given length.
*More precisely something that a human can use to try all combinations if you would print it for them. This means set of sets of digits and arrays of arrays of digits are fine.
Who wins?
This is code-golf so the shortest answer in bytes wins! Standard rules and loopholes apply.
Corner Cases

The output behaviour is undefined if an integer greater than 10 is input.
The ordering of the digits within each output entry is undefined, as entries with a zero actually contain said zero, that is you may not strip "0123" to "123" but "1230", "1203" and "1023" are all valid as is "0123".

Test Cases
1
[0,1,2,3,4,5,6,7,8,9]

2
[10,20,30,40,50,60,70,80,90,21,31,41,51,61,71,81,91,32,42,52,62,72,82,92,43,53,63,73,83,93,54,64,74,84,94,65,75,85,95,76,86,96,87,97,98]

3
[210,310,410,510,610,710,810,910,320,420,520,620,720,820,920,430,530,630,730,830,930,540,640,740,840,940,650,750,850,950,760,860,960,870,970,980,321,421,521,621,721,821,921,431,531,631,731,831,931,541,641,741,841,941,651,751,851,951,761,861,961,871,971,981,432,532,632,732,832,932,542,642,742,842,942,652,752,852,952,762,862,962,872,972,982,543,643,743,843,943,653,753,853,953,763,863,963,873,973,983,654,754,854,954,764,864,964,874,974,984,765,865,965,875,975,985,876,976,986,987]

4
[3210,4210,5210,6210,7210,8210,9210,4310,5310,6310,7310,8310,9310,5410,6410,7410,8410,9410,6510,7510,8510,9510,7610,8610,9610,8710,9710,9810,4320,5320,6320,7320,8320,9320,5420,6420,7420,8420,9420,6520,7520,8520,9520,7620,8620,9620,8720,9720,9820,5430,6430,7430,8430,9430,6530,7530,8530,9530,7630,8630,9630,8730,9730,9830,6540,7540,8540,9540,7640,8640,9640,8740,9740,9840,7650,8650,9650,8750,9750,9850,8760,9760,9860,9870,4321,5321,6321,7321,8321,9321,5421,6421,7421,8421,9421,6521,7521,8521,9521,7621,8621,9621,8721,9721,9821,5431,6431,7431,8431,9431,6531,7531,8531,9531,7631,8631,9631,8731,9731,9831,6541,7541,8541,9541,7641,8641,9641,8741,9741,9841,7651,8651,9651,8751,9751,9851,8761,9761,9861,9871,5432,6432,7432,8432,9432,6532,7532,8532,9532,7632,8632,9632,8732,9732,9832,6542,7542,8542,9542,7642,8642,9642,8742,9742,9842,7652,8652,9652,8752,9752,9852,8762,9762,9862,9872,6543,7543,8543,9543,7643,8643,9643,8743,9743,9843,7653,8653,9653,8753,9753,9853,8763,9763,9863,9873,7654,8654,9654,8754,9754,9854,8764,9764,9864,9874,8765,9765,9865,9875,9876]

The input is non-negative - so on input zero, the program should be a list containing one value, the empty string?

@aschepler indeed, the zero case is about as sensical as the 11 case, so I changed that to "positive integer".

Jelly, 4 bytes
ØDœc

Try it online!
Explanation
ØDœc  Double-builtin; main link
  œc  Number of combinations of          of length
ØD                              [digits]
                                                   <right argument>

Behavior for n > 10 is empty list.

how does it not work with input greater than 10 (tried it, and seemed weird to me)?

@gnu-nobody it gives the empty list because you can't have a combination of 11 elements with 10 choices.

oh, the ØD is the "0123456789". thanks.

JavaScript (ES7), 89 bytes
Returns a list of lists of digits (as characters), or an empty list if n > 10.
n=>[...2**29+'4'].reduce((a,x)=>[...a,...a.map(y=>[x,...y])],[[]]).filter(a=>a.length==n)

Try it online!
How?
We first generate a list of all decimal digits as characters by computing 229 = 536870912, adding the missing '4' and splitting:
[...2**29+'4'] → [ '5', '3', '6', '8', '7', '0', '9', '1', '2', '4' ]

We then compute the powerset:
.reduce(                                   ,[[]]) // starting with a[] holding an empty list
        (a,x)=>[                          ]       // for each decimal digit x:
                ...a,                             //   copy all previous entries in a[]
                     ...a.map(y=>        )        //   and duplicate each previous entry y
                                 [x,...y]         //   with x prepended at the beginning

Finally, we filter the results on their length:
.filter(a=>a.length==n)

05AB1E, 5 bytes
žhæsù

Try it online!
Explanation
   sù  # keep elements the length of the input
  æ    # from the powerset
žh     # of 0123456789

Didn't know ù was a thing. Pretty sure I've used filter before. How new is that one?

@MagicOctopusUrn: Pretty old. Been there for a long time :P

Me brain no do see the command before the now. Me brain no am smart.

Has happened to me a couple of times. More than once on some commands as well, which is...

... acceptable of a god-tier 05AB1Er (05AB1E-ite? 05AB1E-an?) such as yourself.

Python 3, 57 bytes
lambda l:combinations(range(10),l)
from itertools import*

Try it online!
Finds all combinations of 0 .. 9 of length l.
Behavior for n > 10 is empty list.

Wolfram Language (Mathematica), 22 bytes
0~Range~9~Subsets~{#}&

Try it online!

Python 2, 62 bytes
f=lambda n:{d+s for d in`5**19`*n for s in f(n-1)if d>s}or{''}

Returns a set of strings.
Try it online!

R,  17 bytes
combn(0:9,scan())

Try it online!
Errors for input greater than 10.
Returns a matrix where each column is a PIN.

Pyth, 4 bytes
.cUT

Try it here
Explanation
.cUT
  UT     [0, 1, ..., 9].
.c  Q    All (implicit input)-element subsets.

Ruby, 30 bytes
->n{[*[*0..9].combination(n)]}

Try it online!

MATL, 6 bytes
4Y2wXN

Try it online!
Returns nothing (empty array) for k>10.
          % implicit input k
4Y2       % push '0':'9'
   w      % swap top two elements of stack
    XN    % nchoosek, select all k-combinations of '0':'9' as a char array
          % implicit output

Haskell, 56 50 bytes
-6 bytes thanks to Hat Wizard.
(10!)
_!0=[[]]
w!n=[0..w-1]>>=(map.(:)<*>(!(n-1)))

Try it online!

Java (JDK 10), 105 bytes
n->{var s="";for(int i=1024,j;i-->0;s+=" ")for(j=10;n.bitCount(i)==n&j-->0;)s+=(1<<j&i)>0?j:"";return s;}

Try it online!

Haskell, 47 bytes
f 0=[[]]
f n=[a:x|x<-f$n-1,a<-[0..9],all(/=a)x]

Try it online!
Explanation
When the number of digits is zero there is only one combination, that is the empty one:
f 0=[[]]

When the number of digits is n and n/=0 the combinations are all the ways to add digits to combinations from f$n-1 such that no digit is addded to a combination that already contains it.
f n=[a:x|x<-f$n-1,a<-[0..9],all(/=a)x]

Gaia,  4  3 bytes
₸…K

Try it online!
It's been a while since I posted an answer in Gaia! Thanks to Mr. Xcoder for saving a byte!
      % implicit input n
₸     % push 10
 …    % pop 10, push 0..9
  K   % all subsets of size n
      % print top of stack implicitly

You don't need @.

@Mr.Xcoder thanks. Didn't realize that; it doesn't seem to be documented very clearly.

Retina, 51 36 bytes
.+
10*
"$+"{%`^.
*_$&
L$v`_+
$.%`$%'

Try it online! Outputs nothing for n>10. Explanation:
.+
10*

Replace the input with 10 _s.
"$+"{

Repeat the rest of the program n times.
%`^.
*_$&

Prefix each number with _ repeated according to its first digit.
L$v`_+

Match all _s, but include all of the following _s in the match too, for which we need to enable overlapping matches.
$.%`$%'

For each _ found, prefix the number of _s to its left to the number.
This is a bit tricky so perhaps an actual case would be better. Let's suppose that we've already run the loop twice, so that all 2-digit PINs have been generated, and we're currently working through them to create 3-digit PINs. We'll look at what happens to 36: The first digit is 3, so three _s are prefixed, to make ___36. This then creates the following matches, marked here with `'s:
Match   $%` $.%`
`___'36     0
_`__'36 _   1
__`_'36 __  2

$%' evalutes to 36 in all three cases, resulting in the 3-digit PINs 036, 136 and 236.
If we were then to go on to create 4-digit PINs, then 036 would not have any _s prefixed, and therefore would result in no matches at all in the final output.

The question says the input is non-negative. On input zero, this outputs ten underscore characters.

@aschepler Indeed; I see the OP has decided to exclude that case, but in case you're wondering, the fix would be to prepend ^0 and ¶ at a cost of 5 bytes.

Proton, 43 bytes
(0..9)&__import__("itertools").combinations

Try it online!
Proton finally outgolfs Python :D I thought (import itertools) would return the value but apparently I failed at that. Also importing * afterwards doesn't work because it's not in a lambda, it's a top-level expression.

Japt, 5 bytes
Outputs an array of digit arrays. Outputs all combinations if input is 0 or an empty array if input is <0 or >10.
Ao àU

Try it

Explanation
          :Implicit input of integer U
A         :10
 o        :Range [0,10)
   àU     :Combinations of length U

I don't think the output for input 0 is correct. The output should be a list containing one element, which is empty.

@aschepler, where are you getting that from?

Stax, 4 bytes
Vd,S

Try it online!
Vd is "0123456789".  , pushes the input to the main stack. S gets combinations of the specified size.
In the tio link, m is used in the footer to print each output.

Standard ML, 124 122 121 bytes
open List;fun f(s:: &)m=(if exists(fn x=>x=m)s then[]else[m::s])@f&m|f&m= &
fun!0=[[]]| !n=concat(tabulate(10,f(!(n-1))))

Try it online! Example usage: !2 yields [[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7],[0,8],[0,9],[1,0],[1,2],[1,3], ...].
Ungolfed:
open List;

(* int list list -> int -> int list list *)
fun f (s::r) m =
    if exists (fn x => x=m) s
    then f r m
    else (m::s) :: f r m
  | f [] m = []

(* int -> int list list *)
fun g 0 = [[]]
  | g n = concat(tabulate(10, f(g(n-1))))

Some alternatives:
125 123 bytes
fun f(s:: &)m=(if List.exists(fn x=>x=m)s then[]else[m::s])@f&m|f&m= &
fun!m 0=[[]]| !10n=[]| !m n=f(!0(n-1))m@ !(m+1)n;!0;

Try it online! Defines an anonymous function which is bound to it.
127 124 bytes
fun!0=[[]]| !n=let fun f(s:: &)m=(if List.exists(fn x=>x=m)s then[]else[m::s])@f&m|f&9=[]|f&m=f(!(n-1))(m+1)in f(!(n-1))0end

Try it online!

JavaScript (Node.js), 53 bytes
f=(i,b='',k=10)=>k--?f(i-1,k+b,k)+f(i,b,k):i?'':b+`,`

Try it online!

Oracle 18 SQL, 169 bytes
Not a golfing language but:
WITH t(v)AS(SELECT*FROM SYS.ODCINUMBERLIST(0,1,2,3,4,5,6,7,8,9)),n(a,b,c)AS(SELECT a,-1,''FROM i UNION ALL SELECT a-1,v,v||c FROM n,t WHERE v>b)SELECT c FROM n WHERE a=0

Expected the input to be in a table i with column a:
CREATE TABLE i (a INT);
INSERT INTO i VALUES ( 3 );

Try it online at Oracle Live SQL (a free login is required then copy-paste the solution into a worksheet) or SQLFiddle (no login but requires +7 bytes to work on the lower Oracle version).

CJam, 13 11 bytes
{Ae!f<:$_|}

Try it online!
Technically doesn't run on tio.run, since heap space runs out. However, it works properly for up to 9 digit keypads, and should run just fine with more RAM.
Saved 2 bytes thanks to Dennis

Bash, 113 99 bytes
p()(r $1 0 $[10-$1])
r()for i in `seq $2 $3`;{ (($1>1))&&r $[$1-1] $[i+1] $[$3+1] $4$i||echo $4$i;}

Try it online!

r 0 doesn't work.

r is the recursive function: it's not meant to be launched with only 1 parameter. p 0 behaviour is unspecified in the question.

JavaScript (Firefox 30-57), 67 bytes
n=>n?[for(x of f(n-1))for(y of Array(x?+x[0]:10).keys())y+x]:['']

Port of my Retina answer, but works for n=0 too (returning a list of an empty string, as distinct from an empty list for n>10).

Charcoal, 21 bytes
⊞υωＦχ≔⁺υＥυ⁺κＩιυΦυ⁼θＬι

Try it online! Link is to verbose version of code. Explanation:
⊞υω

Push the empty string to the predefined list.
Ｆχ

Loop over each digit.
Ｅυ⁺κＩι

Append the digit to every string in the list.
≔⁺υ...υ

Append the result to the original list.
Φυ⁼θＬι

Print all strings with the correct number of digits.

Perl 6, 20 bytes
{combinations 10,$_}

Try it online!
This is exactly what combinations (as a subroutine, or .combinations on a list) is for.
https://docs.perl6.org/routine/combinations

J, 32 bytes
.. frustratingly longer than Mathematica and R f=:{[:(#@>"0]/.])[:<@I.@#:@i.2^]
TIO


text:
Fun with strings and numbers
Here's a programming puzzle for you:
Given a list of pairs of strings and corresponding numbers, for example, [[A,37],[B,27],[C,21],[D,11],[E,10],[F,9],[G,3],[H,2]], output another list which will have just the strings in the following manner:

The total count of any string should be exactly equal to its corresponding number in the input data.
No string should be repeated adjacently in the sequence, and every string should appear in the output list.
The selection of the next string should be done randomly as long as they don't break above two rules. Each solution should have a non-zero probability of being chosen.
If no combination is possible, the output should be just 0.

The input list may be given in any order (sorted or unsorted), and the strings in the list may be of any length.

Sample output for the above sample input 1
[A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,B,A,C,A,C,A,C,A,C,A,C,A,C,A,C,A,C,A,C,A,C,D,C,D,C,D,C,D,C,D,C,D,C,D,C,D,C,D,C,D,C,D,C,E,F,E,F,E,F,E,F,E,F,E,F,E,F,E,F,E,F,E,G,H,G,H,G]

Input sample 2:
[[A,6],[B,1],[C,1]]
Output for second input:
0
since no list possible based on rules.

Sample input 3:
[[AC,3],[BD,2]]
valid output: [AC,BD,AC,BD,AC]
invalid output: [AC,BD,AC,AC,BD]

If further clarification is needed, please, do not hesitate to tell me in the comments and I will promptly act accordingly.
This is code-golf, so shortest code in bytes for each language wins!

Nice challenge! I do think it's a little underspecified by our standards. I highly recommend use of The Sandbox to get lots of feedback before posting a challenge so you don't get downvotes or close votes! :-) I'm looking forward to seeing more good challenges from you!

@Giuseppe thanks I will try go through that. Let me know if I need to add any details if I have missed in this one.

Can we take 2 inputs, just the strings and just the numbers?

there may be ambiguity in the use of the phrase 'random', several of these solutions are using "random" libraries that are in fact only pseudorandom.

Jelly, 11 bytes
Œṙ'Œ!⁻ƝẠ$ƇX

Try it online!
Œṙ'Œ!⁻ƝẠ$ƇX Arguments: z
  '         Flat: Apply link directly to x, ignoring its left and right depth properties
Œṙ            Run-length decode
   Œ!       Permutations of x
         Ƈ  Filter; keep elements of x for which the link returns a truthy result
        $     ≥2-link monadic chain
      Ɲ         Apply link on overlapping pairs (non-wrapping)
     ⁻            x != y
       Ạ        Check if all elements of x have a truthy value (+vacuous truth)
          X Pick a random element of x; return 0 if the list is empty.

If Œṙ didn't vectorize it would work without '

Jelly, 17 bytes
Wẋ¥Ɲ€ẎẎŒ!Œɠ’SƊÐḟX

Try it online!

When I try ["A", 100], ["B", 3] it doesn't output anything it's stuck I think.

@newguy Generating all permutations of 103 items isn't famous for its speed. For reference, the result after Œ! will have 99029007164861804075467152545817733490901658221144924830052805546998766658416222832141441073883538492653516385977292093222882134415149891584000000000000000000000000 elements.

@newguy This solution is O(n!) but it's short and speed doesn't matter. Don't try it with anything where the numbers add up to more than about 6-8 or so :P

Could Œṙ help?

I think this should work. Is it buggy?

@HyperNeutrino why does it gets stuck if I change A to ABB in your Try it online link?

@Arnauld Actually, it can help as Œṙ' (as used in my completely different answer), but this answer seems to assume that the strings are single-char.

@dylnan I don't think it is working for strings I tried with ["AT", 3], ["B", 3] and got TBATATBAB as output which is wrong

@HyperNeutrino Using Wẋ¥Ɲ€ẎẎ instead of x/€F is what you want. There might be something shorter, but this works.

@newguy should be fixed now; didn't account for the char-vs-string thing because that wasn't in the original test cases ...

Python 2, 114 189 185 174 bytes
from random import*
a=input()
s=u=[]
while a:x,y=a.pop(a.index(next((w for w in a if w[1]>sum(v[1]for v in a+u)/2),choice(a))));s=s+[x];a+=u;u=[[x,y-1]]*(y>1)
print[s,0][y>1]

Try it online!
Ouch! Much harder with rule 3... :). Still trying to avoid the O(n!) approach, so it can handle all the test cases sometime before the heat death of the universe...
Algorithm: suppose the total sum of the string counts is t. If any string has a count n with 2*n>t+1, then it is not possible to satisfy the constraints. Therefore, if any string (excluding the previously chosen one) has count n with 2*n=t+1, then we must choose that string next. Otherwise, we can choose at random any string which is not the previously chosen string.

@Arnauld: completely missed that! fixed now.

R, 148 141 bytes
function(x,y,p=combinatXXpermn(rep(seq(y),y)),q=which(sapply(lapply(p,diff),all)))"if"(n<-sum(q|1),"if"(n-1,x[p[[sample(q,1)]]],x[p[[q]]]),0)

Try it online! (I've copied combinat::permn and called it combinatXXpermn there.)
Brute force O(n!) solution.
Uses permn from the combinat package to generate all possible orderings. Then checks to see if any follow the rules, and picks one of those at random.

n<-sum(n|1) is a byte shorter I believe. But the quirk of sample with a length-one input is pretty frustrating here.

golfed it down a bit as well, try it here -- I had to remove the combinatXXpermn from the header to get the link small enough...

I had something very similar taking input as a dataframe. The issue with bruteforce is it won't handle inputs that are too big...

@JayCe is a non-brute force algorithm even possible, given rule 3 of this challenge?

I agree it might not. Would have been more interesting without rule 3.

J, 60 53 bytes
-7 thanks to FrownyFrog
(?@#{])@(#~*/@(2~:/\])"1)@(]i.@!@#@;A.;) ::0(#~>)/&.>

original
(?@#{])@(#~2&([:*/~:/\)"1)@(A.~i.@!@#)@;@:(([#~>@])/&.>) ::0

ungolfed
(?@# { ])@(#~ 2&([: */ ~:/\)"1)@(A.~ i.@!@#)@;@:(([ #~ >@])/&.>) ::0

Suggestions for improvement welcome.
Try it online!

Golfed to 53

awesome tyvm @FrownyFrog , i’ll update post later

oops, [:*/2~:/\|: is two shorter

JavaScript, 112 bytes
First pass at this, more golfing to (hopefully) follow.
f=([i,...a],o=[])=>a.sort((x,y)=>(y[1]-x[1])*Math.random()-n*.5,n=--i[1],o.push(i[0]))+a?f(n?[...a,i]:a,o):n?0:o

Try it online

Thanks, @Arnauld, I'd missed that. Should've double checked the spec rather than just blindly following Chas' lead. Implemented a quick fix, will have to come back to it later to see if I can golf it better.

Yeah, the 3rd rule is OK for esolangs that can easily brute force all solutions anyway, but it makes it quite harder to implement shorter algorithms in other languages... BTW: this now seems to return 0 on valid entries from time to time.

Implemented another quick fix, @Arnauld - if that doesn't sort it, I'll have to delete again until I have more time to look into it. Note: I've taken the spec at its word that the next string needs to be chosen randomly, implying the first selection need not be random.

@Shaggy - I agree, you should never blindly follow anything I do! :)

JavaScript (ES6), 160 bytes
a=>(g=(a,m=[])=>a.map((v,n)=>v==m[0]||g(a.filter(_=>n--),[v,...m]))>[]?0:r=m)(a.reduce((p,[v,n])=>[...p,...Array(n).fill(v)],r=[]).sort(_=>Math.random()-.5))||r

Try it online!

Charcoal, 38 bytes
ＷΦθ§κ¹«≔‽Φ∨Φι›⊗§κ¹ΣＥι§μ¹ι¬⁼κυυ§υ⁰⊞υ⊖⊟υ

Try it online! Link is to verbose version of code. Explanation:
ＷΦθ§κ¹«

Repeat while there is at least one non-zero count.
Φι›⊗§κ¹ΣＥι§μ¹

Find any count that makes up more than half the remainder.
∨...ι

If there wasn't one, then just take the non-zero counts filtered earlier.
Φ...¬⁼κυ

Filter out the string that was output last time.
≔‽∨...υ

Assign a random element from the first non-empty of the above two lists to the last output string. Note that if an impossible combination is entered, the program will crash at this point.
§υ⁰

Print the string.
⊞υ⊖⊟υ

Decrement its count.

This produces invalid outputs, such as in your example with ["h4x0r", 1337] included as a string.

@ngm I've rearranged the code and it now crashes if you do that... proper validation is going to cost more bytes unfortunately.

Ruby, 85 bytes

The brute force approach (thanks Jonah for the idea).
->l{l.flat_map{|a,b|[a]*b}.permutation.select{|p|r=0;p.all?{|a|a!=r&&r=a}}.sample||0}

Try it online!
Ruby, 108 100 96 bytes
Previously, the Bogosort approach
->l{w=[];l.map{|a,b|w+=[a]*b;b}.max*2>w.size+1?0:(w.shuffle!until(r='';w.all?{|a|a!=r&&r=a});w)}

Try it online!

here's one for 93: Try it online!

Rust 633 bytes
What makes this a little different than the others is that it started with the idea to rearrange the strings by simulating a physical system. Each string is first duplicated the appropriate number of times. Then each individual string is treated as a Particle in a space. Two particles with the same string value "repel" each other, while two particles with different values attract each other. For example if we begin with AAAAAAABBBBCC, the As will repeal each other, moving away from each other, allowing the Bs to move inbetween them. Over time this reaches a nice mixture of particles. After each iteration of 'particle movement', the program checks that no same-particles are adjacent, then stops and prints the state of the system, which is simply the list of strings in order, as they appear in the 1 dimensional space.
Now, when it comes to actually implementing that physical system, it started out as using the old fashiond PC demo/game technique, to store each particles position and velocity as numbers, then go through iterations to update position and velocity. At each iteration, we are adding velocity to position (movement), and adding acceleration to velocity (change in rate of movement), and calculating acceleration (finding the force on the particle). To simplify, the system doesn't calculate force on each particle based on  all other particles - it only checks the particles immediately adjacent. There was also a 'damping' effect so that particles wouldn't accelerate too much and fly off to infinity (velocity is reduced by x percentage each step, for example).
Through the process of golfing, however, this whole thing was cut down and simplified drastically. Now, instead of two alike particles repelling each other, they simply 'teleport'. Different particles simply 'scoot' a wee bit to prevent stagnation in the system. For example if A is next to A it will teleport. If A is next to B it will only slightly shift. Then it checks if the conditions are met (no like particles adjacent) and prints the strings in order, based on their position in 1-d space. It is almost more like a sorting algorithm than a simulation - then again, one could see sorting algorithms as a form of simulated 'drifting' based on 'mass'. I digress.
Anyways, this is one of my first Rust programs so I gave up after several hours of golfing, although there might be opportunities there still. The parsing bit is difficult for me. It reads the input string from standard input. If desired, that could be replaced with "let mut s = "[[A,3],[B,2]]". But right now I do 'echo [[A,3],[B,2]] | cargo run' on the command line.
The calculation of stopping is a bit of a problem. How to detect if a valid state of the system will never be reached? The first plan was to detect if the 'current' state ever repeated an old state, for example if ACCC changes to CACC but then back to ACCC we know the program will never terminate, since it's only pseudo-random. It should then give up and print 0 if that happened. However this seemed like a huge amount of Rust code, so instead I just decided that if it goes through a high number of iterations, its probably stuck and will never reach a steady state, so it prints 0 and stops. How many? The number of particles squared.
Code:
extern crate regex;
struct P {s:String,x:i32,v:i32}
fn main() {
    let (mut i,mut j,mut p,mut s)=(0,0,Vec::new(),String::new());
    std::io::stdin().read_line(&mut s);
    for c in regex::Regex::new(r"([A-Z]+),(\d+)").unwrap().captures_iter(&s) {
        for _j in 0..c[2].parse().unwrap() {p.push(P{s:c[1].to_string(),x:i,v:0});i+=1;}
    }
    let l=p.len(); while i>1 {
        j+=1;i=1;p.sort_by_key(|k| k.x);
        for m in 0..l {
            let n=(m+1)%l;
            if p[m].s==p[n].s {p[m].v=p[m].x;if n!=0 {i=2}} else {p[m].v=1}
            p[m].x=(p[m].x+p[m].v)%l as i32;
        }
        if j>l*l{p.truncate(1);p[0].s="0".to_string();i=1}
    }
    for k in &p{print!("{}",k.s)};println!();
}

That's an interesting way of thinking about this problem, I like it. How well does it do in practice? I feel like the $ l^2 $ limit may be too low, that there may be too many false negatives where the algorithm thinks there's no valid output when there is - but I couldn't test that theory since TIO apparently doesn't have the regex crate.

it passed the examples i fed it, although i did not fuzz it. i have modified it to work in TIO, you need to modify the 'let s=[("A",3),("B",2),("ZZ",4)];' line, https://bit.ly/2LubonO

JavaScript (Node.js), 249 bytes
l=>(a=[],g=(r,s)=>s.length?s.forEach((x,i)=>g([...r,x],s.filter((y,j)=>j-i))):a.push(r),g([],l.reduce(((a,x)=>[...a, ...(x[0]+' ').repeat(x[1]).split(' ')]),[]).filter(x=>x)),p=a.filter(a=>a.every((x,i)=>x!=a[i+1])),p[~~(Math.random()*p.length)]||0)

Try it online!

Java (JDK 10), 191 bytes
S->N->{var l=new java.util.Stack();int i=0,j;for(var s:S)for(j=N[i++];j-->0;)l.add(s);for(;i>0;){i=0;java.util.Collections.shuffle(l);for(var s:S)if(s.join("",l).contains(s+s))i++;}return l;}

Try it online!
This never returns if there are no solutions.


text:
Find elements in an array computing a given function value
Problem Description
Given:

a function \$f(a, b, c, d, e) = \frac{a \times b}c + \frac de\$
an array \$x = [x_1, x_2, x_3, x_4, ..., x_n]\$ of non-distinct integers
a target value \$k\$

What is the most efficient way, in terms of worst-case \$n\$, to find 5 distinct indices \$x_a, x_b, x_c, x_d, x_e\$ from \$x\$ such that \$f(x[x_a], x[x_b], x[x_c], x[x_d], x[x_e]) = k\$?
Example solutions
Example 1 (single solution):
\$x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], k = 5\$
Solution 1:
\$[1, 4, 2, 9, 3]\$ as \$f(x[1], x[4], x[2], x[9], x[3])\$ evaluates to \$5\$.
Example 2 (multiple solutions):
\$x = [0, -1, 1, -1, 0, -1, 0, 1], k = 0\$
Solution 2 (of many solutions):
\$[1, 2, 3, 5, 7]\$ OR \$[0, 1, 2, 4, 7]\$
Example 3 (no solution):
\$x = [0, -1, 1, -1, 0, -1, 0, 1], k = 8\$
Solution 3:
\$-1\$ (no solution)
Example 4 (intermediary floats):
\$x = [2, 3, 5, 4, 5, 1], k = 2\$
Solution 4:
\$[2, 3, 5, 4, 5]\$

Are you given a function with some number of variables an array and a third value? Also, I think the most efficient way is just brute force permutations from the array.

@fəˈnɛtɪk brute force with early stopping for branches of values larger than k? Also, the interchangeability of a*b == b*a seems important?

@fəˈnɛtɪk The function is fixed. I think there might be some way to optimize this solution like two sum, but I haven't been able to figure out how yet.

What exactly does the array contain? Floats? Integers? Positive integers?

May the intermediate calculations lead to float results? For instance, is [2,3,5,4,5] a valid solution for k=2?

@user202729 in terms of n

@Arnauld yes, that's valid

@user202729 I have added all the edits and clarifications requested in the discussion. Is this eligible to be reopened?

@fəˈnɛtɪk That will still be O(n^5) in worst case n.

Do we know if k is always an integer? it is not specified in the question.

I guess that "non-distinct" means "not necessarily distinct"? It seems to be possible in O(n^4), maybe O(n^3 log n).

The first example also has the solution [0,2,3,5,1]. The last example gives the values instead of the indices.

Python3, O(n^3 log n)
from math import gcd
from functools import reduce

def lcm(x,y):
    return x//gcd(x,y)*y

def label(l):
    res=[(v,i) for i,v in enumerate(l)]
    res.sort()
    return res

def sortcombine(l):
    l.sort()
    res=[]
    oldval=None
    for val,how in l:
        if val==oldval:
            res[-1][1].append(how)
        else:
            oldval=val
            res.append((val,[how]))
    return res

def getabc(L,xl):
    N=len(xl)
    res=[]
    lasta=None
    for ai in range(N):
        a,al=xl[ai]
        if a==lasta:
            continue
        lasta=a
        lastb=None
        for bi in range(ai+1,N):
            b,bl=xl[bi]
            if b==lastb:
                continue
            lastb=b
            lastc=None
            for c,cl in xl:
                if c in [0,lastc] or cl in [al,bl]:
                    continue
                lastc=c
                res.append((L//c*a*b,(al,bl,cl)))
    return sortcombine(res)

def getde(L,xl):
    res=[]
    xl.reverse()
    lastd=None
    for d,dl in xl:
        if lastd==d:
            continue
        lastd=d
        laste=None
        for e,el in xl:
            if e in [0,laste] or el==dl:
                continue
            laste=e
            res.append((L//e*d,(dl,el)))
    return sortcombine(res)

def solve(l,k):
    xl=label(l)
    L=reduce(lcm,[v for v in l if v!=0],1)
    k*=L
    abc=getabc(L,xl)
    de=getde(L,xl)
    i=0
    j=len(de)-1
    while i<len(abc) and j>=0:
        v1,ls1=abc[i]
        v2,ls2=de[j]
        s=v1+v2
        if s==k:
            for l1 in ls1:
                s=set(l1)
                for l2 in ls2:
                    if s.isdisjoint(l2):
                        return list(l1+l2)
            i+=1
            j-=1
        elif s<k:
            i+=1
        else:
            j-=1
    return None

Try it online!
Multiply the equation by the LCM of the x values to avoid floating point or fractions.
Find all possible values of ab/c (using ab=ba but that's only for a factor of 1/2) and d/e, sort them and try to add them to the wanted result. The sorting means we don't have to try all combinations.
There are O(n^3) possible values for ab/c, sorting them gives the log. The other steps are faster than that.
The while loop may be repeated O(n^3) times, but the case s==k can only occur O(n^2) times. If we don't find a solution and stop in this case, then the sizes of ls1 and ls2 (number of ways to obtain the corresponding value) must be in O(n) resp. O(1) (except in the case when the value is 0, but luckily that doesn't happen O(n) times).

(but I have no proof that this is the most efficient way)

How does this determine that it isn't using the same element twice between AB/C and D/E

@fəˈnɛtɪk That's in the isdisjoint call. And there are a lot of yet unmentioned details how it handles repeated elements: group and label the elements, i.e. replace [1,2,1,...] with [(1,0),(1,1),(2,0),...], and use the low labels for abc and (by reversing the list) the high labels for de, so if there is intersection then that combination is really not possible.

(now changed the labels to be the indices, so in the above example we get [(1,0),(1,2),(2,1),...])