Anonymous Anonymous - 8 days ago
91 0

No description

Ruby

Ruby: possible ways of splitting a string into n substrings

require 'fruity'
str = 'abcd'

compare do
#  sagar    { s = str.dup; combi(s).map {|st| st.join ' '} }
  navid    { s = str.dup; breakdown4(s)}
  tom      { s = str.dup; breakdown(s).sort }
  stefan_1 { s = str.dup; stefan1(s)  }
  stefan_2 { s = str.dup; stefan2(s)  }
  stefan_3 { s = str.dup; stefan3(s)  }  

end

#Running each test 64 times. Test will take about 1 second.
#navid is similar to tom
#tom is similar to stefan_1
#stefan_1 is similar to stefan_2
#stefan_2 is faster than stefan_3 by 2x ± 0.1