Talk:A. W. Faber Model 366
Latest comment: 3 years ago by The Anome in topic Python program to check property
This article is rated Start-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||||||
|
Python program to check property
editHere's a small Python program to check the mathematical properties of the table given in the illustration:
table = """
0 1 69 2 24 70 9 3 38
25 13 71 66 10 93 4 30 39 96
26 78 14 86 72 48 67 7 11 91
94 84 5 82 31 33 40 56 97 35
27 45 79 42 15 62 87 58 73 18
49 99 68 23 8 37 12 65 92 29
95 77 85 47 6 90 83 81 32 55
34 44 41 61 57 17 98 22 36 64
28 76 46 89 80 54 43 60 16 21
63 75 88 53 59 20 74 52 19 51
50
"""
s = dict(zip(range(1, 101), map(int, table.split())))
for i in range(1, 101):
for j in range(1, 101):
x = (s[i] + s[j])%100
y = s[(i*j)%101]
if (x != y):
raise Exception("mismatch")
print "all matched"
And here's the mapping inverted, from s[i] to i, where s[i] is the table generated above, for i=0 to i=99:
[1, 2, 4, 8, 16, 32, 64, 27, 54, 7, 14, 28, 56, 11, 22, 44, 88, 75, 49, 98, 95, 89, 77, 53, 5, 10, 20, 40, 80, 59, 17, 34, 68, 35, 70, 39, 78, 55, 9, 18, 36, 72, 43, 86, 71, 41, 82, 63, 25, 50, 100, 99, 97, 93, 85, 69, 37, 74, 47, 94, 87, 73, 45, 90, 79, 57, 13, 26, 52, 3, 6, 12, 24, 48, 96, 91, 81, 61, 21, 42, 84, 67, 33, 66, 31, 62, 23, 46, 92, 83, 65, 29, 58, 15, 30, 60, 19, 38, 76, 51]
which also happens to be the sequence of numbers you can see on the Schumacher-system scale in the image seen here. Code for this:
d = dict(zip(map(int, table.split()), range(1, 101)))
print [d[i] for i in range(0, 100)]