mapper.py:

for each line in STDIN
   extract year and temperature
   print year, temperature to STDOUT  


reducer.py:

currentyear = NULL
currentmax = 0
for each line in STDIN
   split line into year, temperature
   if year == currentyear:
      currentmax = max(currentmax,temperature)
   else:  
      if currentyear not NULL:
         print currentyear, currentmax
      currentyear = year
      currentmax = temperature
print currentyear, currentmax

tgmap.py:

#!/usr/bin/env python

# map/reduce pair inputs a graph adjacency matrix and outputs a list of
# links; if say row 3, column 8 of the input is 1, then there will be a
# row (3,8) in the final output
 
import sys

for line in sys.stdin:
   tks = line.split() # get tokens
   srcnode = tks[0]
   links = tks[1:]
   for dstnode in range(len(links)):
      if links[dstnode] == '1':
          toprint = '%s\t%s' % (srcnode, dstnode) 
          print toprint

tgred.py:

#!/usr/bin/env python

import sys

for line in sys.stdin:
    line = line.strip()
    srcnode, dstnode = line.split('\t')
    print '%s\t%s' % (srcnode, dstnode)

