-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEuler_Problem-052.b93
41 lines (27 loc) · 1.16 KB
/
Euler_Problem-052.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
55+>v>v>5+/>::103p55+*>55+/ :#v_$212pv
XX :6/5 > ::103p55+*^p30*g30+2%+55:< :
XX 0:1: v$_v#!: /+55<*+55p311* <g21 <
XX 1p1p 1 >:55+%2+13g*13p^ >:12g^
>^>^>^ >3g03g- #v_12g1+:12p7-|
^*+55$_^#!`\g11:+1$< @$$.<
[0,1] base
[1,1] max
[0,2] sum tmp
[1,2] multiplier
[0,3] digitsum base
[1,3] digitsum mult
GetDigitSum
103p55+*>55+/ :#v_$03g
^p30*g30+2%+55:<
Is 6Perm Family
:003p55+*>55+/ :#v_$ 212v
^p30+g30+2%+55:< p
v$_v#!: /+55<*+55p310 *g21:<
1 >:55+%2+13g+13p^
>3g03g-#v_12g1+:12p7- #^_.@
---------------------------------------
To be a permutation all six numbers have to have the same digit count. So `digitcount(x) == digitcount(x*6)`.
This for each number of digits only given for the numbers from `10^n` to `10/6 * 10^n`.
We perform the permutation check with an modified version of the algorithm used in problem-49 *(product of all digits plus two)*.
But we generalise the code to work with every number of digits.
And because we greatly limited the amount of numbers to search and the permutation test is pretty fast this is all we need to do (except run the code).