From 9f613089077d521bf0f74246fccd8b04256857e9 Mon Sep 17 00:00:00 2001 From: Chantal Demissie <42252976+ChantalDemissie@users.noreply.github.com> Date: Thu, 28 Feb 2019 08:17:26 -0800 Subject: [PATCH 1/3] Add files via upload --- arrayequals.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 arrayequals.rb diff --git a/arrayequals.rb b/arrayequals.rb new file mode 100644 index 0000000..61bbe00 --- /dev/null +++ b/arrayequals.rb @@ -0,0 +1,18 @@ +#Determines if the two input integer arrays are equal. +#The two arrays will be considered equal if.... +#they both have the exact same count of elements +# in the exact same order. +# able to use .length ONLY +# == equal +#!= Checks if the value of two operands are equal or not, +#!=if values are not equal then condition becomes true. + +def array_equals(array1, array2) + raise NotImplementedError + return true if array1 == nil and array2 == nil + return false if !array1 or !array2 + return false if array1.length != array2.length + + array1.length.times do |index| + return false if array1[index] != array2[index] + end \ No newline at end of file From 881556efc457d84197978179482b733ec39e10b3 Mon Sep 17 00:00:00 2001 From: Chantal Demissie <42252976+ChantalDemissie@users.noreply.github.com> Date: Thu, 28 Feb 2019 08:22:42 -0800 Subject: [PATCH 2/3] Rename arrayequals.rb to arrayequals2.rb --- arrayequals2.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 arrayequals2.rb diff --git a/arrayequals2.rb b/arrayequals2.rb new file mode 100644 index 0000000..0e4ff3d --- /dev/null +++ b/arrayequals2.rb @@ -0,0 +1,18 @@ +#Determines if the two input integer arrays are equal. +#The two arrays will be considered equal if.... +#they both have the exact same count of elements +# in the exact same order. +# able to use .length ONLY +# == equal +#!= Checks if the value of two operands are equal or not, +#!=if values are not equal then condition becomes true. + +def array_equals(array1, array2) + raise NotImplementedError + return true if array1 == nil and array2 == nil + return false if !array1 or !array2 + return false if array1.length != array2.length + + array1.length.times do |index| + return false if array1[index] != array2[index] + end From 5f139853c79580f0648f33234abd225d78b97920 Mon Sep 17 00:00:00 2001 From: Chantal Demissie <42252976+ChantalDemissie@users.noreply.github.com> Date: Wed, 6 Mar 2019 09:26:14 -0800 Subject: [PATCH 3/3] Update arrayequals2.rb --- arrayequals2.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arrayequals2.rb b/arrayequals2.rb index 0e4ff3d..b21fe85 100644 --- a/arrayequals2.rb +++ b/arrayequals2.rb @@ -8,10 +8,10 @@ #!=if values are not equal then condition becomes true. def array_equals(array1, array2) - raise NotImplementedError return true if array1 == nil and array2 == nil return false if !array1 or !array2 return false if array1.length != array2.length +end array1.length.times do |index| return false if array1[index] != array2[index]