Package net.n1da.dev.euler
Class PE0043
- java.lang.Object
-
- net.n1da.dev.euler.core.Problem
-
- net.n1da.dev.euler.PE0043
-
- All Implemented Interfaces:
Solvable
public class PE0043 extends Problem
Solution for problem 43 "Sub-string divisibility" completed on Thu, 19 May 2016, 20:14.- Since:
- 12.05.2016 22:33:44
- Author:
- Nico Danneberg
- See Also:
- Problem @ Project Euler, Solution @ Ni-Da-Net
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList<java.lang.Integer[]>
candidates
Storage for all possible numbers.
-
Method Summary
Modifier and Type Method Description private boolean
check(java.lang.Integer[] data)
Checks if there are only single digits within the given array.void
prepare()
It just initializes the list ofcandidates
.java.lang.String
solve()
Runs over all wanted modulos and fills thecandidates
from right to left.-
Methods inherited from class net.n1da.dev.euler.core.Problem
finish, getResult, getRuntime, toString
-
-
-
-
Method Detail
-
prepare
public void prepare()
It just initializes the list ofcandidates
.
-
solve
public java.lang.String solve()
Runs over all wanted modulos and fills thecandidates
from right to left. Allcandidates
arechecked
if the have only single digits. Due to this way the number ofcandidates
shrinks with every modulo until the finalcandidates
are found. Finally thecandidates
areconverted into a large number
and summed to the final result.- Returns:
- the sum of all final
candidates
with the wanted property - See Also:
LargeNumber
-
check
private boolean check(java.lang.Integer[] data)
Checks if there are only single digits within the given array. Only number -1 can be more than once.- Parameters:
data
- the array to be checked- Returns:
- false if at least one number exists more that once - beside number -1
-
-