5517
Comment:
|
5539
py3 print
|
Deletions are marked like this. | Additions are marked like this. |
Line 97: | Line 97: |
print 'Queen at (%d,%d) is threatened by another queen'%(x,y) | print('Queen at (%d,%d) is threatened by another queen' % (x, y)) |
Line 141: | Line 141: |
print 'You have lost' | print('You have lost') |
Line 144: | Line 144: |
print 'Try to take the last item' | print('Try to take the last item') |
Line 146: | Line 146: |
print 'Previous situation:' print game_repr(nim) |
print('Previous situation:') print(game_repr(nim)) |
Line 150: | Line 150: |
print 'Your move:' print game_repr(nim) |
print('Your move:') print(game_repr(nim)) |
Line 153: | Line 153: |
print 'You win' | print('You win') |
Line 156: | Line 156: |
print 'My move:' | print('My move:') |
Line 158: | Line 158: |
myheap,myamount=move_nim(nim) | myheap, myamount = move_nim(nim) |
Line 161: | Line 161: |
myheap=min(heap_number for heap_number, heap_size in enumerate(nim) if heap_size>0) | myheap=min(heap_number for heap_number, heap_size in enumerate(nim) if heap_size > 0) |
Line 164: | Line 164: |
print game_repr(nim) | print(game_repr(nim)) |
Line 166: | Line 166: |
print 'I win' | print('I win') |
Line 168: | Line 168: |
print 'Please move again' | print('Please move again') |
Line 170: | Line 170: |
print 'Choose a heap and the amount to substract from that heap' print game_repr(nim) |
print('Choose a heap and the amount to substract from that heap') print(game_repr(nim)) |
Sage Interactions - Games and Diversions
goto interact main page
Zeros
Have you ever wished you could count the number of zero digits in a long number like Rainman?
by William Stein and Sequoia Lefthand
Queens on board
An interaction to play with the problem of placing eight queens on a board so that they do not threaten each other. This interaction exemplifies the use of persistent data, and the auto_update=False option coded by mhansen and included in sage 3.3. by Pablo Angulo
Nim
Play nim against a perfect opponent. This interaction exemplifies the use of persistent data, and the auto_update=False option coded by mhansen and included in sage 3.3. by Pablo Angulo