You have a chessboard of side length 2^n. An arbitrary unit square is removed from this board. Is it possible to tile the remaining chessboard with L shaped tiles having 3 unit squares each (as shown in the figure below).
_
| |_
|___|
Random notes on life, work and other stuff.
_
| |_
|___|
def sort(word):
l = list(word)
l.sort()
return "".join(l)
def anagrams(words):
ags = {}
for word in words:
sw = sort(word)
ags.setdefault(sw, []).append(word)
return dict([(x,y) for (x,y) in ags.iteritems() if len(y) > 1])
if __name__ == "__main__":
words = open("wordlist.txt").readlines()
words = [word.strip() for word in words]
rs = anagrams(words)
print len(rs)