T
C
code posted
created at 29 Sep 14:54
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 38 39 40 41 |
def repS(word,n) return false if n==nil x=rand(3) word[n..n]="aS" if x==0 word[n..n]="bD" if x==1 word[n..n]="fR" if x==2 return true end def repD(word,n) return false if n==nil x=n<4 ? rand(2) : rand(5) word[n..n]="cD" if x==0 word[n..n]="d" if (x>1) word[n..n]="fR" if x==1 return true end def repR(word,n) return false if n==nil x=n<4 ? 0 : rand(3) word[n..n]="f" if (x>0) word[n..n]="bR" if x==0 return true end def noCaps(word) return true if word.match(/\p{Upper}/)!=nil return false end 5.times { |i| word="S" print "#{word}->" while ( word.length<5 || noCaps(word) ) do print repS(word,(word.index('S')!=nil ? word.length-1 : nil)) ? "#{word}->" : "" print repR(word,(word.index('R')!=nil ? word.length-1 : nil)) ? "#{word}->" : "" print repD(word,(word.index('D')!=nil ? word.length-1 : nil)) ? "#{word}->" : "" end puts } |
932 Bytes in 3 ms with coderay