Browse Source

updates after codewars submission...

change logic from 'divisible by' to 'greater than divisor'
deconstruct tuple for better readability
master
Jim Infield 3 years ago
parent
commit
e2e7175147
  1. 11
      src/main.rs

11
src/main.rs

@ -27,13 +27,10 @@ fn func(num: i32) -> String {
let mut num = num; let mut num = num;
while let Some(div) = stack.pop() {
while num/div.0 > 0 {
out.push(div.1);
num -= div.0;
}
if num == 0 {
break
while let Some((divisor, numeral)) = stack.pop() {
while num > divisor {
out.push(numeral);
num -= divisor;
} }
} }

Loading…
Cancel
Save