已编辑-有关修改,请参见下文
首先,我只是在非结构化(需要行号)BASIC的老派中真正胜任。
我正在尝试编写一个看起来很简单的程序,但是自从上次涉猎以来,我缺乏知识和时间却使我失望。
我有6组4个数字。它们之间的数字为1-24。
这些数字应放置在立方体的角上。
对角相反的数字必须等于25。
即如果立方体的角(按顺时针方向标记)的顶面是ABC&D,而底面的EFGH(从相同的相对角开始)(在线框图中从面的内侧看),则放置1顶面A角中的自动将24放置在底面G角中。
每张脸的总数必须等于50。
到目前为止,我已经掌握了以下内容。
他们是
(A)1 12 16 21 opp(F)24 13 9 4
(B)2 11 17 20 opp(E)23 14 8 5
(C)3 10 18 19 opp(D)22 15 7 6
我想要程序做的是将数字放置在所有4个面上,A朝向F,对角线等于25,然后进行计算以查看在每个角点相交的3个数字是否等于37或38。
我已经束手无策了,但是如果我的计算正确的话,假设第一个数字保持不变,则第一个面孔有6种组合。但是2-5张面孔每个都有10种组合,并且可以定向8种方式,我计算为6 * 10 * 10 * 10 * 10 * 8 = 480,000种组合。
我正在编写一个程序来处理1到24的数字,但是它落在某个地方:
100 cls
110 let n=1
120 let a=1
130 let b=2
140 let c=3
150 print a; " "; b; " "; c; " "
160 if a+b=25 then goto 230 else goto 170
170 if a+c=25 then goto 230 else goto 180
180 if b+c=25 then goto 230 else goto 190
190 if a+b+c=37 then print n;": "; a; " "; b; " "; c; " = "; a+b+c else goto 210
200 let n=n+1
210 if a+b+c=38 then print n;": "; a; " "; b; " "; c; " = "; a+b+c else goto 230
220 let n=n+1
230 if c=24 then goto 260 else goto 240
240 let c=c+1
250 goto 150
260 if b=23 then goto 300 else goto 270
270 let b=b+1
280 let c=b+2
290 goto 150
300 if a=22 then goto 1000 else goto 310
310 let a=a+1
320 let b=a+2
330 let c=a+3
340 goto 145
1000 end
已编辑
因此,我将python作为一种替代语言进行了研究,在从未真正用python编写任何东西的大约30分钟内,我将以下内容拼凑在一起;
n=1
a=1
b=2
c=3
while a<23:
while b<24:
while c<25:
if a+b!=25 and a+c!=25 and b+c!=25:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
c+=1
b=b+1
c=b+2
a=a+1
b=a+2
c=a+3
得出以下结果:
1 : 1 13 23 = 37
2 : 1 14 22 = 37
3 : 1 14 23 = 38
4 : 1 15 21 = 37
5 : 1 15 22 = 38
6 : 1 16 20 = 37
7 : 1 16 21 = 38
8 : 1 17 19 = 37
9 : 1 17 20 = 38
10 : 2 11 24 = 37
11 : 2 12 24 = 38
12 : 2 13 22 = 37
13 : 2 14 21 = 37
14 : 2 14 22 = 38
15 : 2 15 20 = 37
16 : 2 15 21 = 38
17 : 2 16 19 = 37
18 : 2 16 20 = 38
19 : 2 17 19 = 38
20 : 3 10 24 = 37
21 : 3 11 23 = 37
22 : 3 11 24 = 38
23 : 3 12 23 = 38
24 : 3 13 21 = 37
25 : 3 14 20 = 37
26 : 3 14 21 = 38
27 : 3 15 19 = 37
28 : 3 15 20 = 38
29 : 3 16 18 = 37
30 : 3 16 19 = 38
31 : 4 9 24 = 37
32 : 4 10 23 = 37
33 : 4 10 24 = 38
34 : 4 11 22 = 37
35 : 4 11 23 = 38
36 : 4 12 22 = 38
37 : 4 13 20 = 37
38 : 4 14 19 = 37
39 : 4 14 20 = 38
40 : 4 15 18 = 37
41 : 4 15 19 = 38
42 : 4 16 18 = 38
43 : 5 8 24 = 37
44 : 5 9 23 = 37
45 : 5 9 24 = 38
46 : 5 10 22 = 37
47 : 5 10 23 = 38
48 : 5 11 21 = 37
49 : 5 11 22 = 38
50 : 5 12 21 = 38
51 : 5 13 19 = 37
52 : 5 14 18 = 37
53 : 5 14 19 = 38
54 : 5 15 17 = 37
55 : 5 15 18 = 38
56 : 6 8 23 = 37
57 : 6 8 24 = 38
58 : 6 9 22 = 37
59 : 6 9 23 = 38
60 : 6 10 21 = 37
61 : 6 10 22 = 38
62 : 6 11 20 = 37
63 : 6 11 21 = 38
64 : 6 12 20 = 38
65 : 6 13 18 = 37
66 : 6 14 17 = 37
67 : 6 14 18 = 38
68 : 6 15 17 = 38
69 : 7 9 21 = 37
70 : 7 9 22 = 38
71 : 7 10 20 = 37
72 : 7 10 21 = 38
73 : 7 11 19 = 37
74 : 7 11 20 = 38
75 : 7 12 19 = 38
76 : 7 13 17 = 37
77 : 7 14 16 = 37
78 : 7 14 17 = 38
79 : 8 10 19 = 37
80 : 8 10 20 = 38
81 : 8 11 18 = 37
82 : 8 11 19 = 38
83 : 8 12 18 = 38
84 : 8 13 16 = 37
85 : 8 14 16 = 38
86 : 9 11 17 = 37
87 : 9 11 18 = 38
88 : 9 12 17 = 38
89 : 9 13 15 = 37
90 : 10 12 16 = 38
如何将其转换为使用4个数字的6个数据集。如我最初的查询中所述。
编辑#2
它不是很漂亮,但是我进一步缩小了范围(并纠正了语法错误)。
n=1
a=1
b=2
c=3
f1=[1,12,16,21]
f2=[2,11,17,20]
f3=[3,10,18,19]
f4=[4,9,13,24]
f5=[5,8,14,23]
f6=[6,7,15,22]
while a<23:
while b<24:
while c<25:
if a+b!=25 and a+c!=25 and b+c!=25:
if a in f1:
if b in f2:
if c in f3 or c in f6:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f1:
if b in f3:
if c in f2 or c in f5:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f1:
if b in f5:
if c in f3 or c in f6:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f1:
if b in f6:
if c in f3 or c in f5:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f2:
if b in f1:
if c in f3 or c in f6:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f2:
if b in f3:
if c in f1 or c in f4:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f2:
if b in f4:
if c in f3 or c in f6:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f2:
if b in f6:
if c in f1 or c in f4:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f3:
if b in f1:
if c in f2 or c in f5:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f3:
if b in f2:
if c in f1 or c in f4:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f3:
if b in f4:
if c in f1 or c in f5:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f4:
if b in f2:
if c in f3 or c in f6:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f4:
if b in f3:
if c in f2 or c in f5:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f4:
if b in f5:
if c in f3 or c in f6:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f5:
if b in f1:
if c in f3 or c in f6:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f5:
if b in f3:
if c in f1 or c in f4:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f5:
if b in f4:
if c in f3 or c in f6:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f5:
if b in f6:
if c in f1 or c in f4:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f6:
if b in f1:
if c in f2 or c in f5:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f6:
if b in f2:
if c in f1 or c in f4:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
if a in f6:
if b in f4:
if c in f2 or c in f5:
if a+b+c==37 or a+b+c==38:
print (n,":",a,b,c,"=",a+b+c)
n+=1
c+=1
b=b+1
c=b+1
a=a+1
b=a+1
c=a+2
给予
1 : 1 14 22 = 37
2 : 1 17 19 = 37
3 : 2 13 22 = 37
4 : 2 15 21 = 38
5 : 2 16 19 = 37
6 : 3 11 24 = 38
7 : 3 12 23 = 38
8 : 3 13 21 = 37
9 : 4 10 23 = 37
10 : 4 11 22 = 37
11 : 4 14 19 = 37
12 : 5 13 19 = 37
13 : 6 9 23 = 38
14 : 6 11 21 = 38
15 : 6 12 20 = 38
16 : 7 13 17 = 37
17 : 8 12 18 = 38
18 : 9 11 18 = 38
19 : 9 14 15 = 38
20 : 10 11 16 = 37
21 : 10 13 14 = 37
22 : 11 12 15 = 38