@@ -35,15 +35,15 @@ def __init__(self, n, bitmap = None):
3535
3636 # Add background bitmap
3737 if bitmap :
38- self .bitmap = c .create_bitmap (width / 2 , height / 2 ,
38+ self .bitmap = c .create_bitmap (width // 2 , height / /2 ,
3939 bitmap = bitmap ,
4040 foreground = 'blue' )
4141
4242 # Generate pegs
4343 pegwidth = 10
44- pegheight = height / 2
45- pegdist = width / 3
46- x1 , y1 = (pegdist - pegwidth )/ 2 , height * 1 / 3
44+ pegheight = height // 2
45+ pegdist = width // 3
46+ x1 , y1 = (pegdist - pegwidth )// 2 , height * 1 / /3
4747 x2 , y2 = x1 + pegwidth , y1 + pegheight
4848 self .pegs = []
4949 p = c .create_rectangle (x1 , y1 , x2 , y2 , fill = 'black' )
@@ -57,14 +57,14 @@ def __init__(self, n, bitmap = None):
5757 self .tk .update ()
5858
5959 # Generate pieces
60- pieceheight = pegheight / 16
61- maxpiecewidth = pegdist * 2 / 3
60+ pieceheight = pegheight // 16
61+ maxpiecewidth = pegdist * 2 // 3
6262 minpiecewidth = 2 * pegwidth
6363 self .pegstate = [[], [], []]
6464 self .pieces = {}
65- x1 , y1 = (pegdist - maxpiecewidth )/ 2 , y2 - pieceheight - 2
65+ x1 , y1 = (pegdist - maxpiecewidth )// 2 , y2 - pieceheight - 2
6666 x2 , y2 = x1 + maxpiecewidth , y1 + pieceheight
67- dx = (maxpiecewidth - minpiecewidth ) / (2 * max (1 , n - 1 ))
67+ dx = (maxpiecewidth - minpiecewidth ) // (2 * max (1 , n - 1 ))
6868 for i in range (n , 0 , - 1 ):
6969 p = c .create_rectangle (x1 , y1 , x2 , y2 , fill = 'red' )
7070 self .pieces [i ] = p
@@ -101,10 +101,10 @@ def report(self, i, a, b):
101101
102102 # Move it towards peg b
103103 bx1 , by1 , bx2 , by2 = c .bbox (self .pegs [b ])
104- newcenter = (bx1 + bx2 )/ 2
104+ newcenter = (bx1 + bx2 )// 2
105105 while 1 :
106106 x1 , y1 , x2 , y2 = c .bbox (p )
107- center = (x1 + x2 )/ 2
107+ center = (x1 + x2 )// 2
108108 if center == newcenter : break
109109 if center > newcenter : c .move (p , - 1 , 0 )
110110 else : c .move (p , 1 , 0 )
0 commit comments