Skip to content

Commit

Permalink
refactor wordy
Browse files Browse the repository at this point in the history
  • Loading branch information
0xNeshi committed Dec 15, 2024
1 parent c78edc1 commit 909638a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions exercises/practice/wordy/.meta/example.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn answer(question: ByteArray) -> i32 {

let mut result = match parse_int(words[2]) {
Option::Some(s) => s,
Option::None => panic!("syntax error")
Option::None => panic!("syntax error"),
};

let mut i = 3;
Expand Down Expand Up @@ -96,9 +96,8 @@ fn parse_int(num: @ByteArray) -> Option<i32> {
i += 1;
}

while i < size {
let re = char_to_digit(num[i]);
match re {
for i in i..size {
match char_to_digit(num[i]) {
Option::Some(v) => {
if let Option::Some(num) = result {
result = Option::Some(num * 10 + v.into());
Expand All @@ -107,9 +106,8 @@ fn parse_int(num: @ByteArray) -> Option<i32> {
Option::None => {
result = Option::None;
break;
}
},
}
i += 1;
};

if let Option::Some(val) = result {
Expand Down

0 comments on commit 909638a

Please sign in to comment.