Created
January 11, 2012 09:06
-
-
Save kimdwkimdw/1593822 to your computer and use it in GitHub Desktop.
Get Longest Word From List
This file contains hidden or 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
# available above python 2.6 | |
from multiprocessing import Pool | |
def extractMaxLen( l ): | |
assert(len(l)>0) | |
elem,elemLen = l[0],len(l[0]) | |
for idx in xrange(1, len(l)): | |
if len(l[idx]) > elemLen: | |
elem,elemLen = l[idx],len(l[idx]) | |
return elem | |
if __name__ == '__main__': | |
lists = [ ["aaaa","aa","a" ],\ | |
["aaaaaaaaaaaaa","aa","aaaaa"]] | |
result = [] | |
pool = Pool(processes=4) | |
print extractMaxLen(pool.map( extractMaxLen, lists)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment