07. Cake Ingredients - (Недостатъчно време)
Това е решението ми на задачата: https://pastebin.com/nzwygZam
Но Judge ми казва , че "задачата може да се реши по бързо"
Позволено време: 0.100 sec.
Позволена памет: 16.00 MB
Моят резултат:
Памет: 10.48 MB
Време: 0.152 s
Бихте ли ми дали "по-бърз" вариант за решаване на задачата? :)
Edit:
Ето го и условието:
Problem 1.Cake Ingredients
Write a baking program, which takes as an input ingredients and writes a message when the ingredient is in the system. For every given ingredient, you should write: “Adding ingredient {name of the ingredient}.”. When you receive the command “Bake!” from the console you should stop the program and write “Preparing cake with {number of given ingredients} ingredients.”.
Input
You will receive ingredients until the command “Bake!” is given.
Output
For every given ingredient write on a new line the message: “Adding ingredient {name of the ingredient}.”. At the end print the message: “Preparing cake with {number of given ingredients} ingredients.”.
Constraints
- You will receive maximum 20 ingredients.
- Every ingredient will be between 1 and 50 characters.
Examples
Input |
Output |
Flour Bread Sugar Butter Bake! |
Adding ingredient Flour. Adding ingredient Bread. Adding ingredient Sugar. Adding ingredient Butter. Preparing cake with 4 ingredients. |
Edit 2:
Видях си грешката. Аз пиша Bake a не Bake!
Ето и моето решение