Sha256: a788bca68b574227c1308687d23f2163798ba1f645f7fb3e83e4c0e9a2a57608
Contents?: true
Size: 465 Bytes
Versions: 1
Compression:
Stored size: 465 Bytes
Contents
require "topchart/version" require 'set' class Topchart def chart(list1,list2) chart = [] rlist1 = list1.reverse rlist2 = list2.reverse s1 = Set.new(list1) s2 = Set.new(list2) new = s2 - s1 chart += new.map do |el| [rlist2.index(el), el] end inter = s1.intersection(s2) chart += inter.map do |el| i1 = list1.index(el) i2 = list2.index(el) [i1-i2, el] end chart.sort.reverse end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
topchart-0.0.2 | lib/topchart.rb |