Skip to content

Instantly share code, notes, and snippets.

@IdahoEv
Created September 15, 2016 00:26
Show Gist options
  • Save IdahoEv/5c9ea4e29b20a6ded4e862b3160ea079 to your computer and use it in GitHub Desktop.
Save IdahoEv/5c9ea4e29b20a6ded4e862b3160ea079 to your computer and use it in GitHub Desktop.
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