From d3f4df92642d9a663c670c825bc6f7846957cc5c Mon Sep 17 00:00:00 2001 From: emoxi123 Date: Thu, 23 Nov 2017 22:37:23 +0200 Subject: [PATCH] blah blah --- ClassB/07/homework2/task1.rb | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 ClassB/07/homework2/task1.rb diff --git a/ClassB/07/homework2/task1.rb b/ClassB/07/homework2/task1.rb new file mode 100644 index 0000000..3ad3543 --- /dev/null +++ b/ClassB/07/homework2/task1.rb @@ -0,0 +1,45 @@ +require 'csv' +require 'matrix' + +mat1 = "./matrix1.csv" +mat2 = "./matrix2.csv" + +line_count1 = 0 #broq na redovete +elements_in_line_count1 = 0 #broq na elemntite v edin red :) + + +line_count2 = 0 +elements_in_line_count2 = 0 + + +arr1 = Array.new +arr2 = Array.new + +CSV.foreach(mat1) do |row| + arr1 << row.map(&:to_i) + line_count1 += 1 + elements_in_line_count1 = row.size +end + +CSV.foreach(mat2) do |row| + arr2 << row.map(&:to_i) + line_count2 += 1 + elements_in_line_count2 = row.size +end + + +begin + if elements_in_line_count1 != elements_in_line_count2 || line_count1 != line_count2 + + puts "undefined" +end + + else + (Matrix.rows(arr1) + Matrix.rows(arr2)).symmetric? + puts "true" + end + + + puts "false" + +end