`
ihuashao
  • 浏览: 4550513 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

The four number game

 
阅读更多

The Four Numbers Game is a mathematical game, as taught by Dr. Paul Sally, Prof. of Mathematics at the University of Chicago. To play this game, draw a square and put a number at each corner, thus:

5___9
|   |
|   |
|   |
7___13

Now form a new square based on the difference between each the values at the ends of each side. Example:

5_4_9
|   |
2   4
|   |
7_6_13

This gives a new square, which I'll rotate anticlockwise 45 degrees.

4___4
|   |
|   |
|   |
2___6

This in turn gives

0___2
|   |
|   |
|   |
2___4

Then

2___2
|   |
|   |
|   |
2___2

Then

0___0
|   |
|   |
|   |
0___0

At this point, the game is over.

Codes for geting any four given numbers:

  1. SubFourNumbers(ByRefstepsAsString,ByRefcountAsLong,ParamArrays())
  2. DimtempAsString,tempcountAsLong
  3. count=1
  4. Ifs(0)&s(1)&s(2)&s(3)="0000"Thensteps=Join(s,","):ExitSub
  5. FourNumberstemp,tempcount,Abs(s(0)-s(1)),Abs(s(1)-s(2)),Abs(s(2)-s(3)),Abs(s(3)-s(0))
  6. steps=Join(s,",")&vbCrLf&temp
  7. count=tempcount+1
  8. EndSub
  9. SubGetit()
  10. DimstepsAsString,countAsLong
  11. FourNumberssteps,count,[exp(1)],[pi()],1,0
  12. Debug.Print "Count=" & count & vbCrLf & String(50, "-") & vbCrLf & steps
  13. FourNumbers steps, count, 149, 274, 504, 927
  14. Debug.Print "Count=" & count & vbCrLf & String(50, "-") & vbCrLf & steps
  15. EndSub

It returns:

Count=5
--------------------------------------------------
2.71828182845905,3.14159265358979,1,0
0.423310825130748,2.14159265358979,1,2.71828182845905
1.71828182845905,1.14159265358979,1.71828182845905,2.2949710033283
0.576689174869252,0.576689174869252,0.576689174869252,0.576689174869252
0,0,0,0

Count=19
--------------------------------------------------
149,274,504,927
125,230,423,778
105,193,355,653
88,162,298,548
74,136,250,460
62,114,210,386
52,96,176,324
44,80,148,272
36,68,124,228
32,56,104,192
24,48,88,160
24,40,72,136
16,32,64,112
16,32,48,96
16,16,48,80
0,32,32,64
32,0,32,64
32,32,32,32
0,0,0,0

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics