dansefil = File.open("dans.txt")

dansearray = Array.new

resultatarray = Array.new

dansefil.each do |line|

  dansind = Array.new
  dansheltal = Array.new
  dansheltal1 = Array.new
  dansind = line.chomp.split(",")


  for i in 0..7
    dansheltal[i] = dansind[i].to_i
    dansheltal1[i] = dansind[i].to_i
  end

dansearray << dansheltal1

dansheltal.sort!

### FINDING M ###

m = dansheltal[3]

counter = 1
if dansheltal[4] == m
  counter += 1
end

if dansheltal[5] == m
  counter += 1
end

if dansheltal[6] == m
  counter += 1
end

s = dansheltal[0]+dansheltal[1]+dansheltal[2]+dansheltal[3]*counter


### FINDING  N ###

taeller = 0
if dansheltal[0] <= m
  taeller += 1
end

if dansheltal[1] <= m
  taeller += 1
end

if dansheltal[2] <= m
  taeller += 1
end

if dansheltal[3] == m
end

n = taeller += counter


resultat = Array.new

### Couple Number ###
resultat[0] = dansheltal[7]

### Results ###
resultat[1] = m
resultat[2] = n
resultat[3] = s

resultatarray << resultat

end

dansearray.each do |x|
  puts x.inspect
end

resultatarray.sort!{|a,b| a[1] <=> b[1]}

resultatarray.each_with_index do |b,a|

puts "Couple number:#{resultatarray[a][0]}\tMajority:
#{resultatarray[a][1]}\tJudge Majority: #{resultatarray[a][2]}\tTotal
Majority: #{resultatarray[a][3]}"

end

-- 
Posted via http://www.ruby-forum.com/.