July 2018 little math problem
|
07-29-2018, 10:27 PM
Post: #25
|
|||
|
|||
RE: July 2018 little math problem
Slight changes to my posted Python code (post 23) dramatically reduce checks down to 17 cases
Only patch is to change the loop range: s range = [13, 14] c range = range(max(1, ceg-8-9), min(9, ceg//2)) g range = range(c+1, min(10, 10 - s + ceg)) s range is reduced by taking advantage of 10-Complement Symmetry c range is reduce because of this: c + e + g = ceg min(c) = ceg - max(e + g) = ceg - 8 - 9 max(c) = ceg - min(e) - min(g) = ceg - 1 - (max(c) + 1) max(c) * 2 = ceg - 2 max(c) < floor(ceg / 2) g range is reduced because d = s - c - e = (s - ceg) + g Since g is increasing inside loop, d is also increasing, remove invalid d, we get: max(d) = (s - ceg) + max(g) < 10 max(g) < 10 - s + ceg With above ranges, these are the only cases checked: #1: 1 8 4 7 2 => [3, 9] 1 8 4 7 2 [5, 6] #2: 1 9 3 7 3 #3: 2 9 2 8 3 #4: 1 5 8 4 2 => [6, 7] 1 5 8 4 2 [3, 9] #5: 1 6 7 4 3 => [5, 8] 1 6 7 4 3 [2, 9] #6: 1 7 6 4 4 #7: 1 8 5 4 5 #8: 1 9 4 4 6 #9: 2 6 6 5 3 #10: 2 7 5 5 4 #11: 2 8 4 5 5 #12: 2 9 3 5 6 => [4, 8] 2 9 3 5 6 [1, 7] #13: 3 7 4 6 4 #14: 3 8 3 6 5 #15: 3 9 2 6 6 #16: 4 8 2 7 5 => [1, 9] 4 8 2 7 5 [3, 6] #17: 4 9 1 7 6 => [2, 8] 4 9 1 7 6 [3, 5] 16X Symmetries: head swap, tail swap, reversing digits, 10-complement Solutions = 6 primary solutions * 16 = 96 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)