I have a list of goods. The quantity of goods is a multiple of 3 and lies in the range from 3 to 15. I enter the number of goods and put them a rating from 1 to 10. Then, based on the rating, I have to put down the price of $ 1, $ 2 or $ 3, so that the number of money was the same.

I give an example. 6 products with a rating of [1 6 8 2 9 3] A table with money will be like this [1 $ 2 $ 3 $ 1 $ 3 $ 2 $]

What algorithm to implement this dependence?

  • one
    What does "based on rating" mean? What is the principle of deciding which rating corresponds to which price? - Xander
  • I decided. did by this principle. I make a list clone and get a sorted list for it. [1 2 3 3 8 9] accordingly to him I create a hashmap [(1 | 1 $) (2 | 1 $) (3 | 2 $) (3 | 2 $) (8 | 3 $) (9 | 3 $) ] and then in the loop to match the old list - and the value from the map to it. - Padawan

0