g | x | w | all
Bytes Lang Time Link
038Uiua250704T230815ZErikDaPa
020Vyxal250705T014732Zlyxal
090Zsh250628T095723Zroblogic
624Operation Flashpoint scripting language170914T193408ZSteadybo
025Japt R170914T153031ZShaggy
093R170914T145251ZGiuseppe
071Ruby190517T225648ZValue In
073Perl 6170916T164811Znwellnho
102Powershell181105T084232Zmazzy
050MATL170918T211821ZGiuseppe
190Haskell170914T202533Zjferard
142Python 2170914T150323ZMr. Xcod
076QBIC170915T122730Zsteenber
117JavaScript ES6170915T110638ZShaggy
107C gcc170914T152807Zcleblanc
115JavaScript ES6170915T115039ZArnauld
032Charcoal170914T162949ZNeil
126Java 8170914T153118ZRoberto
02905AB1E170914T151207ZEmigna
022Jelly170914T182514ZJonathan
095C170914T232533Zorlp
031SOGL V0.12170914T153743Zdzaima
114Python 2170914T154641Zlynn
144JavaScript ES6170914T153608ZJustin M
124PowerShell170914T151502ZAdmBorkB
033Pyth170914T152448ZJakube
081Perl 5170914T145907ZDom Hast

Uiua, 40 38 bytes

≡₀⨬@ (+@!⌊×94⚂)↘¯1/⊂↯+₁:↥⊸≡⇌⇌⊞(˜∊0⊟)∩⇡

40 bytes version:

≡₀⨬@ (+@!⌊×94⚂)↘¯1/⊂↯+₁:⍜⊣⋅1≡⍜⊃⊢⊣∩⋅1˜↯0⊂

Explanation:

Argument format: [HEIGHT] [WIDTH] [RUNG#]
≡₀⨬@ (+@!⌊×94⚂)↘¯1/⊂↯+₁:↥⊸≡⇌⇌⊞(˜∊0⊟)∩⇡ 
                             ⊞(˜∊0⊟)∩⇡ => create a HxW array of 0s, and fill in 1s for the top and left side
                        ↥⊸≡⇌⇌          => flip vertically, and horizontally flip to fill the right side also

40 bytes version:

≡₀⨬@ (+@!⌊×94⚂)↘¯1/⊂↯+₁:⍜⊣⋅1≡⍜⊃⊢⊣∩⋅1˜↯0⊂
                        ⍜⊣⋅1≡⍜⊃⊢⊣∩⋅1˜↯0⊂ => create a HxW array of 0s, and fill in 1s for the sides and the bottom
               ↘¯1/⊂↯+₁:                 => create R+1 copies of that, and remove the extra bottom
≡₀⨬@ (+@!⌊×94⚂)                          => at the truthy idxs generate a printable ASCII char, otherwise a space

Try it online!

Vyxal, 20 bytes

›*‹⟑kP⁰ƈÞẇn¹Ḋ*1↳JǓ∑,

Try it Online!

Takes N, H, W

Explained

›*‹⟑kP⁰ƈÞẇn¹Ḋ*1↳JǓ∑,­⁡​‎‎⁡⁠⁡‏⁠‎⁡⁠⁢‏⁠‎⁡⁠⁣‏‏​⁡⁠⁡‌⁢​‎‎⁡⁠⁤‏‏​⁡⁠⁡‌⁣​‎‎⁡⁠⁢⁡‏⁠‎⁡⁠⁢⁢‏⁠‎⁡⁠⁢⁣‏⁠‎⁡⁠⁢⁤‏‏​⁡⁠⁡‌⁤​‎‎⁡⁠⁣⁡‏⁠‎⁡⁠⁣⁢‏‏​⁡⁠⁡‌⁢⁡​‎‎⁡⁠⁣⁣‏⁠‎⁡⁠⁣⁤‏⁠‎⁡⁠⁤⁡‏‏​⁡⁠⁡‌⁢⁢​‎‎⁡⁠⁤⁢‏‏​⁡⁠⁡‌⁢⁣​‎‎⁡⁠⁤⁣‏⁠‎⁡⁠⁤⁤‏‏​⁡⁠⁡‌⁢⁤​‎‎⁡⁠⁢⁡⁡‏‏​⁡⁠⁡‌⁣⁡​‎‎⁡⁠⁢⁡⁢‏‏​⁡⁠⁡‌⁣⁢​‎‎⁡⁠⁢⁡⁣‏⁠‎⁡⁠⁢⁡⁤‏‏​⁡⁠⁡‌­
›*‹                   # ‎⁡H*(N+1)-1 -> the total number of lines in the output
   ⟑                  # ‎⁢For each number n in the range [1, H*(N+1)-1]:
    kP⁰ƈ              # ‎⁣  Select N random characters from the set of printable ascii characters
        Þẇ            # ‎⁤  Take the first and last characters from that list, and push them under the remaining characters (i.e. push [first, last], characters[1:-1])
          n¹Ḋ         # ‎⁢⁡  Check whether n (from the original range) is divisible by H. Because the range is 1-indexed, this will nicely align with which lines need a full row.
             *        # ‎⁢⁢  Only keep the letters in the row if this is a line where a row should be. Replace with a list of empty strings otherwise.
              1↳      # ‎⁢⁣  Turn those empty strings into single spaces.
                J     # ‎⁢⁤  And merge the modified row with the original first and last characters. The top of the stack is now [first, last, row...]
                 Ǔ    # ‎⁣⁡  Rotate that left once to put the first character on the end, bookending the row. This works because the first and last characters of a row are guaranteed to always be present.
                  ∑,  # ‎⁣⁢  Concatenate that list into a single string and print with a newline (doesn't break lazy evaluation because this is an eagerly evaluated map).
💎

Created with the help of Luminespire.

Zsh, 90 bytes

r()jot -rc $1 ! ~ -s ''
s()repeat $2-1<<<${(r:$1-1:)$(r 1)}`r 1`
repeat $3 s $@&&r $1;s $@

Try it online! 95b

W=$1, H=$2, N=$3
Function r() asks jot for a list of x random numbers in the character range. Function s() draws the 2 sides of height H-1. The main script repeatedly calls s and r to draw the sides and rungs, N times. The final call to s $@ draws the bottom legs of the ladder.

Originally I tried to use code from "Do X without Y" with complicated logic but calling jot is simpler than doing math and ASCII conversions.

Operation Flashpoint scripting language, 643 624 bytes

f={l=["""","!","#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~"];t=_this;w=t select 0;r={l select random 92};v="";s=v;i=2;while{i<w}do{i=i+1;v=v+" "};p={i=1;while{i<t select 1}do{i=i+1;s=s+call r+v+call r+"\n"}};k=0;call p;while{k<t select 2}do{k=k+1;i=0;while{i<w}do{i=i+1;s=s+call r};s=s+"\n";call p};s}

Ridiculously long because there is no way to create the characters from the character codes.

Call with:

hint ([5, 3, 2] call f)

Output:

The ladder is extra chaotic because the font is not monospaced.

Unrolled:

f =
{
    l = ["""","!","#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3","4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~"];

    t = _this;
    w = t select 0;

    r =
    {
        l select random 92
    };

    v = "";
    s = v;

    i = 2;
    while {i < w} do 
    {
        i = i + 1;
        v = v + " "
    };

    p =
    {
        i = 1;
        while {i < t select 1} do 
        {
            i = i + 1;
            s = s + call r + v + call r + "\n"
        }
    };

    k = 0;
    call p;
    while {k < t select 2} do 
    {
        k = k + 1;

        i = 0;
        while {i < w} do
        {
            i = i + 1;
            s = s + call r
        };
        s = s + "\n";

        call p
    };

    s
}

Japt -R, 42 41 40 37 34 28 25 bytes

Takes input in the order H,W,N.

;*°WÉ ÆJ²ùVXgJùU¹r,@EÅöÃé

Try it

R, 138 129 111 98 93 bytes

-13 bytes thanks to Neal Fultz!

-1 byte thanks to Robin Ryder

function(W,H,N){m=matrix(intToUtf8(32+sample(94,W*(h=H*N+H-1),T),T),h)
m[-H*1:N,3:W-1]=" "
m}

Try it online!

Anonymous function; returns the result as a matrix.

Thanks to that Word Grids question, I've been thinking about matrices a lot more than usual. I observed that the rungs are in those matrix rows that are a multiple of the step height H (R is 1-indexed), and that the rails are the first and last columns, 1 and W. So I create a matrix of random ASCII characters, and replace those letters that didn't match those criteria with spaces, and return the matrix. TIO link prints it out nicely.

Neal Fultz suggested a different indexing for the space characters, [-H*(1:N),3:W-1], which replaces all characters except for those in rows of multiples of H: -H*(1:N) and not on the edge, 3:W-1 <==> 2:(W-1).

R, 121 bytes

function(W,H,N)for(i in 1:(H*N+H-1)){for(j in 1:W)cat("if"(!(i%%H&j-1&j-W),sample(intToUtf8(33:126,T),1)," "))
cat("\n")}

Try it online!

An improvement over the original matrix-based approach I started with; it's the same algorithm but for loops are shorter than constructing and printing a matrix (but not if I don't print it!)

Ruby, 71 bytes

EDIT: Oops I thought this was a new challenge because of the recent edit to fix a typo lol. I'm still leaving this up though because there's no Ruby answer for it yet.

->w,h,n{(1..h*-~n-1).map{|i|[*?!..?~].sample(x=i%h>0?2:w)*(' '*(w-x))}}

Try it online!

Perl 6, 76 73 bytes

->\h,\n,\w{map {chrs (roll(w,1..94)Z*1,|($_%%h xx w-2),1)X+32},1..^h*n+h}

Try it online!

Takes (h, n, w) as arguments. Returns a list of strings.

Explanation:

-> \h, \n, \w {  # Block taking arguments h, n, w
    map {
        # String from codepoints
        chrs
             # Generate w random numbers between 1 and 94
             (roll(w, 1..94)
              # Set inner numbers on non-rungs to zero
              Z* 1, |($_%%h xx w-2), 1)
             # Add 32 to numbers
             X+ 32
    }
    # Map h*n+h-1 row numbers (1-indexed)
    1..^h*n+h
}

Powershell, 102 bytes

param($w,$h,$n)1..(++$n*$h-1)|%{$l=$_%$h
-join(1..$w|%{[char](32,(33..126|Random))[!$l-or$_-in1,$w]})}

Less golfed test script:

$f = {

param($w,$h,$n)
1..(++$n*$h-1)|%{       # for each lines of the ladder
    $l=$_%$h            # line number in a step
    -join(1..$w|%{      # make a line
        [char](32,(33..126|Random))[!$l-or$_-in1,$w]
    })                  # a random character if the line number in a step is a rung line or char position is 1 or width
                        # otherwise a space
}

}

&$f 5 3 2
&$f 3 2 2
&$f 12 4 5
&$f 20 5 3

Output:

0   {
H   S
']UxR
G   ]
3   t
q^R8O
q   y
t   J
U h
YQZ
_ i
3#D
I #
=          m
&          <
]          6
8nmuyw2'Y7%+
o          l
;          !
D          M
Fn[zGfT";RYt
@          B
$          e
z          @
@J[1|:-IS~y<
(          L
:          [
|          q
zBow0T0FnY8)
/          *
e          B
R          p
9{d2(RacBdRj
u          ~
`          l
J          h
v                  t
T                  -
v                  H
'                  Y
IS7{bx2&k@u7]o}>[Vq?
F                  U
?                  U
|                  Q
}                  T
:wv1wEfc6cS;430sigF|
<                  L
:                  }
*                  `
H                  =
L8k5Q/DQ=0XIUujK|c6|
j                  =
!                  p
V                  :
#                  w

MATL, 63 50 bytes

-13 bytes thanks to Luis Mendo

Q*qXJ*6Y2HY)wT3$ZrJ3G3$eJ3G&Ol5LZ(J:HG\~3GTX"!+g*c

Try it online!

I'm still new to golfing in MATL (and I'm not super good at MATLAB for that matter), so I know this probably isn't close to optimal. Tips are welcome. Takes input in order N,H,W.

Here we go:

Q*qXJ                     # compute H*(N+1)-1, store as J
     *                    # multiply by W
      6Y2HY)              # push printable ASCII
            wT3$Zr        # sample uniformly with replacement
                  J3G3$e  # reshape to make a matrix of the appropriate shape.

We now have a matrix of random char.

J3G                       # push J,W
   &O                     # zero matrix, J x W
     l5LZ(                # assign 1 to first and last columns

Now there's also a logical matrix for the rails.

J:                        # push J, range, so 1...J
  HG                      # take second input (H)
    \~                    # mod and bool negate (so it's 1 for rows of multiples of H)
      3GTX"!              # repmat and transpose so we have 1's for rungs

Now we have 3 matrices on the stack:

So we do the following:

+                         # add the top two matrices.
 g                        # convert to logical so 0->0, nonzero->1
   *                      # elementwise multiply
    c                     # convert to char, implicit output (0 -> space).

Haskell, 226 220 211 190 bytes

import System.Random
a=mapM id
b=(putStr.unlines=<<).a
c=randomRIO('!','~')
r w=a$c<$[1..w]
s w=a$c:(return ' '<$[3..w])++[c]
(w#h)0=b$s w<$[2..h]
(w#h)n=do{b$(s w<$[2..h])++[r w];(w#h)$n-1}

Try it online!

Saved 9 bytes thanks to Laikoni

Saved 21 bytes thanks to wchargin

Should be golfable (b$(s w)<$[2..h] and b$((s w)<$[2..h])++[r w]). I don't feel comfortable with IO and golfing.

Python 2, 142 bytes

lambda w,h,n,e=lambda:chr(randint(33,126)):[e()+[eval(("e()+"*(w-2))[:-1])," "*(w-2)][-~i%h>0]+e()for i in range(h*-~n-1)]
from random import*

Try it online!

Saved bytes thanks to ovs!

QBIC, 76 bytes

[:*:+b-1|G=chr$(_r33,126|)~a%b\[:-2|G=G+@ `]][e|G=G+chr$(_r33,126|)]?_sG,1,e

Explanation

[                       FOR a = 1 TO
 :                         input 1 (Height, now in var b)
  *                        times
   :                       input 2 (# of rungs, now in var c)
    +b-1|                  plus one bottom rung without crossbar
G=chr$(_r33,126|)       Assign to G a random char (_r is the RAND() function, chr$() is BASIC's num-to-char)
~a%b|                   IF we are not at a crossbar (the modulo returns anything but 0), 
  [:-2|G=G+@ `            add to G x spaces, where x is width (input 3, now 'e') - 2
                        Note that G is now either 'X' or 'X   '  (for rnd char X and W=5)
]]                      Close the spacing FOR, close the IF 
[e|                     FOR f = 1 to width
  G=G+chr$(_r33,126|)]     Append to G a rnd char
                        G is now either 'XXXXXX'  or 'X   XXXXX' (for rnd char X and W=5)
?_sG,1,e                PRINT the first w characters of G, and on to the next line

Sample run

Command line: 3 2 5
N   F
M   `
Bj#=y
!   (
S   N
q(.Ho
%   7
g   ,

JavaScript (ES6), 129 117 bytes

Unfortunately, while I was in the process of golfing this down, Arnauld beat me to a similar but shorter solution. By combining our 2 solutions, this can be 113 bytes

Includes a trailing newline.

(w,h,n)=>(g=c=>l?(c++<w?c%w>1&&l%h?` `:String.fromCharCode(94*Math.random()+33|0):`
`)+g(c>w?!--l:c):``)(0,l=h*++n-1)

Try it

o.innerText=(f=
(w,h,n)=>(g=c=>l?(c++<w?c%w>1&&l%h?` `:String.fromCharCode(94*Math.random()+33|0):`
`)+g(c>w?!--l:c):``)(0,l=h*++n-1)
)(i.value=5,j.value=3,k.value=2);oninput=_=>o.innerText=f(+i.value,+j.value,+k.value)
label,input{font-family:sans-serif;font-size:14px;height:20px;line-height:20px;vertical-align:middle}input{margin:0 5px 0 0;padding:0 0 0 5px;width:100px;}
<label for=i>W: </label><input id=i min=3 type=number><label for=j>H: </label><input id=j min=2 type=number><label for=k>N: </label><input id=k min=2 type=number><pre id=o>

C (gcc), 141 131 114 109 107 bytes

Should be able to golf this down quite a bit...

i,j,c;f(w,h,n){for(i=1;i<h*n+h;i+=j==w)printf(i%h?i++,j=0,"%c%*c\n":"%c",++j^w?c^8:10,w-2,c=33+rand()%94);}

Try it online!

JavaScript (ES6), 117 115 bytes

A recursive function building the output character by character.

"Look Ma, no literal line-feed!"

(w,h,n)=>(g=x=>y<h*n+h-1?String.fromCharCode(x++<w?x%w>1&&-~y%h?32:Math.random()*94+33|0:10)+g(x>w?!++y:x):'')(y=0)

Demo

let f =

(w,h,n)=>(g=x=>y<h*n+h-1?String.fromCharCode(x++<w?x%w>1&&-~y%h?32:Math.random()*94+33|0:10)+g(x>w?!++y:x):'')(y=0)

O.innerText = f(5,3,4)
<pre id=O></pre>

Charcoal, 34 32 bytes

E…¹×⁺¹NN⪫EIζ⎇∧﹪ιIη﹪λ⁻Iζ¹ §⮌γ‽⁹⁴ω

Try it online! Takes input in the order N, H, W. Verbose approximation (Plus(InputNumber(), 1) is currently broken on TIO). Explanation:

E…¹×⁺¹NN

Map over the range 1..H*(N+1). This means that the rungs appear when i is a multiple of H.

Join the result of:

EIζ

mapping over the implicit range 0..W:

⎇∧﹪ιIη﹪λ⁻Iζ¹ 

if the column is not 0 or W-1 and the row is not a multiple of H then output a space;

§⮌γ‽⁹⁴

otherwise, take the predefined ASCII character variable, reverse it (putting the space in 94th place), and print a random character from what is now the first 94. (Because Slice sucks.)

ω

Join using the empty string. Final result is implicitly printed.

Java 8, 203 188 168 133 132 130 128 126 bytes

W->H->N->{for(double i=0,j,q;++i<H*N+H;)for(j=W,q=10;j-->=0;q=i%H*j<1|j>W-2?33+Math.random()*94:32)System.out.print((char)q);}

Try it online!

05AB1E, 29 bytes

Input taken in the order N, H, W

>*GNUžQ¦©.RIÍFð®.R«X²Öè}®.RJ,

Try it online!

Explanation

>*G                              # for N in [1 ... (N+1)*H)-1] do:
   NU                            # store N in variable X
     žQ                          # push a string of printable ascii
       ¦©                        # remove the first (space) and save a copy in register
         .R                      # pick a random character
           IÍF                   # W-2 times do:
              ð                  # push a space
               ®.R               # push a random ascii character
                  «              # concatenate
                   X²Ö           # push X % H == 0
                      è          # index into the string of <space><random_char> with this
                       }         # end inner loop
                        ®.R      # push a random ascii character
                           J,    # join everything to a string and print

Jelly,  24 23  22 bytes

«þỊoU$ẋ⁵‘¤Ḋ×94X€€+32ỌY

A full program taking the three arguments W, H, N and printing the result.

Try it online!

How?

Builds a 2d array mask of a single rung and its vertical sections below, repeats it N+1times and removes the top rung then places random characters or spaces depending upon the mask value.

«þỊoU$ẋ⁵‘¤Ḋ×94X€€+32ỌY - Main link: W, H (N is third input / 5th command line argument)
 þ                     - outer product (build a table using):
«                      -  minimum
                       -  ...note: þ implicitly builds ranges of W and H prior
  Ị                    - insignificant? (abs(z)<=1) - yields a W by H 2-d array,
                       -   all zeros except the left and top edges which are 1s
     $                 - last two links as a monad:
    U                  -   upend (reverse each row)
   o                   -   or (vectorises) - giving us our |‾| shape of 1s
         ¤             - nilad followed by link(s) as a nilad:
       ⁵               -   5th command line argument, N
        ‘              -   increment -> N+1
      ẋ                - repeat list - giving us our ladder-mask plus a top rung)
          Ḋ            - dequeue - remove the top rung
            94         - literal ninety-four
           ×           - multiply (vectorises) - replace the 1s with 94s
              X€€      - random for €ach for €ach - 0 -> 0; 94 -> random integer in [1,94]
                  32   - literal thirty-two
                 +     - add (vectorises) - 0 -> 32; random integers now from [33,126]
                    Ọ  - character from ordinal (vectorises)
                     Y - join with newlines
                       - implicit print

C, 95 bytes

f(w,h,n,i){++w;for(i=0;i++<w*~(h*~n);)putchar(i%w?~-i%w%(w-2)*((i/w+1)%h)?32:33+rand()%94:10);}

SOGL V0.12, 32 31 bytes

 ~ΔkψR
I{e{R}¶bH{Re⁾⌡@R¶}}¹∑e⌡k

Try it Here!

Input in the order N, W, H.

Explanation:

 ~ΔkψR

     R  a function named "R", pushes a random character:
 ~       push "~"
  Δ      get the charasters from " " to "~"
   k     remove the 1st character
    ψ    choose a random character from that

I{e{R}¶bH{Re⁾⌡@R¶}}¹∑e⌡k  main program

I                         increase the 1st input - N
 {                }       N times do
  e                         push the variable e, which is here initialised to the next input - W
   { }                      E times do
    R                         execute R
      ¶                     push a newline
       bH                   push b-1, where b is initialised to the next input - H
         {       }          B-1 times do
          R                   execute R
           e⁾                 push e-2 aka width-2
             ⌡@               push that many spaces
               R              execute R
                ¶             push a newline
                   ¹∑     join the stack together
                     e⌡k  remove the first width characters

18 bytes without the random characters :/

Python 2, 114 bytes

lambda w,h,n:[[chr(32+randint(1,94)*(x%~-w*(y%h)<1))for x in range(w)]for y in range(1,h*-~n)]
from random import*

Try it online!

JavaScript (ES6), 144 bytes

(w,h,n)=>Array(n+1).fill(("#".padEnd(w-1)+`#
`).repeat(h-1)).join("#".repeat(w)+`
`).replace(/#/g,_=>String.fromCharCode(33+Math.random()*94|0))

Creates the ladder out of # characters then replaces each one with a random ASCII char.

Test Snippet

let f=
(w,h,n)=>Array(n+1).fill(("#".padEnd(w-1)+`#
`).repeat(h-1)).join("#".repeat(w)+`
`).replace(/#/g,_=>String.fromCharCode(33+Math.random()*94|0))

;(W.oninput=H.oninput=N.oninput=B.onclick=_=>{let vals=[W.value,H.value,N.value].map(eval);D.innerText=vals.join`, `;O.innerText=f(...vals);})()
W: <input id=W type=range min=3 max=25 value=12><br>
H: <input id=H type=range min=2 max=25 value=5><br>
N: <input id=N type=range min=2 max=10 value=2><br>
<button id=B>Rerun</button> <code id=D></code>
<pre id=O></pre>

PowerShell, 132 124 bytes

param($w,$h,$n)-join([char[]]((($a=('#'+' '*($w-2)+"#`n")*--$h)+'#'*$w+"`n")*$n+$a)|%{($_,[char](33..126|Random))[$_-eq35]})

Try it online!

We construct a ladder composed of only # first (example), then loop |%{...} through each character and if it's -equal to 35, we pull out a new Random character from the appropriate range. Otherwise we output (i.e., either a space or newline).

Pyth, 33 bytes

VhEjtW!Nmsm?&d}kr1tQ\ Or\!C127Qvz

Try it online: Demonstration

Perl 5, 81 bytes

80 bytes code + 1 for -p.

/ \d+ /;$_=(($}=(_.$"x($`-2)._.$/)x($&-1))._ x$`.$/)x$'.$};s/_/chr 33+rand 94/ge

Try it online!