Skip to content

Instantly share code, notes, and snippets.

@michaelguia
Created June 7, 2018 02:38
Show Gist options
  • Save michaelguia/f51a7b719f6739c4fce016d01b3d4edd to your computer and use it in GitHub Desktop.
Save michaelguia/f51a7b719f6739c4fce016d01b3d4edd to your computer and use it in GitHub Desktop.
def mapper1(_, line):
for word in line:
yield ((len(word), word[0]), 1)
def reducer1(key, values):
yield key, sum(values)
def mapper2(key, value):
length, letter = key
yield (length, (value, letter))
def reducer2(key, values):
count, letter = max(values)
yield (key, letter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment