-
Notifications
You must be signed in to change notification settings - Fork 1
/
Euler_Problem-036.b93
57 lines (31 loc) · 1.59 KB
/
Euler_Problem-036.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
v
0 v \< v *2\< >:.55+,\ v
>093194*+**>::>55+*10p:55+%10g+\55+/:#^_$::0>10p:2%10g+\2/:#^_$-!#^_$ v
|:-1 <
v < v \< v *2\< >:.55+,\v
>93194*+**>::55+/>55+*10p:55+%10g+\55+/:#^_$::0>10p:2%10g+\2/:#^_$-!#^_$ v
|:-1 <
>"= ",,>+\:#<_+.@
[10] temp
93194*+** => 999
// Test number for binary palindrome (stack -> inversed stack )
v *2\<
:0>10p:2%10g+\2/:#^_$- @
// enumerate Palindromes
v \<
>93194*+**>::>55+*10p:55+%10g+\55+/:#^_$ v
|-1 <
v < v \<
>93194*+**>::55+/>55+*10p:55+%10g+\55+/:#^_$ v
|-1 <
// generate palindrome not-odd
v \<
:>55+*10p:55+%10g+\55+/:#^_$
// generate palindrome odd
v \<
:55+/>55+*10p:55+%10g+\55+/:#^_$
---------------------------------------
The *trick* here is that we only need to test 1998 numbers. Because there are only so much base10 palindromes:
- The numbers from `1` to `999` mirrored result into to palindromes `11` to `999999`
- The numbers from `1` to `999` mirrored at the last digit result into to palindromes `1` to `99999`
Then we only need to test these numbers whether they are also binary palindromes.