From 5e05f6625ad0c62d78528de1dafd9d037a333721 Mon Sep 17 00:00:00 2001 From: Goeun Park Date: Wed, 22 Aug 2018 23:35:48 -0700 Subject: [PATCH] array_equals passes all tests --- lib/array_equals.rb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 58e8369..0e6cfe0 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -1,5 +1,18 @@ -# 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) - raise NotImplementedError + + if (array1 == [] && array2 == []) || (array1 == nil && array2 == nil) + return true + + elsif array1 == nil || array2 == nil || array1.length != array2.length + return false + + else + array1.length.times do |num| + if array1[num] != array2[num] + return false + end + end + + return true + end end