-
Notifications
You must be signed in to change notification settings - Fork 1
/
Euler_Problem-043 (pen-and-paper).b93
111 lines (73 loc) · 2.32 KB
/
Euler_Problem-043 (pen-and-paper).b93
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
095989598919597909794 *+*+*+*+*+*+*+*+*+*+ . @
We can rule out a lot of combinations by simply looking at our rules. I divided my thought processes into steps:
**Step 1:**
- d_1 != d_2 != d_3 != d_4 != d_5 != d_6 != d_7 != d_8 != d_9 *(palindromic)*
- d_1 is not `0`
- d_234 is divisible by 2 => d_4 is even
- d_345 is divisible by 3 => `(d_3 + d_4 + d_5) % 3 = 0`
- d_456 is divisible by 5 => d_6 is `0` or `5`
- d_567 is divisible by 7
- d_678 is divisible by 11
- d_789 is divisible by 13
- d_89A is divisible by 17
**Step 2:**
if d_6 is `0` then d_678 starts with a `0`, and because d_678 is divisible by 11: `d_7 == d_8`. This conflicts with our palindrome rule.
Therefore d_6 = `5`.
**Step 3:**
d_6 is `5` and d_678 is divisible by 11. There are only 8 possibilities for d_678:
~~~
506, 517, 528, 539, 561, 572, 583, 594
~~~
**Step 4:**
d_789 is divisible by 13, together with the possibilities for d_78 there are only 4 possibilities left for d_6789:
~~~
5286, 5390, 5728, 5832
~~~
**Step 5:**
d_89A is divisible by 17, then we can again - together with the previous result - look at the possibilities for d_6789A:
~~~
52867, 53901, 57289
~~~
**Step 6:**
d_567 is divisible by 7, d_6 is `5` and d_7 is `2`, `3` or `7`. There are now only 2 possible values for d_56789A left:
~~~
357289, 952867
~~~
**Step 7:**
Both values contain `2`, `5`, `7`, `8`, `9`, so d_1 - d_4 can't be any of those
**Step 8:**
d_345 is divisible by 3. d_5 is `3 or 9` and d_4 is even and the possible digits are `0`, `1`, `2`, `3`, `4`, `6` and `9` (`9` only for d_5).
The possible values for d_345 are therefore:
~~~
063, 069, 309, 603, 609
~~~
And so the possible values for d_3456789A:
~~~
06357289, 06952867, 30952867, 60357289, 60952867
~~~
number 2 and 5 are not palindromic, so the numbers left are:
~~~
06357289, 30952867, 60357289
~~~
**Step 9:**
The only numbers left are now `1` and `4` and there are no rules left to consider.
We can now list the resulting numbers by using the 3 numbers from before and every combination of `1` and `4`:
- 14 06357289
- 41 06357289
----
- 14 30952867
- 41 30952867
----
- 14 60357289
- 41 60357289
**Step 10:**
The final step is now to calculate the sum of these numbers:
~~~
1406357289
+ 4106357289
+ 1430952867
+ 4130952867
+ 1460357289
+ 4160357289
= 16695334890
~~~