This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def ranks | |
rank = self.sort.reverse | |
self.map {|n| rank.index(n) + 1 } | |
end | |
end | |
describe Array do | |
describe '#ranks' do | |
it { [100, 80, 90, 90, 90, 70, 70, 80].ranks.should == [1, 5, 2, 2, 2, 7, 7, 5] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 集合地プログラミングお勉強用コード | |
# テスト用データセット生成 | |
# k0h3yさんが分身して映画をレビューするお | |
# データセットの値が毎回変わるし、検算するの面倒 | |
#dataset = Hash.new | |
#["Kohey", "K0h3y", "Mr. Kohey", "St. Kohey", "Dr. Kohey"].each do |name| | |
# dataset.store(name, Hash.new) | |
# ["STAR WARS", "The Matrix", "The Shawshank Redemptation", "Before Sunrise", "The Notebook"].each do |tittle| | |
# dataset[name].store(tittle, rand(6).to_f) |