Skip to content

Commit 3fd31ef

Browse files
committed
src/bin/categorize-box-according-to-criteria.rs
1 parent d4bc41c commit 3fd31ef

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![allow(dead_code, unused, unused_variables, non_snake_case)]
2+
3+
fn main() {}
4+
5+
struct Solution;
6+
7+
impl Solution {
8+
pub fn categorize_box(length: i32, width: i32, height: i32, mass: i32) -> String {
9+
const A: i32 = 10i32.pow(4);
10+
const B: i64 = 10i64.pow(9);
11+
let is_bulky = length >= A
12+
|| width >= A
13+
|| height >= A
14+
|| (length as i64 * width as i64 * height as i64) >= B;
15+
let is_heavy = mass >= 100;
16+
17+
if is_bulky && is_heavy {
18+
"Both"
19+
} else if is_bulky {
20+
"Bulky"
21+
} else if is_heavy {
22+
"Heavy"
23+
} else {
24+
"Neither"
25+
}
26+
.into()
27+
}
28+
}

0 commit comments

Comments
 (0)