Skip to content

Commit 8d38402

Browse files
committed
refactor
1 parent 1f86872 commit 8d38402

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

rust/eliuds-eggs/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
pub fn egg_count(decimal: u32) -> usize {
22
let binary = decimal_to_binary(decimal);
3-
let eggs = count('1', binary);
4-
eggs
3+
count('1', binary)
54
}
65

76
fn decimal_to_binary(decimal: u32) -> String {
87
let mut result = "".to_string();
9-
108
let mut n = decimal;
119
while n != 0 {
1210
let remainder = n % 2;
1311
n = n / 2;
14-
let c = char::from_digit(remainder, 10).unwrap();
15-
result.insert(0, c);
12+
result.insert(0, char::from_digit(remainder, 10).unwrap());
1613
}
17-
1814
result
1915
}
2016

0 commit comments

Comments
 (0)