[Question]
      [
Given no input, output this interesting alphabet pattern in either case (the case has to be consistent) via an [accepted output method](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods):
```
A
AB
ACBC
ADBDCD
AEBECEDE
AFBFCFDFEF
AGBGCGDGEGFG
AHBHCHDHEHFHGH
AIBICIDIEIFIGIHI
AJBJCJDJEJFJGJHJIJ
AKBKCKDKEKFKGKHKIKJK
ALBLCLDLELFLGLHLILJLKL
AMBMCMDMEMFMGMHMIMJMKMLM
ANBNCNDNENFNGNHNINJNKNLNMN
AOBOCODOEOFOGOHOIOJOKOLOMONO
APBPCPDPEPFPGPHPIPJPKPLPMPNPOP
AQBQCQDQEQFQGQHQIQJQKQLQMQNQOQPQ
ARBRCRDRERFRGRHRIRJRKRLRMRNRORPRQR
ASBSCSDSESFSGSHSISJSKSLSMSNSOSPSQSRS
ATBTCTDTETFTGTHTITJTKTLTMTNTOTPTQTRTST
AUBUCUDUEUFUGUHUIUJUKULUMUNUOUPUQURUSUTU
AVBVCVDVEVFVGVHVIVJVKVLVMVNVOVPVQVRVSVTVUV
AWBWCWDWEWFWGWHWIWJWKWLWMWNWOWPWQWRWSWTWUWVW
AXBXCXDXEXFXGXHXIXJXKXLXMXNXOXPXQXRXSXTXUXVXWX
AYBYCYDYEYFYGYHYIYJYKYLYMYNYOYPYQYRYSYTYUYVYWYXY
AZBZCZDZEZFZGZHZIZJZKZLZMZNZOZPZQZRZSZTZUZVZWZXZYZ
```
Trailing spaces and newlines are acceptable, [standard loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are disallowed, and this happens to be [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins!

[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
```
ØAjṪ$Ƥż¹Y
```
[Try it online!](https://tio.run/##ARgA5/9qZWxsef//w5hBauG5qiTGpMW8wrlZ//8 "Jelly – Try It Online")
### How it works
```
ØAjṪ$Ƥż¹Y  Main link. No arguments.
ØA         Yield "ABCDEFGHIJKLMNOPQRSTUVWXYZ".
     Ƥ     Map the link to the left over all prefixes, i.e., ["A", "AB", ...].
    $        Combine the two links to the left into a chain.
   Ṫ           Tail; yield and remove the last letter of each prefix.
  j            Join the remainder, using that letter as separator.
      ż¹   Zip the resulting strings and the letters of the alphabet.
        Y  Separate the results by linefeeds.
```
[Answer]
# C, 82 bytes
```
f(i,j){for(i=!puts("A");++i<26;puts(""))for(j=0;j++<i*2;)putchar(65+(j&1?j/2:i));}
```
[Try it online!](https://tio.run/##S9ZNT07@/z9NI1MnS7M6Lb9II9NWsaC0pFhDyVFJ01pbO9PGyMwaIqCkqQlSkGVrYJ2lrW2TqWVkrQmUSc5ILNIwM9XWyFIztM/SN7LK1NS0rv2fmVeikJuYmaehyVXNpQAEaRqa1ly1/wE)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 9 bytes
```
Ｅα⁺⪫…ακιι
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM3sUAjUUchIKe0WMMrPzNPw7kyOSfVOSMfLJytqaOQCcaamtb////XLcsBAA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
 α          Predefined uppercase alphabet
Ｅ           Map over each character
    …ακ     Get current prefix of alphabet
   ⪫   ι    Join with current character
  ⁺     ι   Append current character
            Implicitly print on separate lines
```
[Answer]
# [Canvas](https://github.com/dzaima/Canvas), 7 [bytes](https://github.com/dzaima/Canvas/blob/master/files/chartable.md)
```
Ｚ［Ｋ＊¹＋］
```
[Try it here!](https://dzaima.github.io/Canvas/?u=JXVGRjNBJXVGRjNCJXVGRjJCJXVGRjBBJUI5JXVGRjBCJXVGRjNE,v=0,run)
Explanation:
```
Ｚ［     ］ for each prefix of the uppercase alphabet
    Ｋ        pop off the last letter
     ＊       and join the rest of the string with that character
      ¹＋     and append the current iterated character to it
```
[Answer]
# [R](https://www.r-project.org/), 50 bytes
```
l=LETTERS
for(i in 0:25)cat(l[0:i],"
",sep=l[i+1])
```
[Try it online!](https://tio.run/##K/r/P8fWxzUkxDUomCstv0gjUyEzT8HAyshUMzmxRCMn2sAqM1ZHiUtJpzi1wDYnOlPbMFbz/38A "R – Try It Online")
Perhaps the cleverest part here is using `letters[0]` for the empty string to get `cat(character(0),'\n',sep="A")` to print the first line.
[Answer]
# [Python 2](https://docs.python.org/2/), 56 bytes
```
n=65;s='';exec'c=chr(n);print c.join(s)+c;s+=c;n+=1;'*26
```
[Try it online!](https://tio.run/##BcExCsAgDADAr3SLNlBQqEvIa4KgHaIYh/b16d38dhua3ZXLTcYAVN8qICxtBY00V9d9yPWMrsEiChmykCIngjMX9x8 "Python 2 – Try It Online")
[Answer]
# [6502 machine code](https://en.wikibooks.org/wiki/6502_Assembly) routine (C64), 39 bytes
```
A9 41 20 D2 FF AA A8 84 FB E4 FB B0 0B 8A 20 D2 FF 98 20 D2 FF E8 D0 F1 A9 0D
20 D2 FF A2 41 C0 5A F0 03 C8 D0 E1 60
```
Position-independet machine code subroutine, clobbers A, X and Y.
### [Online demo](https://vice.janicek.co/c64/#%7B%22controlPort2%22:%22joystick%22,%22primaryControlPort%22:2,%22keys%22:%7B%22SPACE%22:%22%22,%22RETURN%22:%22%22,%22F1%22:%22%22,%22F3%22:%22%22,%22F5%22:%22%22,%22F7%22:%22%22%7D,%22files%22:%7B%22calst.prg%22:%22data:;base64,AMCpQSDS/6qohPvk+7ALiiDS/5gg0v/o0PGpDSDS/6JBwFrwA8jQ4WA=%22%7D,%22vice%22:%7B%22-autostart%22:%22calst.prg%22%7D%7D)
The demo loads at `$C000`, so use `SYS49152` to call the routine.
---
### Commented disassembly:
```
A9 41       LDA #$41            ; 'A'
20 D2 FF    JSR $FFD2           ; Kernal CHROUT (output character)
AA          TAX                 ; copy to X (current pos)
A8          TAY                 ; copy to Y (current endpos)
  .outerloop:
84 FB       STY $FB             ; endpos to temporary
  .innerloop:
E4 FB       CPX $FB             ; compare pos with endpos
B0 0B       BCS .eol            ; reached -> do end of line
8A          TXA                 ; current pos to accu
20 D2 FF    JSR $FFD2           ; and output
98          TYA                 ; endpos to accu
20 D2 FF    JSR $FFD2           ; and output
E8          INX                 ; next character
D0 F1       BNE .innerloop      ; (repeat)
  .eol:
A9 0D       LDA #$0D            ; load newline
20 D2 FF    JSR $FFD2           ; and output
A2 41       LDX #$41            ; re-init current pos to 'A'
C0 5A       CPY #$5A            ; test endpos to 'Z'
F0 03       BEQ .done           ; done when 'Z' reached
C8          INY                 ; next endpos
D0 E1       BNE .outerloop      ; (repeat)
  .done:
60          RTS
```
[Answer]
# [Uiua](https://uiua.org) 0.1.0, 21 [bytes](https://codegolf.stackexchange.com/questions/247669/i-want-8-bits-for-every-character/265917#265917)
```
∵(&p+@A♭≐⊂⇡.)⇡26&pf@A
```
[See it in action](https://uiua.org/pad?src=4oi1KCZwK0BB4pmt4omQ4oqC4oehLinih6EyNiZwZkBBCg==)
[Answer]
# Java 8, ~~93~~ ~~91~~ 90 bytes
```
v->{String t="";for(char c=64;++c<91;t+=c)System.out.println(t.join(c+"",t.split(""))+c);}
```
-1 byte thanks to *@OlivierGrégoire* by printing directly instead of returning
**Explanation:**
[Try it online.](https://tio.run/##LY7BCsIwDIbvPkXoqaVaEESQOt9AL4IX8VDj1M6ajjUbiOzZZ3VCfkLCD99Xuc7NYl1SdXkMGFxKsHWe3hMAT1w2V4cl7L4nQBf9BVAevqtTNv/6nDyJHXuEHRAUMHSzzXvPjacbcCGEvcZG4t01gMVyYbXG9WpuWReo9q/E5dPElk2d@xxIsqmiJ4laiCmbVAfPUgilNCrbD3bk1e05ZN4f@9N6Zmk5Uo8np0ZhMiipDeHv2g8f)
```
v->{                     // Method with empty unused parameter and String return-type
  String t="";           //  Temp-String, starting empty
  for(char c=64;++c<91;  //  Loop over the letters of the alphabet:
      t+=c)              //    After every iteration: append the letter to the temp-String
    System.out.println(  //   Print with trailing new-line:
       r.join(c+"",t.split(""))
                         //    The temp-String with the current letter as delimiter
       +c);}             //    + the current letter as trailing character
```
[Answer]
# [SNOBOL4 (CSNOBOL4)](http://www.snobol4.org/csnobol4/), ~~169~~ ~~143~~ ~~124~~ 123 bytes
```
	L =LEN(1)
	OUTPUT ='A'
I	&UCASE (ARB K L) . R L . S :F(END)
	O =K =
T	R K L . K :F(O)
	O =O K S :(T)
O 	OUTPUT =O :(I)
END
```
[Try it online!](https://tio.run/##K87LT8rPMfn/n9NHwdbH1U/DUJOL0z80JCA0RMFW3VGdy5NTLdTZMdhVQcMxyEnBW8FHU0FPIUjBB0gGK1i5abj6uYB0KNh6K9hyhXAGgZQA5bxBcv4QGX8gD6hWI0STy18Bbrg/UMRTkwuo//9/AA "SNOBOL4 (CSNOBOL4) – Try It Online")
Explanation for older version of the code:
```
i &ucase len(x) . r len(1) . s	;* set r to the first x characters and s to the x+1th.
 o =				;* set o,i to empty string
 i =
t r len(i) len(1) . k :f(o)	;* set k to the ith letter of r. on failure (no match), go to o.
 o =o s k			;* concatenate o,s,k
 i =i + 1 :(t)			;* increment i, goto t
o o s =				;* remove the first occurrence of s (the first character for x>1, and nothing otherwise)
 output =o s			;* output o concatenated with s
 x =lt(x,25) x + 1 :s(i)	;* increment x, goto i if x<25.
end
```
The problem here is the first line
using `o s k` will add an extra `s`eparator character at the beginning of each line and also not have an `s` at the end. This is OK because line `t` will jump over the following two lines when `x=0`. This means that `o` will still be blank. Hence, `o s =` will remove the first `s` character from `o`, and then we can simply print `o s` to have the appropriate last `s`.
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 56 bytes
```
"A";65..89|%{([char[]](65..$_)-join[char]++$_)+[char]$_}
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/X8lRydrMVE/PwrJGtVojOjkjsSg6NlYDJKQSr6mblZ@ZBxaM1dYG8rUhbJX42v//AQ "PowerShell – Try It Online")
Loops `65` to `89`, each iteration constructing a `char` array of `65` to the current number `$_`, then `-join`s that array together into a string with the next character, then tacks on that character at the end.
Change the `89` to some other ASCII number to see the behavior better.
[Answer]
# [><>](https://esolangs.org/wiki/Fish), ~~44~~ 34 bytes
```
"BA"oao"ZA"\=?;1+40.
o1+:{::o}=?\:
```
[Try it online!](https://tio.run/##S8sszvj/X8nJUSk/MV8pylEpxtbe2lDbxECPK99Q26rayiq/1tY@xur/fwA "><> – Try It Online")
# [><>](https://esolangs.org/wiki/Fish), 44 bytes
```
"A"o10ao\55*=?;1+40.
1+:{:}=?\:"A"+o{:}"A"+o
```
[Try it online!](https://tio.run/##S8sszvj/X8lRKd/QIDE/xtRUy9be2lDbxECPy1Dbqtqq1tY@xgoorZ0PZIPp//8B "><> – Try It Online")
As I use a different route to producing the output I've posted my own ><> answer; The other ><> answer can be found [here.](https://codegolf.stackexchange.com/a/153190/62009)
Big thanks to Jo king for spotting I didn't need to keep putting "A" onto the stack if I just compared against "Z" instead of 26. (-10 bytes)
### Explanation
The explanation will follow the flow of the code.
```
"BA"                 : Push "BA" onto the stack;
                       [] -> [66, 65]
    oao              : Print the stack top then print a new line;
                       [66, 65] -> [66]
       "ZA"\         : Push "ZA" onto the stack then move down to line 2;
                       [66, 90, 65]
o          \:        : Duplicate the stack top then print
 1+:                 : Add one to the stack top then duplicate;
                       [66, 90, 65, 65]
    {::              : Shift the stack right 1 place then duplicate the stack top twice;
                       [90, 65, 65, 66, 66]
       o}            : Print the stack top then shift the stack left 1 place;
                       [66, 90, 65, 65, 66]
         =?\         : Comparison for equality on the top 2 stack items then move to line 1 if equal otherwise continue on line 2;
                       [66, 90, 65]
           \=?;      : Comparison for equality on the top 2 stack items then quit if equal else continue on line 1;
                       [66]
               1+    : Add 1 to the stack top;
                       [67]
                 40. : Move the code pointer to column 4 row 0 of the code box and continue execution of code.
```
[Answer]
## JavaScript (ES6), 81 bytes
```
f=
_=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"].map((c,i,a)=>a.slice(0,i).join(c)+c).join`
`
;document.write('<pre>'+f());
```
Save 9 bytes if a string array return value is acceptable.
[Answer]
# [Japt](https://github.com/ETHproductions/japt) (`-R` flag), ~~14~~ 12 bytes
*-2 bytes thanks to @Shaggy*
```
;B¬
ËiU¯E qD
```
[Test it online!](https://ethproductions.github.io/japt/?v=1.4.5&code=O0KsCqNzMFkgcVggK1g=&input=LVI=)
[Answer]
# [Acc!!](https://github.com/dloscutoff/Esolangs/tree/master/Acc!!), 84 bytes
This is actually what inspired this challenge:
```
Write 65
Count i while i-26 {
Count b while b-i {
Write b+65
Write i+65
}
Write 10
}
```
[Try it online!](https://tio.run/##S0xOTkr6/z@8KLMkVcHMlMs5vzSvRCFToTwjMydVIVPXyEyhGiqYBBVM0s0EikF0JGkD9UCYmSBmLZRjaMBV@/8/AA "Acc!! – Try It Online")
[Answer]
# [Haskell](https://www.haskell.org/), ~~49~~ 48 bytes
```
'A':unlines[init['A'..x]>>=(:[x])|x<-['A'..'Z']]
```
[Try it online!](https://tio.run/##y0gszk7NyflfXFKUmZeuYKsQ81/dUd2qNC8nMy@1ODozL7MkGiigp1cRa2dnq2EVXRGrWVNhowsRVI9Sj439n5uYmQfUWVBaElxSpAAx6f@/5LScxPTi/7rJBQUA "Haskell – Try It Online")
*Edit: -1 byte thanks to totallyhuman!*
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform)
Port from Kevin Cruijssen's [answer](https://codegolf.stackexchange.com/a/153240/15214):
## ~~91~~ 90 bytes
```
_=>{var t="";for(char c='@';++c<91;t+=c)Console.WriteLine(string.Join(c+"",t.Skip(0))+c);}
```
[Try it online!](https://tio.run/##XY5BSwMxEIXv@RVhL02IhnqUGFH2UCgtCHvwHMapDq6JzUwLZdnfvgZBEY8Pvve@B3wNpeJyYsqveriw4EdQf5PvyzgiCJXMfoMZK8E/Ykf5GBSMiVk/TYolCYF@/O7oQRLVPjHqqBdj4/10TlVL7LpwKNXAW0sQVw@r4Bzc3d4EcRFs32xlRP9cSbDto2GpTem3hbIB13VX4od3@jRrax3YMC9B/ZjPhV70PjXQqkn9HjA2qFnNyxc "C# (.NET Core) – Try It Online")
## ~~132~~ ~~122~~ ~~110~~ ~~109~~ ~~104~~ 103 bytes
```
_=>"ABCDEFGHIJKLMNOPQRSTUVWXYZ".Select((c,i)=>string.Join(""+c,"ABCDEFGHIJKLMNOPQRSTUVWXYZ".Take(i))+c)
```
[Try it online!](https://tio.run/##fY/PTgIxEMbvfYrJntqAfYGFTXQFBEHRRVFvdRx1Ymlj2yUxhGdfaozRePA4@f7M98N4hD5Q10Z2L9B8xESbUvy@dO2tJUzsXdQTchQY/zjm7N5LgdbECMudiMkkRhi3DgfTkWs3FMyjpUFMIYeqCppkONQmEgyhk2pYFccn9eloPDmbzs7ni4vL5dV1s7q5Xd/dPxS6oc/3UmKfs/WrRM88O1kUPez/m12ZN5KsVA9VV4rvZVvPT7AwuUGJnXjO/AZfQW5NAM48wO5nolQK6ozuLel1yHKGzZXZpkqxF/vuAA "C# (.NET Core) – Try It Online")
* Replace `()` with `_` to show that we declare an unused variable. Thank you Kevin Cruijssen.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 22 bytes
```
ØAż€Ð€`F€µJ’Ḥ»1ż@¹ḣ/€Y
```
[Try it online!](https://tio.run/##y0rNyan8///wDMejex41rTk8AUgkuAGJQ1u9HjXMfLhjyaHdhkf3OBza@XDHYn2geOT//wA "Jelly – Try It Online")
How it works:
```
                       take argument implicitly
ØA                     the uppercase alphabet
    Ð€`                for C in the alphabet
  ż€                     appends C to every letter in the alphabet
       F€              flatten every sublist
          J            get indices
           ’           subtract 1
            Ḥ          and double
             »1        take max([n, 1])
         µ     ż@¹     interleave alphabet list and indices
                  ḣ/€  reduce on head() for each element
                     Y join on newline
                       implicitly output
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~44~~ 34 bytes
```
?A.upto(?Z){|w|puts [*?A...w]*w+w}
```
[Try it online!](https://tio.run/##KypNqvz/395Rr7SgJF/DPkqzuqa8pqC0pFghWgsoqqdXHqtVrl1e@/8/AA "Ruby – Try It Online")
Thanks benj2240 for getting it down to 37 bytes. And of course crossed out 44 blah blah.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 29 bytes
```
'A,Au©.sRí¦®RSDgÝ×Rs)ø˜.Bíø»=
```
[Try it online!](https://tio.run/##ATIAzf8wNWFiMWX//ydBLEF1wqkuc1LDrcKmwq5SU0Rnw53Dl1JzKcO4y5wuQsOtw7jCuz3//w "05AB1E – Try It Online")
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 96 bytes
```
+++++[->+++++>++>+++++++++++++>+++++++++++++<<<<]>>>.<.<[->>>+>+[-<<.+>.>>+<]>[-<+<<->>>]<<<<.<]
```
[Try it online!](https://tio.run/##SypKzMxLK03O/v9fGwSide3AtB0YIQFUng0QxNrZ2enZ6NkAtdjZAeWjdW1s9LTt9IAcoByQB1QFkooFKdazif3/HwA "brainfuck – Try It Online")
**Tape Layout:**
*`[Init] [Line Count] [newline] [Growing Ascii] [Repeated Ascii] [Loop 1] [Loop 2]`*
**Explanation:**
```
+++++[->+++++>++                      Sets Line counter and newline cell
    >+++++++++++++>+++++++++++++<<<<] Sets Ascii cells to 65 ('A')
>>>.<.<                               Prints first "A" and moves to Line loop
  [->>>+>+                            Increment Repeated Ascii cell in outer loop
      [-<<.+>.>>+<]>                  Increment Growing Ascii cell in inner loop,
                                         Prints both Ascii cells and Sets Loop 2
      [-<+<<->>>]                     Resets Growing cell and Loop 1
  <<<<.<]                             Prints newline and moves to next Line
```
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 81 bytes
```
+++[[->++<<+>]>]<<,<[----<<+>>]<+<+.<+<--.>[>+>>+[-<.+<.>>>+<]>[-<+<->>]<<<<<.>-]
```
[Try it online!](https://tio.run/##FYpBCsRQDEIPZJMTiBcJWbSFQhmYRaHnT/0uxKcez37/r/f8zQCoCgEk1GpyY4W12AgibRGpkhtUMMGUI1smj@u4lIqe@QA "brainfuck – Try It Online")
Prints in lowercase
### Explanation:
```
+++[[->++<<+>]>]  Sets up the tape as 3*2^n (3,6,12,24,48,96,192,128)
<<,               Removes excess 128
<[----<<+>>]      Adds 196/4 to 48 resulting in 96
<+<+.             Add 1 to both 96s and print A
<+<--.            Add 1 to 25, subtract 2 from 12 to print a newline
                  Tape: 3 6 10 25 96 96 0 0
>[ Start loop
   >+>>+          Add one to the unchanging ASCII and the inner loop counter
   [-<.+<.>>>+<]  Print row while preserving counter
   >[-<+<->>]     Undo changes to changing ASCII and return inner loop counter to its cell
   <<<<<.>-       Print newline and decrement loop counter
]
```
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 88 bytes
```
++++++++[->+++>+>++++++++>++++++++<<<<]>+>++>+.<.<[->>+>>+[-<+.<.>>>+<]>[-<+<->>]<<<<.<]
```
[Try it online!](https://tio.run/##SypKzMxLK03O/v9fGwqide2ApJ22HUwAzrABgliwhJ22no2eDVAlkGcH1GED4tsBmUB5EM8GKBMLUq5nE/v/PwA "brainfuck – Try It Online")
should run on all brainfuck interpreters. No wrapping or negative values, no undefined input behaviour, values between 0 and 90.
**How it works**
```
Initialize tape: 25(row count) 10(lf) 64(row letter) 64(col letter) 0(col count) 0(temp)
++++++++[->+++>+>++++++++>++++++++<<<<]>+>++
>+.<.            print "A" and lf
<[               for each letter count
  -                decrement letter count
  >>+              increment row letter
  >>+              increment col count
  [                do col count times
    -                decrement col count
    <+.              increment and print col letter
    <.               print row letter
    >>>+             move col count to temp
    <                return to colcount
  ]
  >[-<+<->>]       move value from temp back to col count and set col letter back to "A" minus 1
  <<<<.            print lf
  <                return to row count
]
```
[Answer]
# [Perl 5](https://www.perl.org/), ~~39~~ 38 bytes
*@DomHastings shaved off a byte*
```
say$.=A;say map$_.$.,A..$.++while$.!~Z
```
[Try it online!](https://tio.run/##K0gtyjH9/784sVJFz9bRGkgr5CYWqMTrqejpOOoBSW3t8ozMnFQVPcW6qP///@UXlGTm5xX/1/U11TMwNAAA "Perl 5 – Try It Online")
[Answer]
# Deadfish~, 4152 bytes
```
{i}cc{iiiii}iiiiic{ddddd}dddddc{iiiii}iiiiicic{ddddd}ddddddc{iiiii}iiiiiciicdcic{dddddd}iiic{iiiii}iiiiiciiicddciicdcic{dddddd}iic{iiiii}iiiiiciiiicdddciiicddciicdcic{dddddd}ic{iiiii}iiiiiciiiiicddddciiiicdddciiicddciicdcic{dddddd}c{iiiii}iiiiiciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{dddddd}dc{iiiii}iiiiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{dddddd}ddc{iiiii}iiiiic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{dddddd}dddc{iiiii}iiiiic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{dddddd}ddddc{iiiii}iiiiic{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{dddddd}dddddc{iiiii}iiiiic{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{dddddd}ddddddc{iiiii}iiiiic{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}iii}iiic{iiiii}iiiiic{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}iii}iic{iiiii}iiiiic{i}iiiic{d}dddc{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}iii}ic{iiiii}iiiiic{i}iiiiic{d}ddddc{i}iiiic{d}dddc{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}iii}c{iiiii}iiiiic{i}iiiiiic{d}dddddc{i}iiiiic{d}ddddc{i}iiiic{d}dddc{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}iii}dc{iiiii}iiiiic{ii}dddc{d}ddddddc{i}iiiiiic{d}dddddc{i}iiiiic{d}ddddc{i}iiiic{d}dddc{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}iii}ddc{iiiii}iiiiic{ii}ddc{dd}iiic{ii}dddc{d}ddddddc{i}iiiiiic{d}dddddc{i}iiiiic{d}ddddc{i}iiiic{d}dddc{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}iii}dddc{iiiii}iiiiic{ii}dc{dd}iic{ii}ddc{dd}iiic{ii}dddc{d}ddddddc{i}iiiiiic{d}dddddc{i}iiiiic{d}ddddc{i}iiiic{d}dddc{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}iii}ddddc{iiiii}iiiiic{ii}c{dd}ic{ii}dc{dd}iic{ii}ddc{dd}iiic{ii}dddc{d}ddddddc{i}iiiiiic{d}dddddc{i}iiiiic{d}ddddc{i}iiiic{d}dddc{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}iii}dddddc{iiiii}iiiiic{ii}ic{dd}c{ii}c{dd}ic{ii}dc{dd}iic{ii}ddc{dd}iiic{ii}dddc{d}ddddddc{i}iiiiiic{d}dddddc{i}iiiiic{d}ddddc{i}iiiic{d}dddc{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}iii}ddddddc{iiiii}iiiiic{ii}iic{dd}dc{ii}ic{dd}c{ii}c{dd}ic{ii}dc{dd}iic{ii}ddc{dd}iiic{ii}dddc{d}ddddddc{i}iiiiiic{d}dddddc{i}iiiiic{d}ddddc{i}iiiic{d}dddc{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}ii}iiic{iiiii}iiiiic{ii}iiic{dd}ddc{ii}iic{dd}dc{ii}ic{dd}c{ii}c{dd}ic{ii}dc{dd}iic{ii}ddc{dd}iiic{ii}dddc{d}ddddddc{i}iiiiiic{d}dddddc{i}iiiiic{d}ddddc{i}iiiic{d}dddc{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}ii}iic{iiiii}iiiiic{ii}iiiic{dd}dddc{ii}iiic{dd}ddc{ii}iic{dd}dc{ii}ic{dd}c{ii}c{dd}ic{ii}dc{dd}iic{ii}ddc{dd}iiic{ii}dddc{d}ddddddc{i}iiiiiic{d}dddddc{i}iiiiic{d}ddddc{i}iiiic{d}dddc{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}ii}ic{iiiii}iiiiic{ii}iiiiic{dd}ddddc{ii}iiiic{dd}dddc{ii}iiic{dd}ddc{ii}iic{dd}dc{ii}ic{dd}c{ii}c{dd}ic{ii}dc{dd}iic{ii}ddc{dd}iiic{ii}dddc{d}ddddddc{i}iiiiiic{d}dddddc{i}iiiiic{d}ddddc{i}iiiic{d}dddc{i}iiic{d}ddc{i}iic{d}dc{i}ic{d}c{i}c{d}ic{i}dc{d}iic{i}ddc{d}iiic{i}dddcddddddciiiiiicdddddciiiiicddddciiiicdddciiicddciicdcic{{d}ii}c
```
[Try it online!](https://tio.run/##7ZZLDoMwDERP1ENVmVbNusvIZ0@JkyDAg/pR@cOCBZ7YM08EgtsVd/98XGIMXpwLPl2idxeQLtF7v9KvDYveoVVAtFO/3ghgZUaVZBiTW7XK8W4hWZcX4osmg8QNuqRFp80PPVnTpip/nEBG5AnTTLPjdML0c@3gVJc5HRAL6gGzuclN7P4L5Vl55ZbzxWwVX1iNS2qyusRKXXPTrWtsJYfZRLlp6OyxzUaj2dI3RPYXlWUtUXcenCTPUQ8FgVDQ36UcFggjkpHg0HjYcaX6qmfkk1QhRUFVUjjJjZLj4FpyOFl@zNLF@AI "Deadfish~ – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 12 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
ØA;\;€Ṫ$€YFḊ
```
**[Try it online!](https://tio.run/##y0rNyan8///wDEfrGOtHTWse7lylAqQi3R7u6Pr/HwA "Jelly – Try It Online")**
Bah just got `ØAjṪ$ƤżØAY` which is a step between this and the already posted solution of Dennis :/
[Answer]
# [Pyth](https://pyth.readthedocs.io), 13 bytes
```
+\ajmPjedd._G
```
[Try it here!](https://pyth.herokuapp.com/?code=%2B%5CajmPjedd._G&debug=0), [Alternative](https://pyth.herokuapp.com/?code=jm%2BjedPded._G&debug=0)
That leading `a` though...
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 13 bytes
```
ØA¹Ƥ+"¹Ṗ€Yṭ”A
```
[Try it online!](https://tio.run/##ASIA3f9qZWxsef//w5hBwrnGpCsiwrnhuZbigqxZ4bmt4oCdQf// "Jelly – Try It Online")
# Explanation
```
ØA¹Ƥ+"¹Ṗ€Yṭ”A  Main Link
ØA              Uppercase Alphabet
  ¹Ƥ            Prefixes
    +"¹         Doubly-vectorized addition to identity (uppercase alphabet) (gives lists of lists of strings)
       Ṗ€      a[:-1] of each (get rid of the double letters at the end)
         Y     Join on newlines
          ṭ”A  "A" + the result
```
partially abuses the way strings and character lists differ in Jelly
[Answer]
# [Python 2](https://docs.python.org/2/), ~~92~~ ~~86~~ ~~79~~ ~~75~~ 64 bytes
```
s=map(chr,range(65,91))
for d in s:print d.join(s[:ord(d)-65])+d
```
[Try it online!](https://tio.run/##K6gsycjPM/r/v9g2N7FAIzmjSKcoMS89VcPMVMfSUFOTKy2/SCFFITNPodiqoCgzr0QhRS8rPzNPozjaKr8oRSNFU9fMNFZTO@X/fwA "Python 2 – Try It Online")
11 bytes thx to Rod.
[Answer]
# APL+WIN, 51 bytes
```
⍎∊'a←⎕av[65+⍳26]⋄a[n←1]',25⍴⊂'⋄,⊃a[⍳n-1],¨a[n←n+1]'
```
Explanation:
```
a←⎕av[65+⍳26] create a vector of upper case letters
a[n←1] first A
25⍴⊂'⋄,⊃a[⍳n-1],¨a[n←n+1]' create an implicit loop to concatenate subsequent letters
```
]


[Question]
      [
This has no practical purpose but it could be fun to golf.
# Challenge
Given a number *n*,
1. Count the amount of each digit in *n* and add 1 to each count
2. Take the prime factorization of *n*
3. Count the amount of each digit in the prime factorization of *n*, without including duplicate primes
4. Create a new list by multiplying together the respective elements of the lists from steps 1 and 3
5. Return the sum of that list
For example, 121 has two `1`s and a `2`, so you would get the following list from step 1:
```
0 1 2 3 4 5 6 7 8 9
1 3 2 1 1 1 1 1 1 1
```
The prime factorization of 121 is 112, which gives the following list for step 3:
```
0 1 2 3 4 5 6 7 8 9
0 2 0 0 0 0 0 0 0 0
```
Note how we did not count the exponent. These multiply together to get:
```
0 1 2 3 4 5 6 7 8 9
0 6 0 0 0 0 0 0 0 0
```
And the sum of this list is 6.
# Test cases
```
1 -> 0
2 -> 2
3 -> 2
4 -> 1
5 -> 2
10 -> 2
13 -> 4
121 -> 6
```
# Notes
* [Standard loopholes](//codegolf.meta.stackexchange.com/q/1061/75524) are forbidden.
* Input and output can be in any reasonable format.
* You should leave ones (or zeros for step 3) in the list for digits that did not appear in the number.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest solution in bytes wins.

[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~18~~ 17 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
-1 byte thanks to [caird coinheringaahing](https://codegolf.stackexchange.com/users/66833/caird-coinheringaahing) & [H.PWiz](https://codegolf.stackexchange.com/users/71256/h-pwiz) (avoid pairing the two vectors)
```
DF‘ċÐ€⁵
ÆfQÇæ.Ç‘$
```
A monadic link taking a positive integer and returning a non-negative integer.
**[Try it online!](https://tio.run/##y0rNyan8/9/F7VHDjCPdhyc8alrzqHEr1@G2tMDD7YeX6R1uB0qo/P//39DIEAAA "Jelly – Try It Online")**
### How?
```
DF‘ċÐ€⁵ - Link 1, digitalCount: number(s)    e.g. [13,17]
D       - to decimal list (vectorises)            [[1,3],[1,7]]
 F      - flatten                                 [1,3,1,7]
  ‘     - increment (vectorises)                  [2,4,2,8]
      ⁵ - literal ten                             10
    Ð€  - map across              (implicit range [1,2,3,4,5,6,7,8,9,10])
   ċ    - count                                   [0,2,0,1,0,0,0,1,0,0]
ÆfQÇæ.Ç‘$ - Main link: positive integer, n   e.g. 11999
        $ - last two links as a monad:
      Ç   -   call the last link (1) as a monad   [0,2,0,0,0,0,0,0,0,3]
       ‘  -   increment (vectorises)              [1,3,1,1,1,1,1,1,1,4]
Æf        - prime factorisation                   [13,13,71]
  Q       - deduplicate                           [13,17]
   Ç      - call the last link (1) as a monad     [0,2,0,1,0,0,0,1,0,0]
    æ.    - dot product                           8
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 16 bytes
```
ṾċÐ€ØD
ÆfQÇ×Ç‘$S
```
[Try it online!](https://tio.run/##ATMAzP9qZWxsef//4bm@xIvDkOKCrMOYRArDhmZRw4fDl8OH4oCYJFP/UsW8w4figqxH//8xMjE "Jelly – Try It Online")
Developed independently from and not exactly the same as [the other Jelly solution](https://codegolf.stackexchange.com/a/151631/75553).
**Explanation**
I'm gong to use `242` as an example input.
```
ṾċÐ€ØD     Helper link
Ṿ          Uneval. In this case, turns it's argument into a string.
           242Ṿ → ['2','4','2']. [2,11] → ['2', ',', '1', '1']. The ',' won't end up doing anything.
    ØD     Digits: ['0','1',...,'9']
 ċÐ€       Count the occurrence of €ach digit in the result of Ṿ
ÆfQÇ×Ç‘$S  Main link. Argument 242
Æf         Prime factors that multiply to 242 → [2,11,11]
  Q        Unique elements → [2,11]
   Ç       Apply helper link to this list → [0,2,1,0,0,0,0,0,0,0]
     Ç‘$   Apply helper link to 242 then add 1 to each element → [1,1,3,1,2,1,1,1,1,1]
    ×      Multiply the two lists element-wise → [0,2,3,0,0,0,0,0,0,0]
        S  Sum of the product → 5
```
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), ~~43~~ 41 bytes
```
⎕CY'dfns'
+/×/+/¨⎕D∘.=⍕¨(⎕D,r)(∪3pco r←⎕)
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKPdOSM1Ofv/o76pzpHqKWl5xepc2vqHp@tr6x9aARR0edQxQ8/2Ue/UQys0QFydIk2NRx2rjAuS8xWKHrVNAIppgkz5DzaGy5CLC8IwgjGMYQwTGMMUxjA0gLPgqgyNDAE "APL (Dyalog Unicode) – Try It Online")
**How?**
`r←⎕` - input into `r`
`3pco` - prime factors
`∪` - unique
`⎕D,r` - `r` prepended with `0-9`
`⍕¨` - format the factors and the prepended range
`⎕D∘.=` - cartesian comparison with every element of the string `0123456789`
`+/¨` - sum each row of the two tables formed
`×/` - multiply the two vectors left
`+/` - sum the last vector formed
[Answer]
# [05AB1E (legacy)](https://github.com/Adriandmen/05AB1E/tree/fb4a2ce2bce6660e1a680a74dd61b72c945e6c3b), 5 bytes
```
fS¢>O
```
[Try it online!](https://tio.run/##MzBNTDJM/f8/LfjQIjv////NzMwB "05AB1E (legacy) – Try It Online")
```
f      list of prime factors (without duplicates) of the implicit input
S      characters, all of the digits
¢      count each of the characters in the implicit input
>      increase each of the counts
O      sum (implicit output)
```
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 44 bytes
```
Y_N_.aM,tT++o>aTa%o{a/:olPBo}$+y*Y_N JUQlM,t
```
Takes input from command-line argument. [Try it online!](https://tio.run/##K8gs@P8/Mt4vXi/RV6ckRFs73y4xJFE1vzpR3yo/J8Apv1ZFu1ILqEDBKzQwB6jk////ugX/jYyNzC2NTM0MAA "Pip – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), ~~136~~ 127 bytes
```
lambda a:sum(''.join(u(a)).count(`i`)*-~`a`.count(`i`)for i in range(10))
u=lambda a:[`j`for j in range(2,a)if a%j<1>len(u(j))]
```
[Try it online!](https://tio.run/##TY0xDsIwDAB3XuEF1UZQkYyI8hFAsoEWErVOG5KBha8HdQHW0@lufKVHUFum5lR6GS43Adk984BVVfvgFDMKUX0NWROyY1pt3iz8B7oQwYFTiKL3Fs2WaJGbb@vInmfF/xS7FnIdyNLvzaFv54cnOpcxOk0wobGGygc "Python 2 – Try It Online")
# Credits
* Reduced from 136 bytes to 127 by [Mr. Xcoder](https://codegolf.stackexchange.com/users/59487/mr-xcoder)
]


[Question]
      [
Your task is to program a mathematical function \$s\$, that takes a nonempty finite set \$A\$ of points in the 2D plane, and outputs an uncircularity score \$s(A)\$ that satisfies following properties:
1. *Positive Definiteness*: If there is a circle or a straight line that contains all points of \$A\$, then \$s(A) = 0\$. Otherwise \$s(A) > 0\$
2. *Surjectivity:* It is surjective to the nonnegative real numbers, that means for every nonnegative real number \$r\$ there is a finite subset \$A\$ of the plane such that \$s(A) = r\$.
3. *Translation Invariance:* \$s\$ is translation invariant if \$s(A) = s(A + v)\$ for every vector \$v\$ and for all \$A\$.
4. *Scale Invariance:* \$s\$ is scale invariant, if \$s(A) = s(tA)\$ for every \$t≠0\$ and for all \$A\$.
5. *Continuity.* \$s\$ is said to be *continuous* if the function \$f(p) := s(A ∪ \{p\})\$ (mapping the a point `p` to a real number) is continuous using the standard absolute value on the real numbers, and the standard euclidean norm on the points of the plane.
Intuitively speaking this *uncircularness score* can be thought of as something similar to the correlation coefficient in linear regression.
### Details
Your function in theory has to work in the reals, but for the purpose of this challenge you can use floating point numbers as substitute. Please provide an explanation of your submission and an argument why those five properties hold. You can take two lists of coordinates or a list of tuples or similar formats as input. You can assume that no point in the input is repeated i.e. all points are unique.

[Answer]
# Python 2 with numpy, 116 bytes
```
from numpy import*
def f(x,y):a=linalg.lstsq(hstack((x,y,ones_like(x))),(x*x+y*y)/2);return a[1]/sum((x-a[0][0])**4)
```
Takes x and y as 2d column vectors and returns an array containing the answer. Note that this will give an empty array for a perfectly straight line or with 3 or fewer points. I think lstsq gives no residuals if there's a perfect fit.
### Explanation
Essentially, this finds the circle of best fit and gets the squared residuals.
We want to minimize `(x - x_center)^2 + (y - y_center)^2 - R^2`. It looks nasty and nonlinear, but we can rewrite that as `x_center(-2x) + y_center(-2y) + stuff = x^2 + y^2`, where the `stuff` is still nasty and nonlinear in terms of `x_center`, `y_center`, and `R`, but we don't need to care about it. So we can just solve `[-2x -2y 1][x_center, y_center, stuff]^T = [x^2 + y^2]`.
We could then back out R if we really wanted, but that doesn't help us much here. Thankfully, the lstsq function can give us the residuals, which satisfies most of the conditions. Subtracting the center and scaling by `(R^2)^2 = R^4 ~ x^4` gives us translational and scale invariance.
1. This is positive definite because the squared residuals are nonnegative, and we're dividing by a square. It tends toward 0 for circles and lines because we're fitting a circle.
2. I'm fairly sure it's not surjective, but I can't get a good bound. If there is an upper bound, we can map [0, bound) to the nonnegative reals (for example, with 1 / (bound - answer) - 1 / bound) for a few more bytes.
3. We subtract out the center, so it's translationally invariant.
4. We divide by x\*\*4, which removes the scale dependence.
5. It's composed of continuous functions, so it's continuous.
[Answer]
# Python, 124 bytes
```
lambda A:sum(r.imag**2/2**abs(r)for a in A for b in A for c in A for d in A if a!=d!=b!=c for r in[(a-c)*(b-d)/(a-d)/(b-c)])
```
Takes *A* as a sequence of complex numbers (`x + 1j*y`), and sums Im(*r*)2/2|*r*| for all complex cross-ratios *r* of four points in *A*.
### Properties
1. *Positive Definiteness.* All terms are nonnegative, and they’re all zero exactly when all the cross-ratios are real, which happens when the points are collinear or concyclic.
2. *Surjectivity.* Since the sum can be made arbitrarily large by adding many points, surjectivity will follow from continuity.
3. *Translation Invariance.* The cross-ratio is translation-invariant.
4. *Scale Invariance.* The cross-ratio is scale-invariant. (In fact, it’s invariant under all Möbius transformations.)
5. *Continuity.* The cross-ratio is a continuous map to the extended complex plane, and *r* ↦ Im(*r*)2/2|*r*| (with ∞ ↦ 0) is a continuous map from the extended complex plane to the reals.
(Note: A theoretically prettier map with the same properties is *r* ↦ (Im(*r*)/(*C* + |*r*|2))2, whose contour lines w.r.t. all four points of the cross-ratio are circular. If you actually need an uncircularness measure, you probably want that one.)
]


[Question]
      [
A deck of cards is the Cartesian product of `S` suits and `R` ranks.
Many, though not all, card games use `S=4` and `R∊{6,8,13}`.
A hand of `H` cards is dealt from the deck.
Its *distribution*, a.k.a. "hand pattern", is an array that describes
how many cards you got from each suit, ignoring suit order (so, it's like a multi-set).
Given a distribution `D` satisfying `len(D)=S`, `1≤sum(D)=H≤S×R`, `0≤D[i]≤R`, `D[i]≥D[i+1]`,
find the probability of it occurring.
Input: an integer `R` and an array `D`.
Output: the probability with at least 5 digits after the decimal mark;
 trailing zeroes may be skipped; scientific notation is ok.
Loopholes forbidden. Shortest wins.
Tests:
```
R    D               probability
13   4 4 3 2     ->  0.2155117564516334148528314355068773
13   5 3 3 2     ->  0.1551684646451760586940386335649517
13   9 3 1 0     ->  0.0001004716813294328274372174524508
13   13 0 0 0    ->  0.0000000000062990780897964308603403
8    3 2 2 1     ->  0.4007096203759162602321667950144035
8    4 2 1 1     ->  0.1431105787056843786543452839337155
8    2 2 1 0     ->  0.3737486095661846496106785317018910
8    3 1 1 0     ->  0.2135706340378197997775305895439377
15   4 4 3 2 1   ->  0.1428926269185580521441708109954798
10   3 0 0       ->  0.0886699507389162561576354679802956
10   2 1 0       ->  0.6650246305418719211822660098522167
10   1 1 1       ->  0.2463054187192118226600985221674877
```
See also [Bridge hand patterns in Wikipedia](https://en.wikipedia.org/wiki/Contract_bridge_probabilities#Hand_pattern_probabilities).
EDIT: dropped unnecessary restriction `H≤R`
EDIT: added constraint `H≥1`

[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 30 chars
```
×/!⍨,z,1÷((z←!∘≢⊢)⌸⊢),×∘≢!⍨1⊥⊢
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24TD0/UVH/Wu0KnSMTy8XUOjCiik@KhjxqPORY@6Fmk@6tkBonQOT4eIgZQaPupaChT8/9/QWCFNwQQIjRWMuMAcUyATzrEEMg0VDCAcIGEAglwWQA5IDRAaQjgmICaMAxZHKDOEmGCKsAio0NAAyAWbB2FCdICZIPWGAA)
Using [@orlp’s formula](https://codegolf.stackexchange.com/a/148624/74681).
[Answer]
# Python 3, 134 bytes
```
b=lambda n,k:k<1or n*b(n-1,k-1)/k
f=lambda R,D,i=1,s=1,t=0:D and b(R,D[0])*i/s*f(R,D[1:],i+1,(D[0]in D[1:])*s+1,t+D[0])or 1/b(~-i*R,t)
```
Formula is the product of `binom(R, d)` for each element `d` in `D`, times `factorial(len(D))`, divided by the product of `factorial(len(S))` for each `S` in the groupings of `D` (e.g. `[4, 4, 3, 2]` has groupings `[[4, 4], [3], [2]]`), finally divided by `binom(len(D) * R, sum(D))`.
Or in math notation, assuming **m** contains the multiplicities of the **n** unique elements in **D**:
$$
\frac{|D|!}{m\_1!\cdot m\_2!\cdots m\_n!}
\binom{|D|\cdot R}{\sum D}^{-1}
\prod\_{d\in D}\binom{R}{d}
$$
[Answer]
# [R](https://www.r-project.org/), ~~90~~ ~~85~~ 83 bytes
```
function(R,D,l=sum(D|1),K=choose)prod(K(R,D),1:l,1/gamma(1+table(D)))/K(R*l,sum(D))
```
[Try it online!](https://tio.run/##JYs7DsIwEAV7n8LlvrAorNIgRDp36biBceKA5A@Kk467mwCaYorRLNXr61FXvyW3PnOiGxsOfdkimbeAh949ci4TXkseafhmsFwCSzvbGC3JYbX3MJEB0O69CfybgeqpOJsIrP@GOivVadk51Q8 "R – Try It Online")
I observed the same thing as [orlp](https://codegolf.stackexchange.com/a/148624/67312), but I picked a nice language that has combinatorics builtins.
Explanation:
```
function(R,D,             # next are optional arguments
 l=sum(D|1),              # alias for length of D, aka S
 K=choose)                # alias for choose
  prod(                   # take the product of:
    K(R,D),               # "choose" is vectorized over R and D
    1:l,                  # S!
    1/gamma(1+            # gamma(n+1) = n! for integer n
     table(D))            # multiplicities of unique elements of D
  ) /                     # divide by
  K(R`*`l, sum(D))          # R`*`S choose H
                          # return last computation (which is all the computation)
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~22~~ 20 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
-2 bytes using a new quick, `ʋ`, and a new monadic atom `Ẉ`
```
ĠẈ!;L×c⁸S¤ʋ
L!;c@÷çP
```
A dyadic link, taking the dealt-distribution, D, on the left and the number-of-ranks, R, on the right, which returns the probability of occurrence.
**[Try it online!](https://tio.run/##y0rNyan8///Igoe7OhStfQ5PT37UuCP40JJT3Vw@itbJDoe3H14e8P//f2MdIyA0/G8BAA "Jelly – Try It Online")** or see the [test-suite](https://tio.run/##y0rNyan8///Igoe7OhStfQ5PT37UuCP40JJT3Vw@itbJDoe3H14e8P/onsPLHfQfNa05OunhzhlAGojc//@PjjY01lGIVjDRASEg0yg2VodLASpqChZCF7UECxnqKBggiYIIAwiCiCpYgNSC9IKRIbKoCUQITdQIJopugiGKbaao7oUbYmgAVY5wA0QIxVCIkCHM9lgA "Jelly – Try It Online")
### How?
```
ĠẈ!;L×c⁸S¤ʋ - Link 1, denomParts: list, distribution (D); number, ranks (R)
                                                                 e.g. [3,3,3,2,2]; 8
Ġ           - group indices of D by their values                      [[4,5],[1,2,3]]
 Ẉ          - length of each group                                    [2,3]
  !         - factorial (vectorises)                                  [2,6]
          ʋ - last four links as a dyad
            - ... i.e. totalWaysToDeal = f(list, distribution (D); number, ranks (R)):
    L       - length of D                                             5
     ×      - multiply by R = total number of cards                   40
         ¤  - nilad followed by link(s) as a nilad:
       ⁸    -   chain's left argument, D                              [3,3,3,2,2]
        S   -   sum = total cards dealt                               13
      c     - binomial                                        40C13 = 12033222880
   ;        - concatenate                                             [2,6,12033222880]
L!;c@÷çP - Main link: list, distribution (D); number, ranks (R)
         -                                                  e.g. [3,3,3,2,2]; 8
L        - length of D = number of suits                         5
 !       - factorial                                             120
   c@    - R binomial (vectorised across) D     (8C3=56;8C2=28)  [56,56,56,28,28]
  ;      - concatenate                                           [120,56,56,56,28,28]
      ç  - call the last link (1) as a dyad = denomParts(D,R)    [2,6,12033222880]
     ÷   - divide (vectorises)                                   [120/2,56/6,56/12033222880,56,28,28]
       P - product                                               0.11441900924883391
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 21 bytes
```
cP¹g!*¹γ€g!P¹gI*¹Oc*/
```
[Try it online!](https://tio.run/##MzBNTDJM/f8/OeDQznRFrUM7z21@1LQmXRHE9QRy/ZO19P//jzbVMQZCo1guQ2MA "05AB1E – Try It Online")
**Explanation**
```
 P                      # product of
c                       # bin(input1,input2)
     *                  # multiplied by
    !                   # fac of
  ¹g                    # length of input1
                    /   # divided by
           P            # product of
          !             # fac of each
        €g              # length of each
      ¹γ                # chunk of consecutive equal elements of input1
                   *    # multiplied by
                  c     # bin of
            ¹g          # length of input1
              I*        # times input2
                ¹O      # and sum of input1
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 32 bytes
```
cc*.!lQ*F.cLvzQ*F.!hMr8Q.c*vzlQs
```
**[Try it here!](https://pyth.herokuapp.com/?code=cc%2a.%21lQ%2aF.cLvzQ%2aF.%21hMr8Q.c%2avzlQs&input=%5B1%2C1%2C1%5D%0A10&test_suite_input=%5B4%2C+4%2C+3%2C+2%5D%0A13%0A%0A%5B5%2C+3%2C+3%2C+2%5D%0A13%0A%0A%5B9%2C+3%2C+1%2C+0%5D%0A13%0A%0A%5B13%2C+0%2C+0%2C+0%5D%0A13%0A%0A%5B3%2C+2%2C+2%2C+1%5D%0A8%0A%0A%5B4%2C+2%2C+1%2C+1%5D%0A8%0A%0A%5B2%2C+2%2C+1%2C+0%5D%0A8%0A%0A%5B3%2C+1%2C+1%2C+0%5D%0A8%0A%0A%5B4%2C+4%2C+3%2C+2%2C+1%5D%0A15%0A%0A%5B3%2C+0%2C+0%5D%0A10%0A%0A%5B2%2C+1%2C+0%5D%0A10%0A%0A%5B1%2C+1%2C+1%5D%0A10%0A&debug=0&input_size=3)** or **[Verify all the test cases!](https://pyth.herokuapp.com/?code=cc%2a.%21lQ%2aF.cLvzQ%2aF.%21hMr8Q.c%2avzlQs&input=%5B1%2C1%2C1%5D%0A10&test_suite=1&test_suite_input=%5B4%2C+4%2C+3%2C+2%5D%0A13%0A%0A%5B5%2C+3%2C+3%2C+2%5D%0A13%0A%0A%5B9%2C+3%2C+1%2C+0%5D%0A13%0A%0A%5B13%2C+0%2C+0%2C+0%5D%0A13%0A%0A%5B3%2C+2%2C+2%2C+1%5D%0A8%0A%0A%5B4%2C+2%2C+1%2C+1%5D%0A8%0A%0A%5B2%2C+2%2C+1%2C+0%5D%0A8%0A%0A%5B3%2C+1%2C+1%2C+0%5D%0A8%0A%0A%5B4%2C+4%2C+3%2C+2%2C+1%5D%0A15%0A%0A%5B3%2C+0%2C+0%5D%0A10%0A%0A%5B2%2C+1%2C+0%5D%0A10%0A%0A%5B1%2C+1%2C+1%5D%0A10%0A&debug=0&input_size=3)**
### How this works?
```
cc*.!lQ*F.cLvzQ*F.!hMr8Q.c*vzlQs ~ Full program. D = list, R = number.
   .!                            ~ The factorial of...
     lQ                            ~ The length of D.
  *                              ~ Multiplied by...
       *F                          ~ The product of the elements of...
         .c                          ~ The nCr between...
           L  Q                        ~ Each element of D, and...
            vz                         ~ R.
 c                               ~ Divided by...
               *F                  ~ The product of the elements of...
                 .!                  ~ The factorial of each...
                   hM                  ~ Heads. Count of adjacent elements in...
                     r8Q                 ~ The run length encoding of D.
c                                ~ Divided by...
                        .c         ~ The nCr between...
                          *          ~ The product of...
                           vz          ~ R, and...
                             lQ        ~ The length of D.
                               s   ~ And the sum of D.
                                 ~ Output implicitly.
```
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 42 bytes
```
{×/(!≢⍵),(⍵!⍺),÷((+/⍵)!⍺×≢⍵),!≢¨⍵⊂⍨1,2≠/⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24Tqw9P1NRQfdS561LtVU0cDSCo@6t2lqXN4u4aGtj5IEMQ/PB2mAqT00Aog81FX06PeFYY6Ro86F4DU1f7/b2iskKZgAoTGCkZcYI4pkAnnWAKZhgoGEA6QMABBLgsgB6QGCA0hHBMQE8YBiyOUGUJMMEVYBFRoaADkgs2DMCE6wEyQekMA "APL (Dyalog Unicode) – Try It Online")
Still golfing.
[Answer]
## Clojure, 153 bytes
```
#(apply +(for[_(range 1e06):when(=(remove #{0}%)(reverse(sort(vals(frequencies(take(apply + %)(shuffle(for[i(range %2)j(range(count %))]j))))))))]1e-06))
```
Just a brute-force simulation, to get more precision increase the iteration count and the "1 / N" value at the end accordingly. First argument is the counts and 2nd argument is the number of cards in the deck per suite.
[Answer]
# J, 57 bytes
```
](#@]%~[:+/[-:"1[:\:~@(#/.~)"1+/@[{."1])i.@!@(*+/)A.(##\)
```
[Try it online!](https://tio.run/##Rc29DsIgGIXhnas4Qkz5RPmx25c0weugTEaiXRw6Grl1Sqfm5B2e6SytrJgYHr2WtYr5XBMbl24sQ@KZa9TK2UoyGBfTz8qQ6WPjKeqLcfSwWqmZGglpMZSJB1zxZ5RViNfz/cWIgrDv4L3THxz7uUfbAA "J – Try It Online")
This runs in *O(golf)* and will choke on many of the test cases (though works theoretically), which would be fine if it were golfier. But I'm stuck on trimming it down, especially with avoiding those repeated `"1`. If anyone wants to help, here's the parsed version...
The right side of the main fork is all possible deals of the *deck*, and the left side of the main fork is just the original right arg, ie, the suit mask we're matching against.
Inside, from each "shuffled" deck, we take the first *hand* elements, then group them using key `/.` and sort the result, and check if that matches the suit mask in question. We add add up the total number that do match, and divide that into the length of all possible decks.
```
┌─┬─────────────────────────────────────────────────────────────────────────────────────────────────┬─────────────────────────────────────┐
│]│┌───────┬─────┬─────────────────────────────────────────────────────────────────────────────────┐│┌──────────────────────┬──┬─────────┐│
│ ││┌─┬─┬─┐│┌─┬─┐│┌──┬─────┬──────────────────────────────────────────────────────────────────────┐│││┌────────┬─┬─────────┐│A.│┌─┬─────┐││
│ │││#│@│]│││%│~│││[:│┌─┬─┐│┌─┬────────┬─────────────────────────────────────────────────────────┐│││││┌──┬─┬─┐│@│┌─┬─────┐││  ││#│┌─┬─┐│││
│ ││└─┴─┴─┘│└─┴─┘││  ││+│/│││[│┌──┬─┬─┐│┌──┬───────────────────────────┬────────────────────────┐│││││││i.│@│!││ ││*│┌─┬─┐│││  ││ ││#│\││││
│ ││       │     ││  │└─┴─┘││ ││-:│"│1│││[:│┌─────────────────────┬─┬─┐│┌───────────┬────────┬─┐│││││││└──┴─┴─┘│ ││ ││+│/││││  ││ │└─┴─┘│││
│ ││       │     ││  │     ││ │└──┴─┴─┘││  ││┌──────┬─┬──────────┐│"│1│││┌─────┬─┬─┐│┌──┬─┬─┐│]││││││││        │ ││ │└─┴─┘│││  │└─┴─────┘││
│ ││       │     ││  │     ││ │        ││  │││┌──┬─┐│@│┌──────┬─┐││ │ ││││┌─┬─┐│@│[│││{.│"│1││ ││││││││        │ │└─┴─────┘││  │         ││
│ ││       │     ││  │     ││ │        ││  ││││\:│~││ ││┌─┬──┐│~│││ │ │││││+│/││ │ ││└──┴─┴─┘│ │││││││└────────┴─┴─────────┘│  │         ││
│ ││       │     ││  │     ││ │        ││  │││└──┴─┘│ │││#│/.││ │││ │ ││││└─┴─┘│ │ ││        │ ││││││└──────────────────────┴──┴─────────┘│
│ ││       │     ││  │     ││ │        ││  │││      │ ││└─┴──┘│ │││ │ │││└─────┴─┴─┘│        │ ││││││                                     │
│ ││       │     ││  │     ││ │        ││  │││      │ │└──────┴─┘││ │ ││└───────────┴────────┴─┘│││││                                     │
│ ││       │     ││  │     ││ │        ││  ││└──────┴─┴──────────┘│ │ ││                        │││││                                     │
│ ││       │     ││  │     ││ │        ││  │└─────────────────────┴─┴─┘│                        │││││                                     │
│ ││       │     ││  │     ││ │        │└──┴───────────────────────────┴────────────────────────┘││││                                     │
│ ││       │     ││  │     │└─┴────────┴─────────────────────────────────────────────────────────┘│││                                     │
│ ││       │     │└──┴─────┴──────────────────────────────────────────────────────────────────────┘││                                     │
│ │└───────┴─────┴─────────────────────────────────────────────────────────────────────────────────┘│                                     │
└─┴─────────────────────────────────────────────────────────────────────────────────────────────────┴─────────────────────────────────────┘
```
]


[Question]
      [
There are several ways to create headers on posts on the Stack Exchange network. The format that's most commonly1 used on PPCG seems to be:
```
# Level one header
## Level two header
### Level three header
```
Note the space after the hash marks. Also, note that trailing hash marks are not included.
## Challenge:
Take a (possibly multiline) string as input, and output the string on the following format:
* If the header is level 1, then output each letter 4-by-4 times
* If the header is level 2, then output each letter 3-by-3 times
* If the header is level 3, then output each letter 2-by-2 times
* If a line is not a header then output it as it is.
To illustrate:
```
--- Level 1 ---
# Hello
--- Output---
HHHHeeeelllllllloooo
HHHHeeeelllllllloooo
HHHHeeeelllllllloooo
HHHHeeeelllllllloooo
--- Level 2 ---
## A B C def
--- Output ---
AAA   BBB   CCC   dddeeefff
AAA   BBB   CCC   dddeeefff
AAA   BBB   CCC   dddeeefff
--- Level 3 ---
### PPCG!
--- Output---
PPPPCCGG!!
PPPPCCGG!!
```
Simple as that!
---
### Rules:
* You must support input over multiple lines. Using `\n` etc. for newlines is OK.
	+ There won't be lines containing only a `#` followed by a single space
* The output must be presented over multiple lines. You may not output `\n` instead of literal newlines.
	+ Trailing spaces and newlines are OK.
---
### Test cases:
Input and output are separated by a line of `...`.
```
# This is a text
with two different
### headers!
........................................................
TTTThhhhiiiissss    iiiissss    aaaa    tttteeeexxxxtttt
TTTThhhhiiiissss    iiiissss    aaaa    tttteeeexxxxtttt
TTTThhhhiiiissss    iiiissss    aaaa    tttteeeexxxxtttt
TTTThhhhiiiissss    iiiissss    aaaa    tttteeeexxxxtttt
with two different
hheeaaddeerrss!!
hheeaaddeerrss!!
```
---
```
This input has
## trailing hash marks ##
#and a hash mark without a space after it.
........................................................
This input has
tttrrraaaiiillliiinnnggg   hhhaaassshhh   mmmaaarrrkkksss   ######
tttrrraaaiiillliiinnnggg   hhhaaassshhh   mmmaaarrrkkksss   ######
tttrrraaaiiillliiinnnggg   hhhaaassshhh   mmmaaarrrkkksss   ######
#and hash marks without a space after it.
```
---
```
# This ## is ### strange
#### ###
........................................................
TTTThhhhiiiissss    ########    iiiissss    ############    ssssttttrrrraaaannnnggggeeee
TTTThhhhiiiissss    ########    iiiissss    ############    ssssttttrrrraaaannnnggggeeee
TTTThhhhiiiissss    ########    iiiissss    ############    ssssttttrrrraaaannnnggggeeee
TTTThhhhiiiissss    ########    iiiissss    ############    ssssttttrrrraaaannnnggggeeee
#### ###
```
---
```
Multiple
### newlines! #
:)
........................................................
Multiple
nneewwlliinneess!!  ##
nneewwlliinneess!!  ##
:)
```
---
```
Line with only a hash mark:
#
### ^ Like that!
........................................................
Line with only a hash mark:
#
^^  LLiikkee  tthhaatt!!
^^  LLiikkee  tthhaatt!!
```
1: I haven't really checked, but I *think* it's true.

[Answer]
# [Stacked](https://github.com/ConorOBrien-Foxx/stacked), ~~51~~ 50 bytes
*Saved 1 byte thanks to @RickHitchcock - golfed regex*
```
['^(##?#?) (.+)'[\#'5\-@k CS k*k rep LF#`]3/mrepl]
```
[Try it online!](https://tio.run/##TU9BasMwELzrFUN1UNKmMaXtISUkIYaeAj70GCdUduRa2JKMJDv49e4m9FAEM6tlZnc2RFk26jJNR3Gecb7l2zlmy6e5OOZcvOfPuwbpF5rHBl51OHzy79NrYqhuT9Puo2KCI3Wm86pWNuhBgSOqEFHKoALjHPuRBNZ5ZELsvVaWmhyz0nWj1z91xMtq9YZ9Omc8FjW4V7Jl/P5ireBIpC1chduvat1VeSjjoi6dxZpDB/S2se5qFyj6CCPtSFptG@iIi/IUKlAZ0N29lXfmPkvaktJEFkZTuPa2wUjqE2gKj4dY91E@LCAxSK@ljX8hoiSUdCGdLT3Ntr0plA9Ldjs3@5eX/OCc6ShEQKPtRZLJtaTDerPeEJ2H80CUZtmBKMmTnIgwYQIVXB@nXw "Stacked – Try It Online")
Anonymous function that takes input from the stack and leaves it on the stack.
## Explanation
```
['^(##?#?) (.+)'[\#'5\-@k CS k*k rep LF#`]3/mrepl]
[                                            mrepl]   perform multiline replacement
 '^(##?#?) (.+)'                                     regex matching headers
                [                        ]3/         on each match:
                 \#'                                   count number of hashes
                    5\-                                5 - (^)
                       @k                              set k to number of repetitions
                          CS                           convert the header to a char string
                             k*                        repeat each char `k` times
                               k rep                   repeat said string `k` times
                                     LF#`              join by linefeeds
```
[Answer]
# JavaScript (ES6), ~~111~~ 105 bytes
*Saved 6 bytes thanks to @Shaggy*
```
s=>s.replace(/^(##?#?) (.+)/gm,(_,a,b)=>`
${b.replace(/./g,e=>e.repeat(l=5-a.length))}`.repeat(l).trim())
```
Matches 1-3 hashes at the beginning of the string or preceded by a new line, then repeats each character in the match along with the match itself, based on the length of the hashes.
**Test Cases:**
```
let f=
s=>s.replace(/^(##?#?) (.+)/gm,(_,a,b)=>`
${b.replace(/./g,e=>e.repeat(l=5-a.length))}`.repeat(l).trim())
console.log(f('# This is a text\nwith two different\n### headers!'));
console.log('______________________________________________');
console.log(f('This input has\n## trailing hash marks ##\n#and a hash mark without a space after it.'));
console.log('______________________________________________');
console.log(f('# This ## is ### strange\n#### ###'));
console.log('______________________________________________');
console.log(f('Multiple\n\n\n### newlines! # \n:)'));
console.log('______________________________________________');
console.log(f('Line with only a hash mark:\n#\n### ^ Like that!'));
```
[Answer]
# [Retina](https://github.com/m-ender/retina), ~~125~~ 104 bytes
```
m(`(?<=^# .*).
$0$0$0$0
(?<=^## .*).
$0$0$0
(?<=^### .*).
$0$0
^#
$%'¶$%'¶$%'¶
^##
$%'¶$%'¶
^###
$%'¶
```
[**Try it online**](https://tio.run/##VY9BTsMwEEX3c4ofuYiWRcS6AvUCZce6YkQmtdXUieypChfjAFwsjBMKrWyN9J/n/xkn0RB5HI/Lt@Xm6XnnUD@salo8zodmeEMv7AqS@Whxd//99V@o2OhWX8A4Orz6kGGXofKhdA7qoeceTWhbSRKVSr8XbiTliub2OJwUnrO9QROHLsR90R5HTocM58hxbCz0D6Ik92Zj5IHfBdyqJASt6XcJy5qqQ7bMuJcy2RVAL6dOw9AJ0bRNlLNNlFzBfrJe0dbElI8@dp/XU9fkJscO23AQqGetfgA)
*Saved 21 bytes thanks to Neil.*
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~43~~ ~~42~~ 40 bytes
*1 byte removed thanks to [Rick Hitchcock](https://codegolf.stackexchange.com/users/42260/rick-hitchcock)!*
```
`j[]y'^##?#? 'XXgn:(2M4:QP&mt~+t&Y"0YcDT
```
This outputs a trailing space in each line (allowed by the challenge), and exits with an error (allowed by default) after producing the ouput.
[**Try it online!**](https://tio.run/##jY/BSsNAEIbv@xR/OtBahCLiKZdeemxBoYcWsTg0k@zaZBOyU2IvvnrcRBGPGZaBHZjvn69iLfv@/eP17bY4Ea1pjcXhUPj07nH3lL48zyv9utf5cfZwPG/2fU/YWxcQH0PlU03n1EK7GpnLc2nFqyEiWOFM2pCY1YQyP0zfXBWWQwRAW3al88Xwt6i4vQQQGWKfxeS/IYb4Oq4xQsNnAecqLZyupgX/6sTAsRNCDPaFDA40DKZhdtdSXVOKMaO8ly7eLiEBwaTLaYxt3Bh1UPvy9l8yNTRiT9i6i0Ata/IN)
### Explanation
```
`            % Do...while loop
  j          %   Input a line as unevaluated string
  []         %   Push empty array
  y          %   Duplicate from below: push input line again
  '^##?#? '  %   Push string for regexp pattern
  XX         %   Regexp. Returns cell array with the matched substrings
  g          %   Get cell array contents: a string, possibly empty
  n          %   Length, say k. This is the title level plus 1, or 0 if no title
  :(         %   Assign the empty array to the first k entries in the input line
             %   This removing those entries from the input
  2M         %   Push k again
  4:QP       %   [1 2 3 4], add 1 , flip: pushes [5 4 3 2]
  &m         %   Push index of k in that array, or 0 if not present. This gives
             %   4 for k=2 (title level 1), 3 for k=3 (tile level 2), 2 for k=2
             %   (title level 1), and 0 for k=0 (no title). The entry 5 in the
             %   array is only used as placeholder to get the desired result.
  t~+        %   Duplicate, negate, add. This transforms 0 into 1
  t&Y"       %   Repeat each character that many times in the two dimensions
  0Yc        %   Postpend a column of char 0 (displayed as space). This is
             %   needed in case the input line was empty, as MATL doesn't
             %   display empty lines
  D          %   Display now. This is needed because the program will end with
             %   an error, and so implicit display won't apply
  T          %   True. This is used as loop condition, to make the loop infinite
             % End (implicit)
```
[Answer]
# Perl 5, 47 +1 (-p) bytes
```
s/^##?#? //;$.=6-("@+"||5);$_=s/./$&x$./ger x$.
```
[try it online](https://tio.run/##K0gtyjH9/79YP05Z2V7ZXkFf31pFz9ZMV0PJQVuppsZU01ol3rZYX09fRa1CRU8/PbVIAUj//6@sEJKRWaygrKwAJpUVikuKEvPSU7mUQRwg5vqXX1CSmZ9X/F@3AAA)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 46 bytes
```
ＦＮ«Ｓι≔⊕⌕Ｅ³…⁺×#κι⁴### θＦ⎇θ✂ι⁻⁵θＬι¹ι«Ｇ↓→↑⊕θκ→»Ｄ⎚
```
[Try it online!](https://tio.run/##TY/BTsMwDIbP7VOY9uJK4YAGl3FCTEhIFE2sPEBo3cZamnRpujKhPXtJygUpsf9Yv77fqZV0tZV6WVrrAF/NMPn3qf8ih0UBP2myTg7esemQi8c0eRpH7kxw1o56Mp4afGHTYCkH3AgorW5wr6cRK@5pxCzPBBwLARzufRFKluc5ZFGdIm/NrcgZ6S54EnDQXBNyILEJlIdoE/BGpvMKI@Ruha3LJXurL501uN3Z2QjYfnCnfOifg4D/G0bEMaYlpT0T/vni@5omu6kfMOpnTdJFdV2WTZpDpXiEcCR4@vbpzF6Bny003LbkAjiNP1EkG3LjzXJ71r8 "Charcoal – Try It Online") Link is to verbose version of code. Charcoal doesn't really do string array input, so I've had to add the array length as an input. Explanation:
```
ＦＮ«Ｓι
```
Loop over the appropriate number of input strings.
```
≔⊕⌕Ｅ³…⁺×#κι⁴### θ
```
Create an array of strings by taking the input and prefixing up to 2 #s, then truncating to length 4, then try to find `###` in the array, then convert to 1-indexing. This results in a number which is one less than the letter zoom.
```
Ｆ⎇θ✂ι⁻⁵θＬι¹ι«
```
If the letter zoom is 1 then loop over the entire string otherwise loop over the appropriate suffix (which is unreasonably hard to extract in Charcoal).
```
Ｇ↓→↑⊕θκ→
```
Draw a polygon filled with the letter ending at the top right corner, and then move right ready for the next letter.
```
»Ｄ⎚
```
Print the output and reset ready for the next input string.
[Answer]
# [SOGL V0.12](https://github.com/dzaima/SOGL), ~~31~~ 28 [bytes](https://github.com/dzaima/SOGL/blob/master/chartable.md)
```
¶Θ{■^##?#? øβlF⁄κ6κ5%:GI*∑∙P
```
[Try it Here!](https://dzaima.github.io/SOGLOnline/?code=JUI2JXUwMzk4JTdCJXUyNUEwJTVFJTIzJTIzJTNGJTIzJTNGJTIwJUY4JXUwM0IybEYldTIwNDQldTAzQkE2JXUwM0JBNSUyNSUzQUdJKiV1MjIxMSV1MjIxOVBGJTBBaW5wdXRzLnZhbHVlJXUyMDFEJXUyMTkyRg__,inputs=TXVsdGlwbGUlMEElMEElMEElMjMlMjMlMjMlMjBuZXdsaW5lcyUyMSUyMCUyMyUyMCUwQSUzQSUyOSUwQSUwQSUyMyUyMFRoaXMlMjBpcyUyMGElMjB0ZXh0JTBBd2l0aCUyMHR3byUyMGRpZmZlcmVudCUwQSUyMyUyMyUyMyUyMGhlYWRlcnMlMjElMEElMjMlMjBzaXplJTIwNCUwQSUyMyUyMyUyMHNpemUlMjAzJTBBJTIzJTIzJTIzJTIwc2l6ZSUyMDIlMEFzaXplJTIwMQ__) - extra code added because the code is a function and takes input on stack (SOGL can't take multiline input otherwise :/) - `inputs.value”` - push that string, `→` - evaluate as JS, `F` - call that function
Explanation:
```
¶Θ                            split on newlines
  {                           for each item
   ■^##?#?                      push "^##?#? "
           øβ                   replace that as regex with nothing
             l                  get the new strings length
              F⁄                get the original strings length
                κ               and subtract from the original length the new strings length
                 6κ             from 6 subtract that
                   5%           and modulo that by 5 - `6κ5%` together transforms 0;2;3;4 - the match length to 1;4;3;2 - the size
                     :          duplicate that number
                      G         and get the modified string ontop
                       I        rotate it clockwise - e.g. "hello" -> [["h"],["e"],["l"],["l"],["o"]]
                        *       multiply horizontally by one copy of the size numbers - e.g. 2: [["hh"],["ee"],["ll"],["ll"],["oo"]]
                         ∑      join that array together - "hheelllloo"
                          ∙     and multiply vertiaclly by the other copy of the size number: ["hheelllloo","hheelllloo"]
                           P    print, implicitly joining by newlines
```
[Answer]
# [Proton](https://github.com/alexander-liao/proton), 130 bytes
```
x=>for l:x.split("\n"){L=l.find(" ")print(L>3or L+len(l.lstrip("\#"))-len(l)?l:"\n".join(["".join(c*(5-L)for c:l[L+1to])]*(5-L)))}
```
[Try it online!](https://tio.run/##LU1LCsMgFNznFPKyea8hgpRuAkku4A1SV2kFy0PFuAiUnt2apgMDwzCfmEIOvtix7ONkQxI87HKL7DLC3QO99cjSOv9AEEAxOZ9RT9ca1B0/PbLkLScXa7oFov7n0czD0Zav4Dwu8BfrBW@9puNlHXjRncrBkDldok855y1C01aIygYWJXIQvTJE5Qs "Proton – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 147 bytes
```
def f(x):
	for l in x.split("\n"):L=l.find(" ");print(L>3or L+len(l.lstrip("#"))-len(l)and l or"\n".join(["".join(c*(5-L)for c in l[L+1:])]*(5-L)))
```
[Try it online!](https://tio.run/##NY27CsIwFIZn8xTxZDnH0kARl4o6CQ5B3WsHsQlGDkmJHerT19bL9vHxX9pXd49hOQyNddJhT6WYuZgkSx9kr58t@w7hEoBKs2HtfGgQJNC6TT50aLbLMWwytgFZ87NLvkVQQJR/FF1DM27FNE3oR/QBK/jBbYGr3ND0dpveuDJZUdZUfz3R4BAAxMEyR6HkwV4bm@ZCKXn/4G7EP2uthTqeznsxVqqizIuahjc "Python 3 – Try It Online")
-1 byte thanks to Mr. Xcoder
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 268 + 18 bytes
```
n=>{var r="";for(int l=0,c;l<n.Length;l++){var m=n[l];var s=m.Split(' ');var y=s[0];if(!y.All(x=>x==35)|y.Length>3|s.Length<2)r+=m+'\n';else for(int i=0,k=y.Length;i<5-k;i++){for(c=1;c<m.Length-k;)r+=new string(m.Substring(k,m.Length-k)[c++],5-k);r+='\n';}}return r;};
```
[Try it online!](https://tio.run/##lVLBbqMwED2Xr5jCISAo6m7VyxpHqirtKSut1JX2kKaS1zFgYUzWHpqglG9PDYG210jIGr2Zee/NE9ze8MaIU2ulLuCpsyjqdCX1f@JxxayF36YpDKvh6F1ZZCg5vDZyC7@Y1KFF47bWG2CmsJEb8SaCn63m2dxN4FwtIQd60nR5fGUGDPV9kjcmlBpB0duEE5XpdCV0gSVRcRyNYzXVa7UhQ2lpnT7tlMRwAYtohDpq17cbIvPwuksflAoPdHmg9O4@eusmquXdm53K7HtkYlrHi2e9IEJZAbO@dPoVnVeIzO5vKiIHD8MEp98Iz@qp6zoDjRb76a7Q2Wr/TXWVfM5Fax7Hm8RxRcRtjLJ9bwS2RoMhPTmRObDHRttGifSvkShc/CLMw08Fl/AR/AD@lNKC@xigOKCfgL@XWALuG9jKPBdG6BENggBKwbbC2Gsf@ii6SOesonctQsnsmQ/QMKmGX8RBJdTMVBaCYGwyvXWOPnAYPDVumYHdMS6A5SgMSEwvtzKd7PTHNxiaTBdiOjIYsMtZB3h0CY1W3VfvP0biOcIXWMlKAJYM5xi9q97rT@8 "C# (.NET Core) – Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 131 bytes
```
from re import*
print(sub("^(#+) (.*?)$",lambda x:((sub('(.)',r'\1'*(5-len(x[1])),x[2])+'\n')*(5-len(x[1])))[:-1],input(),flags=M))
```
[Try it online!](https://tio.run/##VY9Bi4MwFITv/opHUsh7mgrusheh9Bf01pt14XWrNVRjSCK1v9667WHZ43zDDDPuEbvRfi7GuinCDnoezhcuQQhx7EyAN@84JFJC9Gx6Y6@/uoOB/S2AlIlkewH@g3A3a@kaYwiOfxrgNjYeTMzX1qX14wC@ATO40cc0cd7YiGE6o/hGmRFgnu5pI/R7CswlvlyFOSnt1alQKX5t@8biXBU1kZ6rj5oydbKK/jtUldui1q8PSLrt@Rp2B6JleQI "Python 3 – Try It Online")
I used Python 3 in order to use `[]` with regex.
[Answer]
# PHP, 122+1 bytes
```
for($y=$z=" "==$s[$i=strspn($s=$argn,"#")]&&$i?5-$i++:1+$i=0;$y--;print"
")for($k=$i;~$c=$s[$k++];)echo str_pad($c,$z,$c);
```
Run as pipe with `-nR` (will work on one input line after another) or [try it online](http://sandbox.onlinephpfunctions.com/code/07226b470ecae8bbdbd1dde71cf416af5e858c2b).
[Answer]
# [J](http://jsoftware.com/), 55 bytes
```
([:{:@,'^##?#? 'rxmatch])((1 1 4 3 2{~[)([:|:[$"0#)}.)]
```
I don't know how to make TIO work with J regex, so I can't provide a working link.
Here's how to test it in the J interpreter (tested with J804)
```
   f=.([:{:@,'^##?#? 'rxmatch])((1 1 4 3 2{~[)([:|:[$"0#)}.)]
   txt=.'# Hello'; '## A B C def'; '### PPCG!'; '#and a hash mark without a space after it.'; '##### ###'
   ; f each txt
HHHHeeeelllllllloooo
HHHHeeeelllllllloooo
HHHHeeeelllllllloooo
HHHHeeeelllllllloooo
AAA   BBB   CCC   dddeeefff
AAA   BBB   CCC   dddeeefff
AAA   BBB   CCC   dddeeefff
PPPPCCGG!!
PPPPCCGG!!
#and a hash mark without a space after it.
##### ###
```
I simulate a multiline string through a list of boxed strings.
[Answer]
# [Python 2](https://docs.python.org/2/), ~~126~~ ~~124~~ 117 bytes
```
while 1:l=raw_input();i=l.find(' ');v=5-i*(l[:i]in'###');exec"print[l,''.join(c*v for c in l[i+1:])][v<5];"*(v>4or v)
```
[Try it online!](https://tio.run/##TY7BTsMwDIbvfgpvObQdMGmIXVrGE4wbt6qgqHUXs5BWidduT1/SghCSZcm/7f/7@5uYzj1O02jYEu5ye/B6/GDXXyTNCj7YbcuuSRNMsmI47B94k9oy54pdopSKIl2pXveenZT2Pkm2nx27tN4M2HYea2SHtuS7XV5lVTk876tivUmHl6e4HLJpUvhmOGAsjUJXgZHFoIwdNty25MkJRA4a0g35sAL4uZ/zodEhLlG8ZsvuNM8Gv7Q/B1QKlHZNdP0Tcbbu4pvG0OuaULdCHlm2AL8xotnSFYZo6k40s9UsALxerHBvCWAJ5GiMTAorVAh5BnCM04LAztnbf3AOanl5xyOfCcVoWX0D "Python 2 – Try It Online")
or
```
while 1:l=raw_input();i=l.find(' ');t=''<l[:i]in'###';exec"print[l,''.join(c*(5-i)for c in l[i+1:])][t];"*(t<1or 5-i)
```
[Try it online!](https://tio.run/##TY7BasMwDIbvegq1PjjptkIHuyTNG3S33UI2TKLUWj0n2Cppnz5zsjEGQqBf0v/9413s4J/nebLsCA@Fq4KZPtiPV8nykiu379l3mUadl1JpfXR1wQ17rZTSJd2o3Y6BvdTuUev958A@a3fZyxPn/RCwRfboan44FE3e1NKU210mx0NaLSfzrPDNcsRUBoVuAhOLRZkG7LjvKZAXSCS0ZDoKcQPwc7/kQ2tiWqIEw479eZktfplwiagUKOO75Pon4mI9pDeDcTQtoemFArLsAX5jJLO1K4zJ1J9pYatFAHi9OuHREcAayNOUmBQ3qBCKHOCUphWBg3f3/@AC1Pryjie@EIo1svkG "Python 2 – Try It Online")
[Answer]
# JavaScript, 112 bytes
```
x=>x.replace(/^(##?#?) (.*)/mg,(_,n,w)=>(t=>Array(t).fill(w.replace(/./g,c=>c.repeat(t))).join`
`)(5-n.length))
```
```
f=
x=>x.replace(/^(##?#?) (.*)/mg,(_,n,w)=>(t=>Array(t).fill(w.replace(/./g,c=>c.repeat(t))).join`
`)(5-n.length))
```
```
<textarea id=i style=display:block oninput=o.value=f(i.value)></textarea>
<output id=o style=display:block;white-space:pre></output>
```
[Answer]
# C# 4.5 158 Bytes
Where i is the input in the form of a string.
```
int l,m,t,s=0;while(i[s]=='#'){s++;};t=s>0?4-s+1:1;for(l=0;l<t;l++){foreach(char c in i.Skip(s>0?s+1:0))for(m=0;m<t;m++)Console.Write(c);Console.WriteLine();}
```
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 27 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
é!?q╚<╙≈╣íå▒{¼Φ8ôƒ¡m↨;-◘-u♥
```
[Run and debug it](https://staxlang.xyz/#p=82213f71c83cd3f7b9a186b17bace838939fad6d173b2d082d7503&i=This+input+has%0A%23%23+trailing+hash+marks+%23%23%0A%23and+a+hash+mark+without+a+space+after+it.%0A)
This was fun.
]