+ 1

how to solve 'halloween candy" challenge ???

actualy i solved all of the challenge except this easy halloween candy challenge https://code.sololearn.com/cAiZqr3lezxz/?ref=app

28th Aug 2020, 5:35 PM
Jitendra
Jitendra - avatar
16 ответов
+ 7
import math print(math.ceil(200/int(input())))
28th Aug 2020, 6:51 PM
Namit Jain
Namit Jain - avatar
+ 6
Steven M It's same! Difference: your is a bit more tedious than mine No need of defining extra variable 2*100 = 200
28th Aug 2020, 6:54 PM
Namit Jain
Namit Jain - avatar
+ 4
Steven M if you visit house, u will get one would be candy, two would be dollars, and one would be a toothbrush.. Here u need to find percentage of getting dollar bills. So it is (2/number of house's)*100 Or 200/number of house's
28th Aug 2020, 6:09 PM
Ajith
Ajith - avatar
+ 3
import math print(math.ceil((2/int(input()))*100))
28th Aug 2020, 5:49 PM
Ajith
Ajith - avatar
+ 2
Steven M he is trying to round up the answer. In Python u can use ceil method to do this
28th Aug 2020, 6:13 PM
Ajith
Ajith - avatar
28th Aug 2020, 6:13 PM
Ajith
Ajith - avatar
+ 1
Bro can i get some tips for solving challanges I didn't completed any I want it in python
28th Aug 2020, 5:36 PM
🍎Mi_ra_go
🍎Mi_ra_go - avatar
+ 1
Gotcha, I used the ceil method to solve this as well, just trying to understand, thanks 👍👍
28th Aug 2020, 6:14 PM
Steven M
Steven M - avatar
+ 1
Steven M welcome 👍🙃
28th Aug 2020, 6:15 PM
Ajith
Ajith - avatar
+ 1
Mine looks slightly different... import math homes=int(input()) print(math.ceil(2/homes*100)) same result 👍👍
28th Aug 2020, 6:53 PM
Steven M
Steven M - avatar
0
start with easy challenges .
28th Aug 2020, 5:40 PM
Jitendra
Jitendra - avatar
0
Have you attempted it? What are your thoughts? How do you think you can solve this?
28th Aug 2020, 5:41 PM
Steven M
Steven M - avatar
0
h = int(input()) a = 200/h b = 200//h if (200/h) >= b+0.5 : print(int(b+1)) else : print(int(b))
28th Aug 2020, 5:45 PM
Jitendra
Jitendra - avatar
0
Ajith has you covered, but I do have some questions about your method. Why 200 and all the other variables? The problem doesn't mention them...
28th Aug 2020, 5:54 PM
Steven M
Steven M - avatar
0
I see he combined the 2 operations 👍, but why the +1 and the +0.5
28th Aug 2020, 6:11 PM
Steven M
Steven M - avatar
0
from math import ceil houses = int(input()) prc = ceil((2 * 100) / houses) print(prc)
29th Aug 2020, 4:40 AM
Jonathan Alvarado
Jonathan Alvarado - avatar