leetcode 2525. 根据规则将箱子分类

#给你四个整数 length ,width ,height 和 mass 
#分别表示一个箱子的三个维度和质量,请你返回一个表示箱子 类别 的字符串。

#如果满足以下条件,那么箱子是 "Bulky" 的:
#箱子 至少有一个 维度大于等于 104 。
#或者箱子的 体积 大于等于 109 。
#如果箱子的质量大于等于 100 ,那么箱子是 "Heavy" 的。
#如果箱子同时是 "Bulky" 和 "Heavy" ,那么返回类别为 "Both" 。
#如果箱子既不是 "Bulky" ,也不是 "Heavy" ,那么返回类别为 "Neither" 。
#如果箱子是 "Bulky" 但不是 "Heavy" ,那么返回类别为 "Bulky" 。
#如果箱子是 "Heavy" 但不是 "Bulky" ,那么返回类别为 "Heavy" 。
#注意,箱子的体积等于箱子的长度、宽度和高度的乘积。

class Solution(object):

    def categorizeBox(self, length, width, height, mass):
        """
        :type length: int
        :type width: int
        :type height: int
        :type mass: int
        :rtype: str
        """
        x = 10
        threshold1 = x**4
        threshold2 = x**9
        flag1 = ''
        flag2 = ''
        volume = length * height * width
        if length >= threshold1 or width >= threshold1 or height >= threshold1 or volume >= threshold2:
            flag1 = 'Bulky'
        if mass >= 100:
            flag2 = 'Heavy'
        res = ''
        if flag1 == 'Bulky' and flag2 == 'Heavy':
            res = 'Both'
        if flag1 != 'Bulky' and flag2 != 'Heavy':
            res = 'Neither'
        if flag1 == 'Bulky' and flag2 != 'Heavy':
            res = 'Bulky'
        if flag1 != 'Bulky' and flag2 == 'Heavy':
            res = 'Heavy'
        return res
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

罗啰萝在努力

如果这篇文章对你有帮助,望支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值