Skip to content

Instantly share code, notes, and snippets.

View danob-jana's full-sized avatar

dan obrien danob-jana

  • jana
  • boston ma
View GitHub Profile
# my solutions to https://technology.jana.com/2016/04/26/challenge-your-python-knowledge/
def challenge_1():
################
# solution #1
#
# an open file handle will always count as "True", but the file might have
# nothing in it.
mystery = open('/dev/null', 'r')
@danob-jana
danob-jana / zipf.py
Last active November 30, 2015 20:32
def zipf(n):
# element n is weighted by 1/n
cumulative_weight = 0
cumulative_weights = []
for n in range(1, n + 1):
cumulative_weight += 1.0 / n
cumulative_weights.append(cumulative_weight)
total_weight = cumulative_weights[-1]
r = random.random() * total_weight

#Challenge:

Create a command line program that will take an internet domain name (e.g. “jana.com”) and print out a list of the email addresses that were found on that website. It should find email addresses on any discoverable page of the website, not just the home page.

##Examples:

> python find_email_addresses.py jana.com
Found these email addresses:
sales@jana.com