From: Paul Smith Date: 2009-11-14T00:43:21+09:00 Subject: Re: just for fun: oneline code for 4 language permutation On Fri, Nov 13, 2009 at 3:31 PM, Haoqi Haoqi wrote: > hello,happy weekday! > in ruby1.9: > irb:> > %w{ruby c java php}.permutation.to_a > > and my code is(all ruby): > irb:> > (1..1000).inject([]){|p,_|p<<%w{ruby c java php}.sort_by{rand}}.uniq .shuffle! is shorter than .sort_by{rand} by 5 characters. I hate that your method is nondeterministic, but I've got it spinning in a while loop and having broken it yet... > > how about you? > -- > Posted via http://www.ruby-forum.com/. > > -- Paul Smith http://www.nomadicfun.co.uk paul@pollyandpaul.co.uk