Answered step by step
Verified Expert Solution
Question
1 Approved Answer
[Ocaml Language] ****Note: won is a currency Please solve this question by completing (*TODO*) in this code: (* problem 8*) let change : int list
[Ocaml Language]
****Note: won is a currency
Please solve this question by completing (*TODO*) in this code:
(* problem 8*)
let change : int list -> int -> int = fun coins amount -> (*TODO*)Problem 8 (30pts) Consider the problem of counting the number of different in-changes of a given amount of money. For exan three types of coins (1, 5, 10 wons) are available, there are four different ways of making changes of 12 won 12 won = 10 won * 1 + 1 won * 2 12 won = 5 won * 2 + 1 won * 2 12 won = 5 won * 1 1 won * 7 12 won1 won * 12 Write a function change: int list -> int -> int that takes a list of the denominations of the coins and an amount of money to change, and returns the number of ways to make changes. For example, change change [1;5;10] 12 - 4 [1 ; 5 ; 10, 25; 50] 100-292 Note that special cases are defined as follows: When the amount is 0, we count that as 1 way to make change: e.g., change [1;5;10] 01 When the amount is less than 0, we count that as 0 ways to make change: e. change [1;5:10] -5-0 When the number of coin kinds is 0, we count that as 0 ways to make change: e.g., change [] 10 - 0 Problem 8 (30pts) Consider the problem of counting the number of different in-changes of a given amount of money. For exan three types of coins (1, 5, 10 wons) are available, there are four different ways of making changes of 12 won 12 won = 10 won * 1 + 1 won * 2 12 won = 5 won * 2 + 1 won * 2 12 won = 5 won * 1 1 won * 7 12 won1 won * 12 Write a function change: int list -> int -> int that takes a list of the denominations of the coins and an amount of money to change, and returns the number of ways to make changes. For example, change change [1;5;10] 12 - 4 [1 ; 5 ; 10, 25; 50] 100-292 Note that special cases are defined as follows: When the amount is 0, we count that as 1 way to make change: e.g., change [1;5;10] 01 When the amount is less than 0, we count that as 0 ways to make change: e. change [1;5:10] -5-0 When the number of coin kinds is 0, we count that as 0 ways to make change: e.g., change [] 10 - 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started