modArr = Array.new
freq = Array.new([ [0] ])
values = Array.new([ [] ])
#--------------Open the output file and process each line-----
File.open('output.txt', 'r').each { |x|
#-------------Create unique keys according to |x|---------------
#--Calculate the modulus ([add each digit]%10) and use it as hash
key--
key = 0; modF = x.each_byte { |y| key += y.chr.to_i }
#--For slight optimization, change the resulting key into a symbol
mod = (key%100).to_s.intern
if(!modArr.include?(mod))
#--Add the value
values[modArr.size].push(x.chomp)
#--Add the frequency
freq[modArr.size].push(1)
#--Add the mod
modArr.push(mod)
end
}
BLANK.rb:22: undefined method `push' for nil:NilClass (NoMethodError)
from BLANK.rb:7:in `each'
from BLANK.rb:7
??
--
Posted via http://www.ruby-forum.com/.