Implement the logic to generate the average and print it

Signed-off-by: 's avatarHenrique Varella Ehrenfried <hve13@inf.ufpr.br>
parent 0877bb36
......@@ -42,7 +42,7 @@ while i < limit do
i+=1
end
# This loop return the alive mutants based in the lines of the file passed as ARGV[0]
# This loop returns the alive mutants based in the lines of the file passed as ARGV[0]
mutants_not_killed = Array.new
all_lines.each do |al|
temp_array = Array.new
......@@ -53,6 +53,7 @@ all_lines.each do |al|
mutants_not_killed << temp_array.map{ |x| x }.reduce(&:|).uniq
end
# This loop returns the score and the number of mutants alive
number_of_not_killed = Array.new
score_of_not_killed = Array.new
i = 0
......@@ -64,3 +65,24 @@ while i < limit do
i = i.next
end
# Generate the average for each strategy
result = Array.new
result[0] = score_of_not_killed[0]
result[1] = number_of_not_killed[1..100].reduce(&:+).fdiv(100).fdiv(matrix_size)
result[2] = number_of_not_killed[101..200].reduce(&:+).fdiv(100).fdiv(matrix_size)
result[3] = number_of_not_killed[201..300].reduce(&:+).fdiv(100).fdiv(matrix_size)
# Print each avarege
puts("The avarege")
result.each_with_index do |r, i|
case i
when 0
puts("Random 100%: #{r}")
when 1
puts("Random 10%: #{r}")
when 2
puts("Random 20%: #{r}")
when 3
puts("Random 50%: #{r}")
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment