First solution in Clear category for Pawn Brotherhood by
This function uses a list comprehension to build a list of safe pawns
To check if a pawn is safe, we look at the previous row using int(i-1)
and the left and right column using chr(ord(i) +/- 1).
Note: ord() converts a string to a number, and char convert a number to a string.
We don't need to worry about converting ord('a')-1 to a char, for instance, because
a non-alpha char will never appear in the pawns list anyway
If the left diagonal or right diagonal spot is in the pawns list, then the current pawn is safe
return len([i for i in pawns if (chr(ord(i)-1) + str(int(i)-1)) in pawns or (chr(ord(i)+1) + str(int(i)-1)) in pawns])
April 10, 2016