## Assigning values to variables raster1..3 (remember, the values are strings!)
raster1 = "133322232111"
raster2 = "1132111223223"
raster3 = "22111332211122"

## Calculate the number of forest cells in rows 1..3 and save them to variables forest1..3
forest1 = raster1.count("1")
forest2 = raster2.count("1")
forest3 = raster3.count("1")
## Calculate the maximum number of forest cells in one row
maxForest = max(forest1, forest2, forest3)

## Check if a row has the most forest cells (this will also tell us if multiple rows contain the maximum number of forest cells if they have the same amount)
print "Row 1 has the most forest cells:", forest1 == maxForest
print "Row 2 has the most forest cells:", forest2 == maxForest
print "Row 3 has the most forest cells:", forest3 == maxForest
print ""

## Count the number of occurencies of "12" (forest water) in each row and then convert it to a boolean value (0 → False, anything else → True)
print "Row 1 contains cells '12':", bool(raster1.count("12"))
print "Row 2 contains cells '12':", bool(raster2.count("12"))
print "Row 3 contains cells '12':", bool(raster3.count("12"))
print ""

## Count the the number of forest, water and field cells in columns 3 up to (and including!) 6
forest = raster1.count("1", 2, 6) + raster2.count("1", 2, 6) + raster3.count("1", 2, 6)
water = raster1.count("2", 2, 6) + raster2.count("2", 2, 6) + raster3.count("2", 2, 6)
field = raster1.count("3", 2, 6) + raster2.count("3", 2, 6) + raster3.count("3", 2, 6)
maxValue = max(forest, water, field)
print "Forest cells:", forest
print "Forest is the most frequent in columns 3 to 6:", forest == maxValue
print "Water cells:", water
print "Water is the most frequent in columns 3 to 6:", water == maxValue
print "Field cells:", field
print "Field is the most frequent in columns 3 to 6:", field == maxValue
print "Maximum:", maxValue
print ""

## raster2.count("1", 2, 6) is the same as raster2[2:6].count("1") !
print raster2.count("1", 2, 6) == raster2[2:6].count("1")