Skip to content

Instantly share code, notes, and snippets.

@philangist
Created April 9, 2018 12:08
Show Gist options
  • Save philangist/70fca61d2d124f773830b39be8eca823 to your computer and use it in GitHub Desktop.
Save philangist/70fca61d2d124f773830b39be8eca823 to your computer and use it in GitHub Desktop.
"""
Examples:
Input: {5, 20, 3, 2, 50, 80}, n = 78
Output: Pair Found: (2, 80)
Input: {90, 70, 20, 80, 50}, n = 45
Output: No Such Pair
"""
def find_diff(arr, n):
for i in arr:
if (i + n) in arr:
return (i, i + n)
return "No Such Pair"
arr = {5, 20, 3, 2, 50, 80}
n = 78
find_diff(arr, n)
arr = {90, 70, 20, 80, 50}
n = 45
find_diff(arr, n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment