Created
June 23, 2021 12:35
-
-
Save Kiandisor/0d6ff8532e1a09e2623d5f2181b58fda to your computer and use it in GitHub Desktop.
[2021-06-07] Challenge #393 [Easy] Making change - C++ 20 Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[nodiscard]] /*constexpr*/ int make_change(int current_money) { | |
int change_amount {0}; | |
auto generate_change {[¤t_money,&change_amount](int bill_size) { | |
change_amount += current_money/bill_size; | |
current_money %= bill_size; | |
}}; | |
std::ranges::for_each(std::array {500,100,25,10,5,1},generate_change); | |
return change_amount+=current_money; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment