From 63ff482ef1af2d16741493a86c9114039b66816b Mon Sep 17 00:00:00 2001 From: Kate Sandler Date: Thu, 28 Feb 2019 00:45:17 -0800 Subject: [PATCH 1/2] Brought up to passing tests. --- lib/array_equals.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 58e8369..49866e0 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -1,5 +1,7 @@ # 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 == nil || array2 == nil +return false if (array1[x] - array2[x]) != 0 +return false if array1.length != array2.length end From 1328baef6318457a9f6c3882987836693996be58 Mon Sep 17 00:00:00 2001 From: Kate Sandler Date: Thu, 28 Feb 2019 00:48:41 -0800 Subject: [PATCH 2/2] Update for completion --- lib/array_equals.rb | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 58e8369..6ab678b 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -1,5 +1,21 @@ -# 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 -end + i = 0 + if (array1 == nil) && (array2 == nil) + return true + elsif (array1 == nil) && (array2 != nil) + return false + elsif (array1 != nil) && (array2 == nil) + return false + elsif array1.length != array2.length + return false + else + array1.length.times do + if array1[i] != array2[i] + return false + else + i += 1 + end + end + end + return true +end \ No newline at end of file