Question: In outer space, messages sent in space are vulnerable to alteration due to cosmic conditions and interference. To ensure the correctness of messages during transmission,

In outer space, messages sent in space are vulnerable to alteration due to cosmic conditions and interference. To ensure the correctness of messages during transmission, messages need to be encoded in a certain way. In this particular encoding system, characters in a message are followed by a number which indicates how many times the character is to be repeated. However, there's a twist: if the position of the character in the original message is odd (1,3,5,...) the character is repeated one additional time, and if it's even (0,2,4,...), one repetition is subtracted. Your task is to develop a function called CommsDecoder that will take the encoded message as input and return the decoded message to the main program. The main program will read the encoded message, pass it to the function CommsDecoder and print the returned value. Example: For an encoded message "H2e3l4o5""H" should be repeated 2+1 times (due to its odd position)."e" should be repeated 3-1 times (due to its even position)."l" should be repeated 4+1 times (due to its odd position)."o" should be repeated 5-1 times (due to its even position). Decoded Message: HHHeellllloooo 3254 Instructions Use a while loop to traverse through the message character by character. Depending on the index of the character, adjust the repeat factor and add the repeated character. Assume that the user will always input a character followed by a single digit number, no need for input validation (or you can do it for the sake of making it more challenging but it will not affect your grade) Sample Run 1: Enter the encoded message to be sent into space: H3L2X7O6 Encoded Message: H3L2X7O6 Decoded Message: HHHHLXXXXXXXXOOOOO Sample Run 2: Enter the encoded message to be sent into space: I4N5T7E5R3 Encoded Message: I4N5T7E5R3 Decoded Message: IIIIINNNNTTTTTTTTEEEERRRR Sample Run 3: Enter the encoded message to be sent into space: S3t2E6L2L1A4R5 Encoded Message: S3T2E6L2L1A4R5 Decoded Message: SSSSTEEEEEEELLLAAARRRRRR

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!