The four number game

本文介绍了一个数学游戏——四数游戏,该游戏由芝加哥大学数学教授Paul Sally传授。通过绘制包含四个角点数字的正方形,并基于每条边两端数值之差形成新的正方形,重复这一过程直至所有角点上的数字均为零。文章还提供了实现这一游戏的伪代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值