<commit_before>/**********************************************************************
 *  Problem : Coin Change                                             *
 *                                                                    *
 *  Prompt: US Currency has coins in circulation with the             *
 *          following value in cents: [1, 5, 10, 25, 50, 100]         *
 *                                                                    *
 *          Given a value, find how many unique ways to make change   *
 *          given the coin values in circulation.                     *
 *                                                                    *
 *  Input:  An integer N (value from which to make change)            *
 *  Output: An integer (number of unique ways to make change)         *
 *                                                                    *
 *  Time Complexity: NA                                               *
 *  Auxiliary Space Complexity: NA                                    *
 *                                                                    *
 *  Example: input = 11                                               *
 *           output = 4 ([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],           *
 *                       [5, 1, 1, 1, 1, 1, 1],                       *
 *                       [5, 5, 1],                                   *
 *                       [10, 1])                                     *
 *                                                                    *
 *  Challenge Mode: Solve coin change with you solution having:       *
 *                  Time Complexity: O(nm)                            *
 *                  Auxiliary Space Complexity: O(n)                  *
 *  Hint: www.geeksforgeeks.org/dynamic-programming-set-7-coin-change *
 **********************************************************************/<commit_msg>add one solution, 1 working on it<commit_after>/**********************************************************************
 *  Problem : Coin Change                                             *
 *                                                                    *
 *  Prompt: US Currency has coins in circulation with the             *
 *          following value in cents: [1, 5, 10, 25, 50, 100]         *
 *                                                                    *
 *          Given a value, find how many unique ways to make change   *
 *          given the coin values in circulation.                     *
 *                                                                    *
 *  Input:  An integer N (value from which to make change)            *
 *  Output: An integer (number of unique ways to make change)         *
 *                                                                    *
 *  Time Complexity: NA                                               *
 *  Auxiliary Space Complexity: NA                                    *
 *                                                                    *
 *  Example: input = 11                                               *
 *           output = 4 ([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],           *
 *                       [5, 1, 1, 1, 1, 1, 1],                       *
 *                       [5, 5, 1],                                   *
 *                       [10, 1])                                     *
 *                                                                    *
 *  Challenge Mode: Solve coin change with you solution having:       *
 *                  Time Complexity: O(nm)                            *
 *                  Auxiliary Space Complexity: O(n)                  *
 *  Hint: www.geeksforgeeks.org/dynamic-programming-set-7-coin-change *
 **********************************************************************/


function coinChange(n){
  var CURRENCY = [1, 5, 10, 25, 50, 100];
  var result = [];
  function traverse(rem, arr){
    if(rem === 0){
      result.push(arr);
      return;
    }
    for(var i = 0; i < CURRENCY.length; i++){
      var temp = rem - CURRENCY[i]; // 10
      if (temp >= 0 ){ // rem = 11
        arr.push(CURRENCY[i]); // [1]
        traverse(temp, arr); // traverse(10, [1])
      }
    }
  }
  traverse(n, [])
  return result
}

function coinChange(total, coins){
  if(total === 0){
    return 1;
  }
  else if(total < 0){
    return 0;
  }
  var ways = 0;
  for (var i = 0; i < coins.length; i++){
    avail = coins.slice(i);
    ways += coinChange(total-coins[i], avail)
  }
  return ways.length;
}
{'fraction_non_alphanumeric': 0.14657262508265373, 'fraction_numerical': 0.023583865990742782, 'mean_word_length': 0.8130243707550939, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6628614', 'n_tokens_mistral': 1081, 'n_tokens_neox': 939, 'n_words': 305}