Magic_triangle

How many magic triangles are there for the chosen values ​​of S S and A 7 A_7 ?

{ A 1 , A 2 , A 3 , . . , A 15 , A 16 } \left \{ A_1,A_2,A_3,..,A_{15},A_{16} \right \} - is permutation of set { 1 , 2 , 3 , . . , 15 , 16 } \left \{1,2,3,..,15,16\right \}

A 1 + A 2 + A 3 + A 5 + A 6 + A 11 + A 10 = S A_1+A_2+A_3+A_5+A_6+A_{11}+A_{10}=S

A 1 + A 4 + A 3 + A 8 + A 9 + A 15 + A 16 = S A_1+A_4+A_3+A_8+A_9+A_{15}+A_{16}=S

A 10 + A 11 + A 12 + A 13 + A 14 + A 15 + A 16 = S A_{10}+A_{11}+A_{12}+A_{13}+A_{14}+A_{15}+A_{16}=S

A 5 + A 6 + A 7 + A 8 + A 9 = S A_5+A_6+A_7+A_{8}+A_9=S

A 2 + A 6 + A 7 + A 13 + A 14 = S A_2+A_6+A_7+A_{13}+A_{14}=S

A 4 + A 8 + A 7 + A 12 + A 13 = S A_4+A_8+A_7+A_{12}+A_{13}=S

Let N ( S , A 7 ) N (S, A_7) be the number of magic triangles for the chosen values ​​of S S and A 7 A_7 . Find S m a x S_{max} and A 7 m a x A_{7max} which give the maximum value of N ( S , A 7 ) N (S, A_7) . Give answer S m a x + A 7 m a x S_{max} + A_{7max}

The problem was proposed thanks to V. Ilyukhin.


The answer is 69.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

David Vreken
Dec 16, 2020

Since A 1 , A 2 , A 3 , . . . , A 15 , A 16 {A_1, A_2, A_3, ..., A_{15}, A_{16}} is a permutation of the set 1 , 2 , 3 , . . . , 15 , 16 {1, 2, 3, ..., 15, 16} , that means n = 1 16 A n = 1 + 2 + 3 + . . . + 15 + 16 = 1 2 16 17 = 136 \displaystyle \sum_{n=1}^{16} A_n = 1 + 2 + 3 + ... + 15 + 16 = \frac{1}{2} \cdot 16 \cdot 17 = 136 .

Adding all six of the given equations and simplifying gives A 6 + A 7 + A 8 + A 13 = 6 S 272 A_6 + A_7 + A_8 + A_{13} = 6S - 272 .

From third given equation A 10 + A 11 + A 12 + A 13 + A 14 + A 15 + A 16 = S A_{10} + A_{11} + A_{12} + A_{13} + A_{14} + A_{15} + A_{16} = S and the fourth given equation A 5 + A 6 + A 7 + A 8 + A 9 = S A_{5} + A_{6} + A_{7} + A_{8} + A_{9} = S , as well as n = 1 16 A n = 136 \displaystyle \sum_{n=1}^{16} A_n = 136 , we obtain A 1 + A 2 + A 3 + A 4 = 136 2 S A_1 + A_2 + A_3 + A_4 = 136 - 2S .

Similarly, A 5 + A 10 + A 11 + A 12 = 136 2 S A_{5} + A_{10} + A_{11} + A_{12} = 136 - 2S and A 9 + A 14 + A 15 + A 16 = 136 2 S A_{9} + A_{14} + A_{15} + A_{16} = 136 - 2S .

Let B = A 2 + A 4 + A 5 + A 9 + A 12 + A 14 B = A_{2} + A_{4} + A_{5} + A_{9} + A_{12} + A_{14} , C = A 1 + A 3 + A 10 + A 11 + A 15 + A 16 C = A_{1} + A_{3} + A_{10} + A_{11} + A_{15} + A_{16} , and D = A 6 + A 8 + A 13 D = A_{6} + A_{8} + A_{13} .

From A 6 + A 7 + A 8 + A 13 = 6 S 272 A_6 + A_7 + A_8 + A_{13} = 6S - 272 we get D + A 7 = 6 S 272 D + A_7 = 6S - 272 .

From A 1 + A 2 + A 3 + A 4 = 136 2 S A_1 + A_2 + A_3 + A_4 = 136 - 2S , A 5 + A 10 + A 11 + A 12 = 136 2 S A_{5} + A_{10} + A_{11} + A_{12} = 136 - 2S , and A 9 + A 14 + A 15 + A 16 = 136 2 S A_{9} + A_{14} + A_{15} + A_{16} = 136 - 2S we get B + C = 408 6 S B + C = 408 - 6S .

From A 1 + A 2 + A 3 + A 5 + A 6 + A 10 + A 11 = S A_{1} + A_{2} + A_{3} + A_{5} + A_{6} + A_{10} + A_{11} = S , A 1 + A 3 + A 4 + A 8 + A 9 + A 15 + A 16 = S A_{1} + A_{3} + A_{4} + A_{8} + A_{9} + A_{15} + A_{16} = S , and A 10 + A 11 + A 12 + A 13 + A 14 + A 15 + A 16 = S A_{10} + A_{11} + A_{12} + A_{13} + A_{14} + A_{15} + A_{16} = S we get B + 2 C + D = 3 S B + 2C + D = 3S .

From A 2 + A 6 + A 7 + A 13 + A 14 = S A_{2} + A_{6} + A_{7} + A_{13} + A_{14} = S , A 4 + A 7 + A 8 + A 12 + A 13 = S A_{4} + A_{7} + A_{8} + A_{12} + A_{13} = S , and A 5 + A 6 + A 7 + A 8 + A 9 = S A_{5} + A_{6} + A_{7} + A_{8} + A_{9} = S we get B + 2 D + 3 A 7 = 3 S B + 2D + 3A_7 = 3S .

Combining D + A 7 = 6 S 272 D + A_7 = 6S - 272 , B + C = 408 6 S B + C = 408 - 6S , B + 2 C + D = 3 S B + 2C + D = 3S , and B + 2 D + 3 A 7 = 3 S B + 2D + 3A_7 = 3S we get B = A 7 9 S + 544 B = -A_7 - 9S + 544 , C = A 7 + 3 S 136 C = A_7 + 3S - 136 , and D = A 7 + 6 S 272 D = -A_7 + 6S - 272 .

For S 49 S \leq 49 and 1 A 7 16 1 \leq A_7 \leq 16 , B 87 B \geq 87 . However, the highest value that B B can be is 11 + 12 + 13 + 14 + 15 + 16 = 81 11 + 12 + 13 + 14 + 15 + 16 = 81 . Therefore, S 50 S \geq 50 .

For S 56 S \geq 56 and 1 A 7 16 1 \leq A_7 \leq 16 , D 48 D \geq 48 . However, the highest value that D D can be is 14 + 15 + 16 = 45 14 + 15 + 16 = 45 . Therefore, S 55 S \leq 55 .

Armed with 50 S 55 50 \leq S \leq 55 and the above equations, we can now use a computer program to brute force each possible number of magic triangles for chosen values of S S and A 7 A_7 . (Note: this still took over 16 hours on my computer to run!)

Ignoring symmetrical and rotational equal possibilities, the S S and A 7 A_7 values that give the maximum number of magic triangles is S max = 53 S_{\text{max}} = 53 and A 7 max = 16 A_{7\text{max}} = 16 at 3088 3088 possible triangles. Therefore, S max + A 7 max = 53 + 16 = 69 S_{\text{max}} + A_{7\text{max}} = 53 + 16 = \boxed{69} .

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Magic_triangle
# Python

from itertools import combinations
from itertools import permutations

# Function that finds the number of magic triangles
#   for chosen values of S and A7
def N(S, A7):
    count = 0
    # L1 is a list of numbers 1-16
    L1 = []
    for a in range(1, 17):
        L1.append(a)
    # L2 is a list of numbers 1-16 except A7
    L2 = []
    for a in range(1, 17):
        if a <> A7:
            L2.append(a)
    # C is a list of 2 number combinations
    #   from L2 for A6 and A8 (in order)
    C = list(combinations(L2, 2))
    # Go through all possibilities for chosen
    #   values of S, A7, A6, and A8
    for a in range(0, len(C)):
        A = []
        for c in range(0, 17):
            A.append(0)
        A[7] = A7
        A[6] = C[a][0]
        A[8] = C[a][1]
        A[13] = 6 * S - 272 - A[6] - A[8] - A[7]
        if A[13] > A[8]:
            # L3 is a list of numbers 1-16 except
            #   A7, A6, A8, and A13
            L3 = []
            for b in range(1, 17):
                if b <> A[6] and b <> A[7] and (
                    b <> A[8] and b <> A[13]):
                    L3.append(b)
            # P is a list of 6 number permutations
            #   from L3 for A2, A3, A9, A11, A12, and A15
            P = []
            P = list(permutations(L3, 6))
            for b in range(0, len(P)):
                A[2] = P[b][0]
                A[3] = P[b][1]
                A[9] = P[b][2]
                A[11] = P[b][3]
                A[12] = P[b][4]
                A[15] = P[b][5]
                # Determine the other A values
                A[4] = S - A[7] - A[8] - A[12] - A[13]
                A[5] = S - A[6] - A[7] - A[8] - A[9]
                A[14] = S - A[2] - A[6] - A[7] - A[13]
                A[1] = 136 - 2 * S - A[2] - A[3] - A[4]
                A[10] = 136 - 2 * S - A[5] - A[11] - A[12]
                A[16] = 136 - 2 * S - A[9] - A[14] - A[15]
                # T is the list of A values in order
                T = []
                for c in range(0, 16):
                    T.append(A[c + 1])
                # if T has the same numbers as L1, then
                #   add one to the count
                if sorted(T) == L1:
                    count += 1
    return count

# Go through each possible S value for 50 <= S <= 55
#   with each possible A7 value using the N function
#   and record the maximum N(S, A7) as Nmax 
Nmax = 0
for S in range(50, 56):
    for A7 in range(0, 17):
        N1 = N(S, A7)
        if N1 > Nmax:
            Nmax = N1
            Smax = S
            A7max = A7

# Display the results
print(Smax, A7max, Nmax)

The full dataset (where N ( S , A 7 ) 0 N(S, A_7) \neq 0 ) is:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
N(51, 6) = 224
N(51, 7) = 280
N(51, 8) = 296
N(51, 9) = 240
N(51, 10) = 424
N(51, 11) = 560
N(51, 12) = 672
N(51, 13) = 560
N(51, 14) = 872
N(51, 15) = 1048
N(51, 16) = 1352
N(52, 4) = 272
N(52, 5) = 128
N(52, 6) = 72
N(52, 7) = 304
N(52, 8) = 232
N(52, 9) = 392
N(52, 10) = 392
N(52, 11) = 608
N(52, 12) = 1264
N(52, 13) = 792
N(52, 14) = 728
N(52, 15) = 1160
N(52, 16) = 1656
N(53, 4) = 232
N(53, 5) = 120
N(53, 6) = 232
N(53, 7) = 448
N(53, 8) = 320
N(53, 9) = 448
N(53, 10) = 800
N(53, 11) = 688
N(53, 12) = 1288
N(53, 13) = 1344
N(53, 14) = 2072
N(53, 15) = 2456
N(53, 16) = 3088
N(54, 7) = 408
N(54, 8) = 248
N(54, 9) = 672
N(54, 10) = 392
N(54, 11) = 624
N(54, 12) = 904
N(54, 13) = 936
N(54, 14) = 840
N(54, 15) = 1448
N(54, 16) = 1624
N(55, 13) = 504
N(55, 14) = 568
N(55, 15) = 336
N(55, 16) = 704

David Vreken - 5 months, 3 weeks ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...