+ 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

26th Mar 2020, 6:19 PM
Souptik Nath
Souptik Nath - avatar
12 Answers
26th Mar 2020, 7:23 PM
Muhammad Bilal
Muhammad Bilal - avatar
+ 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.
27th Mar 2020, 7:41 AM
Muhammad Bilal
Muhammad Bilal - avatar
+ 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))
1st Aug 2022, 5:00 AM
Максут Кудайбергенов
Максут Кудайбергенов - avatar
0
Muhammad Bilal , please explain the logic
26th Mar 2020, 7:26 PM
Souptik Nath
Souptik Nath - avatar
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.
27th Mar 2020, 5:51 AM
Muhammad Bilal
Muhammad Bilal - avatar
0
Muhammad Bilal ,Yes it passes all test cases
27th Mar 2020, 5:52 AM
Souptik Nath
Souptik Nath - avatar
0
SOUPTIK NATH I add some comments it might be helpful for you.kindly check it https://code.sololearn.com/cdTK92k4KqQ0/?ref=app
27th Mar 2020, 6:04 AM
Muhammad Bilal
Muhammad Bilal - avatar
27th Mar 2020, 6:20 AM
Souptik Nath
Souptik Nath - avatar
0
You're welcome
27th Mar 2020, 6:23 AM
Muhammad Bilal
Muhammad Bilal - avatar
0
Muhammad Bilal , What if I use Math.floor in the last line in place of Math.ceil?
27th Mar 2020, 7:29 AM
Souptik Nath
Souptik Nath - avatar
27th Mar 2020, 11:31 PM
goodyeea
goodyeea - avatar
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...
14th Nov 2023, 11:03 AM
Premnath Srini
Premnath Srini - avatar