Processing Math: Done
jsMath
Differences between revisions 8 and 10 (spanning 2 versions)
Revision 8 as of 2012-05-09 02:52:56
Size: 5517
Editor: jason
Comment:
Revision 10 as of 2020-06-02 22:07:41
Size: 5629
Editor: kcrisman
Comment:
Deletions are marked like this. Additions are marked like this.
Line 30: Line 30:
html("<h1 align=center>Zeros</h1>")
html("<h2 align=center><font color='blue'>How many zeros?</font></h2>")
pretty_print(html("<h1 align=center>Zeros</h1>"))
pretty_print(html("<h2 align=center><font color='blue'>How many zeros?</font></h2>"))
Line 37: Line 37:
    html("<center>")
Line 39: Line 38:
    H = "<center>"
Line 41: Line 41:
           html("<font size=+3 color='red'>RIGHT</font>")            H += "<font size=+3 color='red'>RIGHT</font>"
Line 54: Line 54:
        html("<font size=+2 color='blue'>Wrong. Try again...</font>")
    html(
"</center>")
    
html("<font size=+%s color='#333'>"%random.randrange(-2,5))
    print
' '*random.randrange(20) + '0'*n
        H += "<font size=+2 color='blue'>Wrong. Try again...</font>"
    H +=
"</center>"
    pretty_print(
html(H))
    H2 =
"<font size=+%s color='#333'>%s</font>"%(random.randrange(-2,5),' '*random.randrange(20) + '0'*n)
    pretty_print(html(H2))
Line 60: Line 61:
        html("<br><br><center>Score: %s rounds, Average time: %.1f seconds</center>"%(
                 round, float(tm)/round))
        pretty_print(html("<br><br><center>Score: %s rounds, Average time: %.1f seconds</center>"%(
                 round, float(tm)/round)))
Line 97: Line 98:
            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 142:
        print 'You have lost'         print('You have lost')
Line 144: Line 145:
        print 'Try to take the last item'         print('Try to take the last item')
Line 146: Line 147:
        print 'Previous situation:'
        print game_repr(nim)
        print('Previous situation:')
        print(game_repr(nim))
Line 150: Line 151:
        print 'Your move:'
        print game_repr(nim)
        print('Your move:')
        print(game_repr(nim))
Line 153: Line 154:
            print 'You win'             print('You win')
Line 156: Line 157:
        print 'My move:'         print('My move:')
Line 158: Line 159:
            myheap,myamount=move_nim(nim)             myheap, myamount = move_nim(nim)
Line 161: Line 162:
            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 165:
        print game_repr(nim)         print(game_repr(nim))
Line 166: Line 167:
            print 'I win'             print('I win')
Line 168: Line 169:
            print 'Please move again'             print('Please move again')
Line 170: Line 171:
        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

zeros.png

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

queens.png

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

nim.png

interact/games (last edited 2020-06-02 22:07:41 by kcrisman)