Skip to content

Instantly share code, notes, and snippets.

@Cornellio
Created September 13, 2017 03:26
Show Gist options
  • Save Cornellio/aaa5d3c748e2643821f2b906d883e250 to your computer and use it in GitHub Desktop.
Save Cornellio/aaa5d3c748e2643821f2b906d883e250 to your computer and use it in GitHub Desktop.
Given two files that have lists of numbers in them, find the numbers that are overlapping. One file has a list of all prime numbers under 1000, and the other has a list of happy numbers up to 1000.
with open('prime_nums.txt') as f:
primes = f.read().splitlines()
with open('happy_nums.txt') as f:
happys = f.read().splitlines()
overlap = [n for n in primes if n in happys ]
print(overlap)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment