subject

(a) Write a SCHEME function (make-change n den) which outputs a list of change specifications. Namely, a call (make-change 11 (list 25 10 5 1) produces the list
((1 1 1 1 1 1 1 1 1 1 1) (1 1 1 1 1 1 5) (1 5 5) (1 10))
Hints: a helper function (helper n den cur) that takes as input cur, a list of coins given out so far will surely come in handy! Also, the order in which the "options" appear in the top list is immaterial.

(b) While getting the output above is helpful, it is not particularly readable. Indeed, the list (1 1 1 1 1 1 5) that states 6 pennies and 1 nickel could be far more readable as ((6 . 1) (1 . 5)) also stating 6 pennies and 1 nickel. That is, this is a list of pairs telling us how many of each denomination. Thankfully, the former can be translated into the latter by a conversion known as run length encoding that replaces sequences of an identical value by a pair giving the number of repetition of the value.
Write a SCHEME function (rle coins) which, given a list of coins, returns a list of pairs denoting the number of repetitions of each sequence of consecutive values. As a last example, the list
(list 1 1 1 1 1 1 1 5 5 5 5 1 1 1 10 10 10 1 1 25 25 25 25 25 25)
would be encoded as
( (17. 1) (4.5) (3 . 1) (3. 10) (2 . 1) (6. 25) )
Note how the tree sub-sequences of pennies are not collapsed into a single value. Those are kept as separate pairs. Naturally, this function only works for one element of the output from make-change.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:10
Look at the far left lane in the picture. explain what the red car is doing and what it needs to do to travel safely.
Answers: 2
question
Computers and Technology, 22.06.2019 15:20
The north and south regions had very diferent economies in the 1800s.
Answers: 1
question
Computers and Technology, 23.06.2019 02:30
What is the power dissipated by a resistor with a current of 0.02 a and a resistance of 1,000 ? a. 200 w b. 20 w c. 0.4 w d. 4 w
Answers: 1
question
Computers and Technology, 23.06.2019 09:10
Effective character encoding requires standardized code. compatible browsers. common languages. identical operating systems.
Answers: 1
You know the right answer?
(a) Write a SCHEME function (make-change n den) which outputs a list of change specifications. Namel...
Questions
question
Mathematics, 13.11.2020 19:20
question
Mathematics, 13.11.2020 19:20
question
Social Studies, 13.11.2020 19:20
question
Mathematics, 13.11.2020 19:20
question
Social Studies, 13.11.2020 19:20
question
Chemistry, 13.11.2020 19:20
Questions on the website: 13722367