+ 2
Please help me to solve this code
This is a code coach problem help me https://www.sololearn.com/coach/38?ref=app Question: Duct Tape +10 XP You want to completely cover a flat door on both sides with duct tape. You need to know how many rolls of duct tape to buy when you go to the store. Task: Given the height and width of the door, determine how many rolls of duct tape you will need (a roll of duct tape is 60 feet long and 2 inches wide and there are 12 inches in each foot). Don't forget both sides of the door! Input Format: Two integers that represent the height and width of the door. Output Format: An integer that represents the total rolls of duct tape that you need to buy. Sample Input: 7 4 Sample Output: 6
12 Answers
+ 2
SOUPTIK NATH
We can not use floor as floor(a) give us nearest integer less then or equal to a.
So if our answer is 5.6 then floor give us 5 .
As in the given test case (height=7,width=4) the final answer is 5.6.
1.Now if we use floor it give us 5 and neglect .6 that are insufficient number of tape rolls.
2.If we use ceil it give us 6 then
.4(6-5.6) left but our purpose of taping the door fullfill.
So,in short using floor give us less number of tape rolls than required in some cases.
+ 1
import math
d_n = 720
s_n = 2
d_x = int(input())*12
s_x = int(input())*12
S = (d_x*s_x*2)/(d_n*s_n)
print(math.ceil(S))
0
Muhammad Bilal , please explain the logic
0
The code passes all the test cases ?? I am not a pro user I only check the given test case.
I add comments in the code.
0
Muhammad Bilal ,Yes it passes all test cases
0
SOUPTIK NATH
I add some comments it might be helpful for you.kindly check it
https://code.sololearn.com/cdTK92k4KqQ0/?ref=app
0
Muhammad Bilal Thanks
0
You're welcome
0
Muhammad Bilal , What if I use Math.floor in the last line in place of Math.ceil?
0
While using ceil method it return the value in float and it failed in all test cases instead of ceil method i used round method but it was failed in the test case 5😐 I'm not using pro and i can't able to find the error...