You are viewing a single comment's thread. Return to all comments →
I did your first 3 steps to get a summed array for each stack. But as I was using Ruby I merely did an intersection on all 3 arrays:
matching_values = summed_h1 & summed_h2 & summed_h3
The correct value will either be the last value in the matched_values array or if the array is empty 0 so I did:
return matching_values.empty? ? 0 : matching_values.pop
Seems like cookies are disabled on this browser, please enable them to open this website
Equal Stacks
You are viewing a single comment's thread. Return to all comments →
I did your first 3 steps to get a summed array for each stack. But as I was using Ruby I merely did an intersection on all 3 arrays:
matching_values = summed_h1 & summed_h2 & summed_h3
The correct value will either be the last value in the matched_values array or if the array is empty 0 so I did:
return matching_values.empty? ? 0 : matching_values.pop