/*
 * Copyright (C) 2014 Pedro Vicente Gómez Sánchez.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.pedrovgs.problem49;

import java.util.List;

/**
 * Given a set of moneys and one amount to change, can you write a method to calculate every
 * possible return change using all possible combinations of moneys minimizing the number of moneys
 * to return?
 *
 * @author Pedro Vicente Gómez Sánchez.
 */
public class CombinationsOfChange {
  public List<List<Integer>> get(int[] moneys, int ammount) {
    return null;
  }
}

@@ -645,16 +645,121 @@
 lem49;%0A%0A
+import com.github.pedrovgs.problem47.ReturnChange;%0Aimport java.util.Arrays;%0Aimport java.util.LinkedList;%0A
 import j
@@ -773,16 +773,16 @@
 l.List;%0A
-
 %0A/**%0A * 
@@ -1072,86 +1072,1465 @@
 e %7B%0A
-  public List%3CList%3CInteger%3E%3E get(int%5B%5D moneys, int ammount) %7B%0A    return null;
+%0A  private final ReturnChange returnChange;%0A%0A  public CombinationsOfChange() %7B%0A    this.returnChange = new ReturnChange();%0A  %7D%0A%0A  /**%0A   * Combination of an iterative and recursive approach to resolve this problem. We are using%0A   * ReturnChange problem to create this algorithm. The complexity order of this algorithm in space%0A   * terms is equals to O(N) where N is the number of possible combinations. In time terms, the%0A   * complexity order is equals to O(N*M) where N is the number of moneys in the array and M the%0A   * complexity order of ReturnChange algorithm.%0A   */%0A  public List%3CList%3CInteger%3E%3E get(int%5B%5D availableChange, int value) %7B%0A    validateInputData(availableChange, value);%0A%0A    List%3CList%3CInteger%3E%3E changeCombinations = new LinkedList%3CList%3CInteger%3E%3E();%0A    for (int i = 0; i %3C availableChange.length; i++) %7B%0A      int%5B%5D availableMoneys = Arrays.copyOfRange(availableChange, 0, availableChange.length - i);%0A      List%3CInteger%3E change = getChange(availableMoneys, value);%0A      changeCombinations.add(change);%0A    %7D%0A    return changeCombinations;%0A  %7D%0A%0A  private List%3CInteger%3E getChange(int%5B%5D availableMoneys, int value) %7B%0A    return returnChange.calculate(availableMoneys, value);%0A  %7D%0A%0A  private void validateInputData(int%5B%5D availableChange, int value) %7B%0A    if (availableChange == null %7C%7C value %3C= 0) %7B%0A      throw new IllegalArgumentException(%0A          %22You can't pass a null array or a value minor or equals to zero as argument.%22);%0A    %7D
 %0A  %7D

Add solution to problem 49