include random.fs
: f 1+ swap do i 8 mod if i . else i 0 <# #s #> 0 do 83 random 33 + dup 47 > 10 * - emit loop ." "then loop ;
Try it online!
###Explanation
Loop from start to end, print number if not multiple of 8, otherwise get the number of digits in the number and print that many random characters followed by a space
###Code Explanation
include random.fs \ include/import the random module
: f \ start new word definition
1+ swap \ add 1 to end number, because forth loops are [start, end), and swap order
do \ start counted loop form start to end
i 8 mod \ get the remainder of dividing i (loop index) by 8
if \ if true (not 0, therefore not multiple of 8)
i . \ print the index
else \ otherwise
i 0 \ convert index to double-length number
<# #s #> \ use formatted numeric output to convert number to a string
0 do \ loop from 0 to (string-length - 1)
84 random \ get random number between 0 and 83
33 + \ add 33
dup 47 > \ check if result is larger than 47
10 * - \ if it is add 10 to result (results in number in range: 33-47,58-126)
emit \ output ascii char corresponding with number
loop \ end inner loop
." "then \ output a space and then close the if/else
loop \ end the outer loop
; \ end the word definition
UnGolfed
I don't usually ungolf my solutions, but this one is long/complicated enough that I think it's needed
include random.fs
\ get the length (in digits) of a number
: num-length 0 <# #s #> nip ;
\ check if a number is a multiple of another
: is-multiple mod 0= ;
\ get a random printable non-digit ascii char
: random-char 84 random 33 + dup 47 > 10 * - ;
\ get a "random" string of printable ascii chars the same length as a number
: rand-str num-length 0 do random-char emit loop space ;
\ print numbers from a to b, replacing multiple of 8 with a random ascii string of the same length
: crazy-eights 1+ swap do i 8 is-multiple if i rand-str else i . then loop ;