Професионална програма
EvgeniJD avatar EvgeniJD 35 Точки

Cappy Juice JS

Някой би ли ми помогнал с проблема ми при тази задача. Judge ми дава 20/100 и не мога да рабера как да го придумам да ми даде 100/100.

Решението ми: https://pastebin.com/WHY1YPPu


Cappy Juice

You will be given different juices, as strings. You will also receive quantity as a number. If you receive a juice, you already have, you must sum the current quantity of that juice, with the given one. When a juice reaches 1000 quantity, it produces a bottle. You must store all produced bottles and you must print them at the end.

Note: 1000 quantity of juice is one bottle. If you happen to have more than 1000, you must make as much bottles as you can, and store what is left from the juice.

Example: You have 2643 quantity of Orange Juice – this is 2 bottles of Orange Juice and 643 quantity left.


The input comes as array of strings. Each element holds data about a juice and quantity in the following format:

“{juiceName} => {juiceQuantity}”



The output is the produced bottles. The bottles are to be printed in order of obtaining the bottles. Check the second example bellow - even though we receive the Kiwi juice first, we don’t form a bottle of Kiwi juice until the 4th line, at which point we have already create Pear and Watermelon juice bottles, thus the Kiwi bottles appear last in the output.





['Orange => 2000',

'Peach => 1432',

'Banana => 450',

'Peach => 600',

'Strawberry => 549']

Orange => 2

Peach => 2

['Kiwi => 234',

'Pear => 2345',

'Watermelon => 3456',

'Kiwi => 4567',

'Pear => 5678',

'Watermelon => 6789']

Pear => 8

Watermelon => 10

Kiwi => 4


JavaScript Fundamentals 04/06/2020 01:07:04
MartinBG avatar MartinBG 3972 Точки
Best Answer

Не отчитате случаите, когао количеството сок е равно точно на 1000 мл.


Ред №13:

if (acc[juice] > 1000) {

if (acc[juice] >= 1000) {

EvgeniJD avatar EvgeniJD 35 Точки

Благодаря Ви! Явно 80% от тестовете са с граничен случай 1000. Оправих го на >= 1000 и вече съм на 100/100.