comparing 2 arrays (ruby)
Posted: Fri Jan 03, 2014 12:14 am
I need to do one of two things:
a) compare 2 arrays of elements and get an output with 0's (element at index not equal) and 1's (element at index equal)
or
b) determine which elements on input array changed after single retrig, and get an output like described above.
I guess the (a) is easier to implement.
It would be like this:
array1:
11
9
3
40
5
array2 (= array1 after change)
11
25
34
40
7
output:
1
0
0
1
0
(no sorting, no duplicate removing). How to make it with ruby?
a) compare 2 arrays of elements and get an output with 0's (element at index not equal) and 1's (element at index equal)
or
b) determine which elements on input array changed after single retrig, and get an output like described above.
I guess the (a) is easier to implement.
It would be like this:
array1:
11
9
3
40
5
array2 (= array1 after change)
11
25
34
40
7
output:
1
0
0
1
0
(no sorting, no duplicate removing). How to make it with ruby?