Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

RuslanKostov avatar RuslanKostov 1 Точки

04. Honey

Здравейте,

бих искал да помоля за малко помощ относно зада: 04. Honey от Stacks, Queues, Tuples and Sets - Exercise,  'judj" ми дава ''run time error" 85/100:

не мога да разбера какъв е проблема, подробно гледах да спазя всички условия от задачата, но явно нещо не правя както трябва!

Благодаря предварително!

https://pastebin.com/XWWu6xrz

Условие:

  1. Honey

We think the process of making honey is amazing! Let's learn more about how bees make honey.

Worker-bees collect nectar. When a worker-bee has found enough nectar, she returns to the hive to drop off the load and pass the nectar to waiting bees so they can really start the honey-making process

You will receive 3 sequences:

  • a sequence of integers, representing working bees
  • a sequence of integers, representing nectar
  • a sequence of symbols"+", "-", "*" or "/", representing the honey-making process.

Your task is to check if the bee has collected enough nectar to return to the hive and keep track of the total honey waiting for bees made with the collected nectar.

Step one: check if a bee has collected enough nectar. You should take the first bee and try to match it with the last nectar:

  • If the nectar value is more or equal to the value of the bee, it is considered collected, and the bee returns to the hive to drop off the load (step two).
  • If the nectar value is less than the value of the bee, you should remove the nectar and try to match the bee with the next nectar's value until the bee collects enough nectar.

Step two: When a bee successfully collects nectar, she returns to the hive, and you should calculate the honey made. Take the first symbol in the sequence of symbols ("+", "-", "*" or "/") and make the corresponding calculation:

"{matched_bee} {symbol} {matched_nectar}"

The result represents the honey that is made from the passed nectar. The calculation should always return the absolute value of the result. After the calculation, remove the bee, the nectar, and the symbol.

  • If the symbol is "/" and the nectar’s value is 0 (zero), skip the calculation and remove the bee, the nectar, and the symbol.

Stop making honey when you are out of bees or nectar.

Input

  • On the first line, you will be given the values of bees - integers, separated by a single space
  • On the second line, you will be given the nectar's values - integers, separated by a single space
  • On the third line, you will be given symbols - "+", "-", "*" or "/", separated by a single space

Output

  • On the first line - print the total honey made:
    • "Total honey made: {total honey}"
  • On the next two lines print the bees or the nectar that are left, if there are any, otherwise skip the line:
    • "Bees left: {bee1}, {bee2}, … {beeN}"
    • "Nectar left: {nectar1}, {nectar2}, … {nectarN}"

Constraints

  • All the bee's values will be integers in the range [0, 150]
  • Nectar's values will be integers in the range [0, 150]
  • There always will be enough symbols in the sequence of symbols

Examples

Input

Output

Comment

20 62 99 35 0 150

120 60 10 1 70 10

+ - + + / * - - /

 

Total honey made: 148

Bees left: 99, 35, 0, 150

First, compare 20 to 10. 20 is bigger than 10, so remove 10. Then compare 20 to 70. 20 is less than 70, so the bee could return to the hive. Honey made with given nectar is 20 + 70 = 90.

Next, compare 62 to 1. 62 is bigger than 1, so remove 1. Compare 62 to 10. 62 is bigger than 10, so remove 10. Compare 62 to 60. 62 is bigger than 60, so remove 60. Compare 62 to 120. 60 is less than 120, so the bee could return to the hive. Honey made with given nectar is 62 - 120 = (-58). (-58) is negative, and its absolute value is 58, so the calculation result is 58.

Total honey made: 90 + 58 = 148.

Print desired text.

30

15 9 5 150 8

* + + * -

Total honey made: 4500

Nectar left: 15, 9, 5

 

Тагове:
0
Module: Python Advanced
icowwww avatar icowwww 2673 Точки

Здравей,

Когато символа е / и нектара е 0 трябва да пропуснеш пчелата, нектара и символа.

При теб обаче си пропуснал един символ, след което пропускаш още един заедно с пчелата и нектара и накрая правиш пак сметката със следващата пчела, следващия нектар и същия символ /

В това не намирам логиката.

Трябва да са два случая:

При / и стойност 0 да пропуснеш заедно със символа и пчелата и нектара.

При всичко останало да се изпълни сметката

https://pastebin.com/hVtNDxp9

0
RuslanKostov avatar RuslanKostov 1 Точки

Благодаря за помощта,

явно вече съм бил много уморен за да пропусна, нещо толкова очевидно,

но така се получава, като трябва да наваксваш много материал.

Благодаря отново!

Успех и здраве!

0
Phroodession avatar Phroodession 2 Точки

I've been going crazy lately playing challenges in geometry dash world. It's really not that simple and stimulates my aggressiveness.

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.