forked from AdaGold/array-equals
-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy patharray_equals.rb
More file actions
52 lines (45 loc) · 1.02 KB
/
array_equals.rb
File metadata and controls
52 lines (45 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# 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 true
elsif array1 == [] && array2 == []
return true
elsif array1 == nil || array2 == nil
return false
elsif array1.length != array2.length
return false
index = 0
while index < array_length
if array1[current_index] != array2[current_index]
return false
end
index += 1
return true
else
return false
end
end
end
end
# NOTES WHILE WORKING THROUGH
# if
# array1.length =! array2.length
# returns false
# break
# index = 0
# while index < array.length
# element = array[index]
# #do operation
# index += 1
# end
# array_equals
# false?
# arrays are not exactly the same
# element values different
# elements not in the same order
# true?
# arrays have some # of elements
# element values are the same
# order is the same