Hi Peter! > Whenever the question of performance comes up with scripting > languages > such as Ruby, Perl or Python there will be people whose > response can be > summarised as "Write it in C". I am one such person. Some people take > offence at this and label us trolls or heretics of the true > programming > language (take your pick). The last (and only) time I called someone a troll for saying 'Write it C' it was in response to a rails related question. Further the OP asked for configuration items and such, but maybe that's a whole other storry. (and of course you can write C Extensions for rails... yeah, yadda, yadda :) ) ...snip 52 lines Perl, some hundred lines C ... > [Latin]$ time ./Latin1.pl 5 > x5 > > real 473m45.370s > user 248m59.752s > sys 2m54.598s > > [Latin]$ time ./Latin4.pl 5 > x5 > > real 12m51.178s > user 12m14.066s > sys 0m7.101s > > [Latin]$ time ./c_version.sh 5 > > real 0m5.519s > user 0m4.585s > sys 0m0.691s Just to show the beauty of ruby: ----------------------------------------------------------- require 'rubygems' require 'permutation' require 'set' $size = (ARGV.shift || 5).to_i $perms = Permutation.new($size).map{|p| p.value} $out = $perms.map{|p| p.map{|v| v+1}.join} $filter = $perms.map do |p| s = SortedSet.new $perms.each_with_index do |o, i| o.each_with_index {|v, j| s.add(i) if p[j] == v} end && s.to_a end $latins = [] def search lines, possibs return $latins << lines if lines.size == $size possibs.each do |p| search lines + [p], (possibs - $filter[p]).subtract(lines.last.to_i..p) end end search [], SortedSet[*(0...$perms.size)] $latins.each do |latin| $perms.each do |perm| perm.each{|p| puts $out[latin[p]]} puts end end ----------------------------------------------------------- (does someone has a nicer/even faster version?) would you please run that on your machine? perhaps you have to do a "gem install permutation" (no I don't think it's faster than your C code, but it should beat the perl version) > If you really really want that performance boost then take > the following > advice very seriously - "Write it in C". Agreed, 100%, for those who want speed, speed and nothing else there is hardly a better way. thanks Simon