Question: python Write a function moronic2arabic() that takes a string argument consisting of properly-formatted Moronicnumerals and returns the integer represented by the Moronic numerals. The converted

python

python Write a function moronic2arabic() that takes a string argument consisting of

Write a function moronic2arabic() that takes a string argument consisting of properly-formatted Moronicnumerals and returns the integer represented by the Moronic numerals. The converted integer is guaranteed to be in the range [1, 3071].

Process the input string from left-to-right, looking for combinations of numerals (doubles and triples that indicate subtraction) or single numerals that are not involved in subtraction. Add the value of the numeral combination or singleton to a running total and move on to the remainder of the input string. To find combinations of numerals, examine two or three characters simultaneously (e.g., SSF or IE), taking care not to overrun the end of the string while doing this. Proceed in this manner until the rightmost numeral has been processed.

Examples:

properly-formatted Moronicnumerals and returns the integer represented by the Moronic numerals. The

def moronic2arabic(numerals): return None 

if __name__ == "__main__": 
 print('Testing moronic2arabic() for "SIE": ' + str(moronic2arabic('SIE'))) print('Testing moronic2arabic() for "SSSSSEESIIII": ' + str(moronic2arabic('SSSSSEESIIII'))) print('Testing moronic2arabic() for "FSSFIIII": ' + str(moronic2arabic('FSSFIIII'))) print('Testing moronic2arabic() for "FFFIIE": ' + str(moronic2arabic('FFFIIE'))) print('Testing moronic2arabic() for "FFFSFEIE": ' + str(moronic2arabic('FFFSFEIE'))) 

You've heard of Roman numerals, but have you heard of Moronic numerals? Probably not because we've invented them for this homework assignment. Moronic numerals are similar to Roman numerals in that numbers are formed by combining symbols and adding the values In Moronic numerals, each numeral has a fixed value representing a power of 8 (rather than a power of 10 or half of a power of 10, as in Roman numerals) Symbol: I E S F Value: 1 3 64 512 Symbols are placed from left to right in order of value, starting with the largest. For example, FFFFSSSEEEEEllll s 2, 284 (512 x 4) (64 x 3) (8 x 5) (4 x 1) In a few specific cases, to avoid having six or more characters being repeated in succession (such as llllll or EEEEEE), subtractive notation is used, as in this table: Number 6 7 48 (64 2x 8) 56 (64 1x8) 384 (512 2x64) 448 (512-1x64) Notation: ILE DE EES SF ES SSF

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!