5 credit
source | link

Ruby, 112 107 101 99

Input is stdin, newline-seperated strings.

QPaysTaxes helped a lot with golfing it down!

M={}
while gets
k=''
$_.each_char{|c|M[k]||=[];M[k]<<c;k=c}
end
k=''
print k=M[k].sample while M[k]

Ruby, 112 107 101 99

Input is stdin, newline-seperated strings.

M={}
while gets
k=''
$_.each_char{|c|M[k]||=[];M[k]<<c;k=c}
end
k=''
print k=M[k].sample while M[k]

Ruby, 112 107 101 99

Input is stdin, newline-seperated strings.

QPaysTaxes helped a lot with golfing it down!

M={}
while gets
k=''
$_.each_char{|c|M[k]||=[];M[k]<<c;k=c}
end
k=''
print k=M[k].sample while M[k]
4 further improvements
source | link

Ruby, 112 107 101101 99

Input is stdin, newline-seperated strings.

M={}
while gets
k=''
$_.each_char{|c|M[k]=[c]+(M[k]||[]);k=c|c|M[k]||=[];M[k]<<c;k=c}
end
k=''
print k=M[k].sample while M[k]

Ruby, 112 107 101

Input is stdin, newline-seperated strings.

M={}
while gets
k=''
$_.each_char{|c|M[k]=[c]+(M[k]||[]);k=c}
end
k=''
print k=M[k].sample while M[k]

Ruby, 112 107 101 99

Input is stdin, newline-seperated strings.

M={}
while gets
k=''
$_.each_char{|c|M[k]||=[];M[k]<<c;k=c}
end
k=''
print k=M[k].sample while M[k]
3 improved code
source | link

Ruby, 112 107107 101

Input is stdin, newline-seperated strings.

M={}
while s=getsgets
k=''
s$_.each_char{|c|
M[k]=[c]+|c|M[k]=[c]+(M[k]?M[k]:[]M[k]||[])
k=c;k=c}
end
k=''
print k=M[k].sample while M[k]

Ruby, 112 107

Input is stdin, newline-seperated strings.

M={}
while s=gets
k=''
s.each_char{|c|
M[k]=[c]+(M[k]?M[k]:[])
k=c}
end
k=''
print k=M[k].sample while M[k]

Ruby, 112 107 101

Input is stdin, newline-seperated strings.

M={}
while gets
k=''
$_.each_char{|c|M[k]=[c]+(M[k]||[]);k=c}
end
k=''
print k=M[k].sample while M[k]
2 bracket notation
source | link
1
source | link