First
Ruby
code posted
created at 06 Oct 19:19
Edit
|
Back
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
Vn="S,B,L".scan(/\b/).size/2 MinLength=Vn+2 quan=0 A=["","","","","",""] until quan>4 do z="S" while z=~/['S']/ z=z.gsub(/[S]/,'aB') while z=~/['B']/ x=rand if x<0.5 z=z.gsub(/[B]/,'bB') else z=z.gsub(/[B]/,'cL') end end while z=~/['L']/ x=rand if x<0.33 z=z.gsub(/[L]/,'cL') elsif x<=0.66 && x>=0.33 z=z.gsub(/[L]/,'aS') elsif x>0.66 z=z.gsub(/[L]/,'b') end end end if z.length>=MinLength && 9>z.length && A.index(z)==nil puts z A[quan]=z quan+=1; end end |
602 Bytes in 3 ms with coderay