I did something wrong or its the program beacause it inputs 18 10 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I did something wrong or its the program beacause it inputs 18 10

Carrot Cake You are packing boxes of carrots for a farm co-op, and you are supposed to evenly distribute all of the carrots that you have into the boxes. The total number of carrots in each box doesn't matter as long as you distribute them evenly, and there are not enough leftover to put another carrot in each box. Anything that you have left over, you get to keep. You need 7 carrots to make the cake the way that you want to. Task: Determine if you will have enough leftover carrots to make your cake. Input Format: Two integer values. The first represents the number of carrots that you start with, and the second is the number of boxes that need to be packed into. Output Format: A string that says 'Cake Time' if you have enough, or that says 'I need to buy X more' where X is the extra amount you need for your cake. Sample Input: 100 10 Sample Output: I need to buy 7 more https://code.sololearn.com/cWMBPxgeuKBJ/?ref=app

3rd Sep 2022, 11:58 AM
Costy Game
Costy Game - avatar
3 Answers
0
Is that full description? Where you found this task? description is missing something.... I guess what if 7-a is negative value? Try ( 7-a > 0 ? 7-a : 7 - ( a-7) ) instead of (7-a)
3rd Sep 2022, 12:28 PM
Jayakrishna 🇮🇳
0
// Try it if(a>=7){
3rd Sep 2022, 1:34 PM
SoloProg
SoloProg - avatar
0
My solution in python number_of_carrots = int(input()) number_of_boxes = int (input ()) y = number_of_carrots % number_of_boxes x= 7- y if x > 0: print (f"I need to buy {x} more") else: print("Cake Time")
6th May 2023, 6:27 AM
Oussama Kadimallah
Oussama Kadimallah - avatar