RosettaCodeData/Task/Dinesmans-multiple-dwelling.../Ruby/dinesmans-multiple-dwelling...

12 lines
255 B
Ruby

N = %w(Baker Cooper Fletcher Miller Smith)
b,c,f,m,s = N
N.permutation.map{|a| a.join " "}.
grep(/(?=.*#{b}.)
(?=.+#{c})
(?=.+#{f}.)
(?=.*#{c}.*#{m})
(?=.*(#{f}..+#{s}|#{s}..+#{f}))
(?=.*(#{f}..+#{c}|#{c}..+#{f}))/x).
first