From c16c353b1afda71b65c14972d7e8b3b79475fbbe Mon Sep 17 00:00:00 2001 From: Jessica Date: Wed, 27 Feb 2019 16:02:06 -0800 Subject: [PATCH 1/3] created array_equals method to compare two arrays (passes all tests) --- lib/array_equals.rb | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 58e8369..04c417f 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -1,5 +1,23 @@ # 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 + if array1 == nil && array2 == nil + return true + else + return false + end + elsif array1.length != array2.length + return false + else + length = array1.length + index = 0 + length.times do |number| + if array1[index] != array2[index] + return false + end + index += 1 + end + end + return true end From 1eb7176ed5eea350a5b0fba04ef9fb140fd5b442 Mon Sep 17 00:00:00 2001 From: Jessica Date: Tue, 9 Apr 2019 10:23:17 -0700 Subject: [PATCH 2/3] Remove index variable and change iteration variable of times loop to i based on feedback --- .DS_Store | Bin 0 -> 6148 bytes lib/array_equals.rb | 6 ++---- 2 files changed, 2 insertions(+), 4 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..a41a491be1e40ef0b0c232fcbdaabbf7ff32d7e5 GIT binary patch literal 6148 zcmeHKF=_)r43uIQhBPiy?ic)n#W*kU2aIC^fddyN{Z)Bao|YL&Ha5oqlS&Z(QdCKQj`!M8{^?}>_1Kngr6 zP(%8f{r?p{Gygvp=}8Jmfq$idFL(Rh7Ozyjb@FoTwGDoNGv^yl!#YY3q8$UH9pi!R e_$87uuW^n2UN|O3Iru0C>Sutu$fUquEARt|z!xI` literal 0 HcmV?d00001 diff --git a/lib/array_equals.rb b/lib/array_equals.rb index 04c417f..399c37e 100644 --- a/lib/array_equals.rb +++ b/lib/array_equals.rb @@ -11,12 +11,10 @@ def array_equals(array1, array2) return false else length = array1.length - index = 0 - length.times do |number| - if array1[index] != array2[index] + length.times do |i| + if array1[i] != array2[i] return false end - index += 1 end end return true From 7eeb8fdf8a907177a31e218560c090b55b972654 Mon Sep 17 00:00:00 2001 From: Jessica Date: Tue, 9 Apr 2019 10:24:06 -0700 Subject: [PATCH 3/3] Delete .DS_Store from Git --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index a41a491be1e40ef0b0c232fcbdaabbf7ff32d7e5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKF=_)r43uIQhBPiy?ic)n#W*kU2aIC^fddyN{Z)Bao|YL&Ha5oqlS&Z(QdCKQj`!M8{^?}>_1Kngr6 zP(%8f{r?p{Gygvp=}8Jmfq$idFL(Rh7Ozyjb@FoTwGDoNGv^yl!#YY3q8$UH9pi!R e_$87uuW^n2UN|O3Iru0C>Sutu$fUquEARt|z!xI`