Download benchmarks/quixbugs/java/POSSIBLE_CHANGE.java from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/quixbugs/java/POSSIBLE_CHANGE.java
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/benchmarks/quixbugs/java/POSSIBLE_CHANGE.java
-
curl -L -o POSSIBLE_CHANGE.java https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/benchmarks/quixbugs/java/POSSIBLE_CHANGE.java
1.11 kB
| import java.util.*; | |
| /** | |
| * Making Change | |
| * change | |
| * | |
| * | |
| * Input: | |
| * coins: A list of positive ints representing coin denominations | |
| * total: An int value to make change for | |
| * | |
| * Output: | |
| * The number of distinct ways to make change adding up to total using only coins of the given values. | |
| * For example, there are exactly four distinct ways to make change for the value 11 using coins [1, 5, 10, 25]: | |
| * 1. {1: 11, 5: 0, 10: 0, 25: 0} | |
| * 2. {1: 6, 5: 1, 10: 0, 25: 0} | |
| * 3. {1: 1, 5: 2, 10: 0, 25: 0} | |
| * 4. {1: 1, 5: 0, 10: 1, 25: 0} | |
| * | |
| * Example: | |
| * >>> possible_change([1, 5, 10, 25], 11) | |
| * 4 | |
| * | |
| * @author derricklin | |
| */ | |
| public class POSSIBLE_CHANGE { | |
| public static int possible_change(int[] coins, int total) { | |
| if (total == 0) { | |
| return 1; | |
| } | |
| if (total < 0 ||coins.length==0) { | |
| return 0; | |
| } | |
| int first = coins[0]; | |
| int[] rest = Arrays.copyOfRange(coins, 1, coins.length); | |
| return possible_change(coins, total-first) + possible_change(rest, total); | |
| } | |
| } | |