Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Branches - Dora L. #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 66 additions & 1 deletion lib/array_equals.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,70 @@
# 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)
# count1 = 0
# count2 = 0
# if array1 == nil && array2 == nil
# if array1.length == array2.length
# array1.each_with_index do |array1_element, index|
# count1 += array1_element
# array2_element = array2[index]
# count2 += array2_element
# if array1_element == array2_element
# return true
# end
# if count1 == count2
# return true
# end
# end
# return true

# else
# return false
# end
# return true
# end
# end

# Array equal, element length

# Array not equal, element length

# Array not equal, different count

#length
#count
def array_equals(array1, array2)
raise NotImplementedError

if array1 == nil && array2 == nil
return true
end

if array1 != nil && array2 != nil
if array1.length == array2.length
i = 0
array1.length.times do
if array1[i] != array2[i]
return false
else
i += 1
end
end
return true
else
return false
end
return true
else
return false
end
end

puts array_equals([3, 3, 4], [3, 3, 4])
# i = 0
# array_a = [3, 3, 4]
# array_b = [2, 2, 4]
# until array_a[i] == array_b[i]
# i += 1
# return false
# # puts "#{array_a[i]} and #{array_b[i]}"
# end