## Class PE0031

• All Implemented Interfaces:
`Solvable`

```public class PE0031
extends Problem```
Solution for problem 31 "Coin sums" completed on Sat, 19 Dec 2015, 22:30.
Since:
12.12.2015 00:23:18
Author:
Nico Danneberg
Problem @ Project Euler, Solution @ Ni-Da-Net
• ### Field Summary

Fields
Modifier and Type Field Description
`private int[]` `coins`
Stores for every coin the count to fill 200 pence.
`private int` `count`
Counts the number of found combinations.
`private int[]` `used`
Stores for every coin how many are used in a combination.
• ### Fields inherited from class net.n1da.dev.euler.core.Problem

`number, title`
• ### Method Summary

Modifier and Type Method Description
`private void` `check​(int level)`
Here the algorithm is implemented by checking every combination of coins.
`private int` `getSum()`
Calculates the sum of the combination in `used` array.
`void` `prepare()`
Initializes the `coins` and `used` arrays, and the `count` with 0.
`java.lang.String` `solve()`
This problem is solved by a recursive call of the `check(int)` method.
• ### Methods inherited from class net.n1da.dev.euler.core.Problem

`finish, getResult, getRuntime, toString`
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### coins

`private int[] coins`
Stores for every coin the count to fill 200 pence.
• #### used

`private int[] used`
Stores for every coin how many are used in a combination.
• #### count

`private int count`
Counts the number of found combinations.
• ### Method Detail

• #### prepare

`public void prepare()`
Initializes the `coins` and `used` arrays, and the `count` with 0.
Specified by:
`prepare` in interface `Solvable`
Overrides:
`prepare` in class `Problem`
• #### solve

`public java.lang.String solve()`
This problem is solved by a recursive call of the `check(int)` method. Here this method is called and the final `count` is returned.
Returns:
the count of all found combinations
• #### check

`private void check​(int level)`
Here the algorithm is implemented by checking every combination of coins. If the `sum` of the current combination is less than 200 this method is called recursively for the next smaller coin.
Parameters:
`level` - the position in `coins` array
• #### getSum

`private int getSum()`
Calculates the sum of the combination in `used` array.
Returns:
the sum of all products of elements in `used` and #coins array