ADS
Algorithms and Data Structures
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
52namespace ADS
53{
54
74inline std::optional< std::vector< long > >
75greedyChange( std::vector< long > coins , long c );
76
96inline 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/*--------------------------------------------------------------------------*/
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
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
std::optional< long > optimalChange(const std::vector< long > &coins, long c)
the fewest coins that pay , nothing if none
Definition ADT.h:96