Computers and Technology

(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.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 18:20, dinosaur10
Geneva’s manager would like to see some additional information to make sales decisions. enter a formula in cell j4 using the if function to it whether or not the item beaded earrings should go on sale. it will go on sale if its current sales rank (in cell g4) is 8th or lower. (hint: if the cell value is greater than or equal to 8, it will go on sale.)if this condition is true, the item will go on sale. (hint: the if_true value should be “yes”.)if this condition is false, the item doesn’t need to go on sale. (hint: the if_false value should be “-”.)copy the formula created in cell j4 to the range j5: j14
Answers: 2
image
Computers and Technology, 22.06.2019 09:40, Tyrant4life
It is vital to research each of the services you plan to disable before implementing any change, especially on critical machines such as the: a. servers in the test environment. b. domain controller and other infrastructure servers. c. desktops that have previously been attacked. d. desktops used by upper-level management.
Answers: 2
image
Computers and Technology, 23.06.2019 04:20, milkshakegrande101
4. a1. vince owns a television repair shop that is insured undera commercial package policy. the policy includes thebuilding and personal property coverage form and thecauses-of-loss broad form. the declarations page indicatesthat coverage applies to both the building and the namedinsured's business property. explain whether or not thefollowing losses would be covered under his policy. a. a fire occurs on the premises, and the building isbadly damaged. b. a burglar steals some money and securities from anunlocked safe. c. a business computer is damaged by vandals whobreak into the shop after business hours. d. a tornado touches down near the store. several tel-evision sets of customers in the shop for repair aredamaged in the storm. til
Answers: 2
image
Computers and Technology, 23.06.2019 07:00, MissSmartyPants88
To produce a starlight effect in her photograph, lina should choose the filter for her camera.
Answers: 1
Do you know the correct answer?
(a) Write a SCHEME function (make-change n den) which outputs a list of change specifications. Namel...

Questions in other subjects:

Konu
Mathematics, 15.12.2020 16:40
Konu
Social Studies, 15.12.2020 16:40
Konu
Mathematics, 15.12.2020 16:40