Created
June 7, 2018 02:38
-
-
Save michaelguia/f51a7b719f6739c4fce016d01b3d4edd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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