Created
September 15, 2016 00:26
-
-
Save IdahoEv/5c9ea4e29b20a6ded4e862b3160ea079 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def pairwise_sum(target, list) | |
seen = {} | |
list.each do |element| | |
if seen[target - element] | |
p [element, seen[element]] | |
else | |
seen[element] = element | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment