2 added 26 characters in body
source | link

PowerShell, 9191 86 bytes

 

-5 bytes thanks to mazzy

param($n)$x=,'X'*$n+,'_'*(8-$n)|Sort{random}|random -c 8
-join($x[0join$x[0..2]+"2]
$($x[3]+$n+$x[4])$x[3,4]-join$n
"+$x[5-join$x[5..7])

Try it online!Try it online!

Shuffles a generated string ranging from ________ to XXXXXXXX (replacing from the left). It then slices through it multiple times, inserting $n in the middle, to build the output string. This last part can probably be greatly optimized because each index costs a minimum of 5 bytes.

PowerShell, 91 bytes

 
param($n)$x=,'X'*$n+,'_'*(8-$n)|Sort{random}
-join($x[0..2]+"
$($x[3]+$n+$x[4])
"+$x[5..7])

Try it online!

Shuffles a generated string ranging from ________ to XXXXXXXX (replacing from the left). It then slices through it multiple times, inserting $n in the middle, to build the output string. This last part can probably be greatly optimized because each index costs a minimum of 5 bytes.

PowerShell, 91 86 bytes

-5 bytes thanks to mazzy

param($n)$x=,'X'*$n+,'_'*(8-$n)|random -c 8
-join$x[0..2]
$x[3,4]-join$n
-join$x[5..7]

Try it online!

Shuffles a generated string ranging from ________ to XXXXXXXX (replacing from the left). It then slices through it multiple times, inserting $n in the middle, to build the output string. This last part can probably be greatly optimized because each index costs a minimum of 5 bytes.

1
source | link

PowerShell, 91 bytes

param($n)$x=,'X'*$n+,'_'*(8-$n)|Sort{random}
-join($x[0..2]+"
$($x[3]+$n+$x[4])
"+$x[5..7])

Try it online!

Shuffles a generated string ranging from ________ to XXXXXXXX (replacing from the left). It then slices through it multiple times, inserting $n in the middle, to build the output string. This last part can probably be greatly optimized because each index costs a minimum of 5 bytes.