From 461eb89ec1aa7d3feba1ab9f449a0667bf98b49d Mon Sep 17 00:00:00 2001 From: daniela sanchez Date: Thu, 22 Aug 2019 15:03:29 -0700 Subject: [PATCH 1/2] Only tests for nil arrays aren't passing --- lib/array_equals.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 58e8369..651163b 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -1,5 +1,20 @@ # Determines if the two input arrays have the same count of elements # and the same integer values in the same exact order def array_equals(array1, array2) +true_false_array = [] + if array1.length == array2.length + array1.length.times do |index| + if array1[index] == array2[index] + true_false_array << "true" + else + true_false_array << "false" + end + end + else + true_false_array << "false" + end + + return true_false_array.delete("false") == nil raise NotImplementedError end + From 26e74a8a2e3adc575770fb28a884ac4b1cf0e7fc Mon Sep 17 00:00:00 2001 From: daniela sanchez Date: Sun, 1 Sep 2019 21:29:32 -0700 Subject: [PATCH 2/2] All tests passed --- lib/array_equals.rb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 651163b..7038b07 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -2,16 +2,25 @@ # and the same integer values in the same exact order def array_equals(array1, array2) true_false_array = [] - if array1.length == array2.length - array1.length.times do |index| - if array1[index] == array2[index] - true_false_array << "true" - else - true_false_array << "false" - end + + if array1 == nil || array2 == nil + if array1 == nil && array2 == nil + true_false_array << "true" + else + true_false_array << "false" end else - true_false_array << "false" + if array1.length == array2.length + array1.length.times do |index| + if array1[index] == array2[index] + true_false_array << "true" + else + true_false_array << "false" + end + end + else + true_false_array << "false" + end end return true_false_array.delete("false") == nil