Rubykuby

Singingbanana Maths puzzle

May 25th, 2013
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import math
  2.  
  3. maxvalue = 90
  4.  
  5. board = maxvalue*["B"]
  6. counter = 2
  7.  
  8. def flipPiece(board, piece):
  9.     if board[piece-1] == "W": #"-1" because ordinal -> cardinal
  10.         board[piece-1] = "B"
  11.     else:
  12.         board[piece-1] = "W"
  13.  
  14. def counterPossibilities(counter):
  15.     possibilities = math.floor(maxvalue / counter) #math.floor rounds down any floating point
  16.     return int(possibilities)
  17.    
  18. def flipBoard(possibilities, counter, board):
  19.     for i in range(1, possibilities + 1):
  20.         flipPiece(board, counter * i)
  21.  
  22. while counter < maxvalue + 1:
  23.     flipBoard(counterPossibilities(counter), counter, board)
  24.     print(board)
  25.     print(counter)
  26.     counter += 1
Advertisement
Add Comment
Please, Sign In to add comment