Commit 614e15d
Changed files (2)
bin
spec
bin/perf.sh
@@ -12,7 +12,8 @@ gnuplot << EOF
set term png
set output "tmp/graphs/$FILENAME.png"
set datafile separator ","
- plot 'tmp/input.csv'
+ set xrange [0:100]
+ plot 'tmp/input.csv' with line
EOF
echo "tmp/graphs/$FILENAME.png"
spec/triplet_sum_spec.rb
@@ -99,9 +99,9 @@ describe "triplet sum" do
false
end
- #def triplet_sum(target, items)
- #items.combination(3).to_a.any? { |x| x.reduce(:+) == target }
- #end
+ def triplet_sum(target, items)
+ items.combination(3).to_a.any? { |x| x.reduce(:+) == target }
+ end
it do
expect(triplet_sum(15, [14, 1, 2, 3, 8, 15, 3])).to be(false)
@@ -161,10 +161,10 @@ describe "triplet sum" do
filename = "tmp/input.csv"
File.unlink(filename) if File.exist?(filename)
File.open(filename, "w") do |file|
- 500.times do |n|
+ 100.times do |n|
total = (n + 1) * 1_000
items = Array.new(total) { rand(total) }
- target = rand(100)
+ target = rand(total)
start_time = Time.now
triplet_sum(target, items)
end_time = Time.now