ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
CoinChange.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*--------------------------- File CoinChange.h ----------------------------*/
3
/*--------------------------------------------------------------------------*/
27
/*--------------------------------------------------------------------------*/
28
/*----------------------------- DEFINITIONS --------------------------------*/
29
/*--------------------------------------------------------------------------*/
30
31
#ifndef __ADS_CoinChange
32
#define __ADS_CoinChange
33
/* self-identification: #endif constant */
34
35
/*--------------------------------------------------------------------------*/
36
/*------------------------------ INCLUDES ----------------------------------*/
37
/*--------------------------------------------------------------------------*/
38
39
#include "
ADS/Contract.h
"
40
41
#include <algorithm>
42
#include <cstddef>
43
#include <limits>
44
#include <numeric>
45
#include <optional>
46
#include <vector>
47
48
/*--------------------------------------------------------------------------*/
49
/*--------------------------- NAMESPACE ------------------------------------*/
50
/*--------------------------------------------------------------------------*/
51
52
namespace
ADS
53
{
54
74
inline
std::optional< std::vector< long > >
75
greedyChange
( std::vector< long > coins ,
long
c );
76
96
inline
std::optional< long >
optimalChange
(
const
std::vector< long > & coins ,
97
long
c );
98
99
/*--------------------------------------------------------------------------*/
100
101
}
// end( namespace ADS )
102
103
/*--------------------------------------------------------------------------*/
104
/*-------------------------- IMPLEMENTATION --------------------------------*/
105
/*--------------------------------------------------------------------------*/
106
107
#include "ADS/optimization/impl/CoinChange.tpp"
108
109
/*--------------------------------------------------------------------------*/
110
111
#endif
/* CoinChange.h included */
112
113
/*--------------------------------------------------------------------------*/
114
/*------------------------- End File CoinChange.h --------------------------*/
115
/*--------------------------------------------------------------------------*/
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
ADS::greedyChange
std::optional< std::vector< long > > greedyChange(std::vector< long > coins, long c)
the coins taken by the greedy choice, the coins given in any order; nothing if it cannot pay
ADS::optimalChange
std::optional< long > optimalChange(const std::vector< long > &coins, long c)
the fewest coins that pay , nothing if none
ADS
Definition
ADT.h:96
ADS
optimization
CoinChange.h
Generated by
1.17.0