Skip to content
Browse files

added max percents stub

  • Loading branch information...
1 parent e7349b0 commit ae6a3d1603e4a04e6481d7e0d429c85c75dd544d Jakub Kuźma committed Sep 14, 2010
Showing with 27 additions and 3 deletions.
  1. +15 −1 lib/bridge/points/duplicate.rb
  2. +12 −2 test/test_duplicate.rb
View
16 lib/bridge/points/duplicate.rb
@@ -7,9 +7,23 @@ def initialize(*scores)
def max
@scores.inject({}) do |result, score|
result.tap do |r|
- r[score] ||= @scores.inject(-1) { |partial, s| partial += (score <=> s) + 1 }
+ r[score] ||= @scores.inject(-1) { |points, s| points += (score <=> s) + 1 }
end
end
end
+
+ # def max_percents
+ # max.tap do |result|
+ # result.each do |score, points|
+ # result[score] = points * 100.0 / theoretical_max
+ # end
+ # end
+ # end
+
+ # protected
+
+ # def theoretical_max
+ # (@scores.size - 1) * 2
+ # end
end
end
View
14 test/test_duplicate.rb
@@ -22,7 +22,17 @@ class TestDuplicate < Test::Unit::TestCase
test "maximum points with non-unique values, without zero value" do
max = Bridge::Points::Duplicate.new(430, 420, 420, 420, 300, 300).max
assert_equal 10, max[430]
- assert_equal 6, max[420]
- assert_equal 1, max[300]
+ assert_equal 6, max[420]
+ assert_equal 1, max[300]
end
+
+ # test "maximum percents" do
+ # max_percents = Bridge::Points::Duplicate.new(50, 400, 110, 100, 110, 120, 50, 120, 140, 420, 110, 110, 110, 110, 50, 110, 140, 110).max_percents
+ # notify max_percents.inspect
+ # end
+
+ # test "maximum percents 2" do
+ # max_percents = Bridge::Points::Duplicate.new(-500, -650, -170, -170, -620, -620, -620).max_percents
+ # notify max_percents.inspect
+ # end
end

0 comments on commit ae6a3d1

Please sign in to comment.
Something went wrong with that request. Please try again.