# Factory workers

## R, 92 89 bytes

cat(t(cbind("|",apply("[<-"(matrix(runif(100)<1/scan(),10),1,,0),2,cummax),"|
")),sep="")


Try it online!

Ungolfed:

m <- matrix(runif(100)<1/n,10,10)   #10x10 matrix of TRUE with probability 1/n
#and FALSE with probability 1-1/n
m[1,] <- 0                          #set first row to 0
m <- apply(m,2,cummax)              #take the column cumulative maxima
m <- cbind("|",m,"|\n")             #put "|" as the first and last columns
m <- t(m)                           #transpose m for the write function
cat(m,sep="")                       #print m to stdout, separated by ""


## Japt -R, 22212019 18 bytes

AÆP=®|!UöÃªAçTÃû|C


Try it

### Explanation

AÆP=®|!UöÃªAçTÃû|C     :Implicit input of integer U
A                      :10
Æ                     :Map the range [0,A)
P=                   :  Assign to P (initially the empty string)
®                  :    Map P
|                 :      Bitwise OR with
!                :      The negation of
Uö              :      A random integer in the range [0,U)
Ã             :    End Map
ª            :    OR, for the first element when the above will still be an empty string (falsey)
Aç          :    Ten times repeat
T         :      Zero
Ã        :End Map
û|      :Centre pad each element with "|"
C     :  To length 12
:Implicitly join with newlines and output


n=>[...s=2e9+''].map(j=>|${s=s.replace(/./g,i=>i&1|Math.random()*n<!+j)}|).join   Try it online! ## Recursive version, 88 bytes n=>(g=k=>k?|${s=s.replace(/./g,i=>i%5|Math.random()*n<(s!=k))}|
+g(k>>3):'')(s=5e9+'')


Try it online!

### How?

At each iteration:

• We coerce each character i of s to a number, compute i modulo 5 -- so that the leading 5 is treated like a 0 -- and randomly perform a bitwise OR with 1 with the expected probability 1/n, except on the first iteration.

• The counter k is right-shifted by 3 bits. We stop the recursion as soon as k = 0, which gives 10 iterations.

It is important to note that 5000000000 is slightly larger than a 32-bit integer, so it is implicitly converted to 5000000000 & 0xFFFFFFFF = 705032704 just before the first bitwise shift occurs. Hence the following steps:

 step | k
------+-----------
0  | 705032704
1  | 88129088
2  | 11016136
3  | 1377017
4  | 172127
5  | 21515
6  | 2689
7  | 336
8  | 42
9  | 5
10  | 0