Finished
11def parse_octal(digits: str) -> int:
2 pass
2 # Edge Case: Empty string input
3 if not digits:
4 return 0
5
6 result = 0
7
8 # Process each digit from left to right
9 for digit in digits:
10 # Edge Case: Invalid characters in octal string
11 if not digit.isdigit() or int(digit) > 7:
12 raise ValueError("Invalid octal digit: " + digit)
13
14 # Convert the digit to integer and multiply by the appropriate power of 8
15 result = result * 8 + int(digit)
16
17 return result
18# Handled Edge Cases: empty string input, invalid characters in octal string
Test NameStatus
test_6789_is_seen_as_invalid
Pass
test_8_is_seen_as_invalid
Pass
test_invalid_octal_is_recognized
Pass
test_octal_10_is_decimal_8
Pass
test_octal_1234567_is_decimal_342391
Pass
test_octal_130_is_decimal_88
Pass
test_octal_17_is_decimal_15
Pass
test_octal_1_is_decimal_1
Pass
test_octal_2047_is_decimal_1063
Pass
test_valid_octal_formatted_string_011_is_decimal_9
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.