最大长度 - 单位数量 [英] Max length - unit quantities

查看:80
本文介绍了最大长度 - 单位数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我已经制定了一个程序来检测我应该在房间里放多少床。如果我有房间的最大长度和宽度,以及每张床的最大长度和宽度,我想要在x和y方向上打印多少张床。这可能吗? (房间和床是矩形的)



我尝试过:



def main():

max_length =无

current_length = 76.2

max_width =

current_width =



def for l in bed:

if current_length> max_length =不适用:

返回max_length

else current_length< max_value:

返回current_length

Let say I have made a program to detect how many beds I should put in a room. If I have the max length and width of the room, and the max length and width of each bed, I want to print how many beds its possible on the x and y direction. is this possible? (rooms and beds are rectangular)

What I have tried:

def main():
max_length = None
current_length = 76.2
max_width =
current_width =

def for l in bed:
if current_length > max_length = "not applicable":
return max_length
else current_length < max_value:
return current_length

推荐答案

这类问题众所周知,其他人已经深入研究过。您可以在网上找到很多资料。一个很好的起点是,正如 PIEBALD 已经建议的那样, Wikipedia 。看看,例如在背包问题 - 维基百科 [ ^ ]。
Such kind of problem is well known and other people have already deeply studied it. You may find a lot of material on the web. A good starting point is, as PIEBALD has already suggested, Wikipedia. Have a look, for instance at Knapsack problem - Wikipedia[^].


引用:

我是新编码,我需要一个代码才能知道我可以在一个房间和床的宽度和长度的房间里放多少张床。

I am new at coding, I need a code to know how many beds I can place in a room with certain width and length of both, the room and the beds.



我们不做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



如果遇到具体问题,请询问相关问题,我们会尽力提供帮助。但我们不打算为你做这一切!


We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


这篇关于最大长度 - 单位数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆