Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Pearls in the Box by Moff
def tour(whites, blacks, remaining):
if remaining == 1:
return whites
result = 0
if whites:
result += tour(whites - 1, blacks + 1, remaining - 1) * whites
if blacks:
result += tour(whites + 1, blacks - 1, remaining - 1) * blacks
return result
def checkio(s, steps):
return round(tour(s.count('w'), s.count('b'), steps) / len(s) ** steps, 2)
Aug. 7, 2015