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,14 +27,11 @@ 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;
while let Some((divisor, numeral)) = stack.pop() {
while num > divisor {
out.push(numeral);
num -= divisor;
} }
if num == 0 {
break
}
} }
out.join("") out.join("")

Loading…
Cancel
Save