Write a Python program, in a file called decode.py, to solve the following problem: A princess...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Python program, in a file called decode.py, to solve the following problem: A princess was lost in the woods and came across a castle with the door ajar. She went in and found no one inside the castle until she heard a terrifying roar and a big beast appeared in front of her. The beast said that he was actually a prince, but was cursed to become a beast and the princess could help break the curse if she could get a bottle of potion that was under the big banyan tree. The beast gave the princess a piece of paper which had an encoded message on it. The message contained 16 alphanumeric characters (aep2eapбpse4ctd7) that encoded the location of the big banyan tree; that is, the encoded message contained the direction and the walking distance needed (from the castle) to find the big banyan tree. Help the princess save the prince by decoding the message to find the direction and the walking distance needed to find the bottle of potion under the big banyan tree. The direction has only four characters and the distance is computed from the four digits contained in the message. To decode the message, use the following key: ● • The direction the princess needs to go can be found by extracting the first character at the second position of the given message and then getting a character from every fourth position in the message thereafter (i.e., every fourth position relative to the second character's position). • The distance (in paces) is computed by extracting digits from positions/locations that are 4 places away from the previous position (starting at the fourth character of the message) and finding the sum of all the digits. Given the message found as input; decode and output the decoded message. Note that the input message should be able to be changed as long as it following the encoding scheme as indicated by the decoding key, and remains as the same length. For example, if the prince moves to a different location, there could be a different message left such as: fwp3rep2kse1cts4 Sample input prompts, input and output for run 1 of the program (input shown in bold blue); Enter the message found: aep2eap6pse4ctd7 To find the potion, you need to travel east for 19 paces. Sample input prompts, input and output for run 2 of the program (input shown in bold blue): Enter the message found: fwp3rep2kselcts4 To find the potion. Vou need to travel west for 10 paces. Write a Python program, in a file called decode.py, to solve the following problem: A princess was lost in the woods and came across a castle with the door ajar. She went in and found no one inside the castle until she heard a terrifying roar and a big beast appeared in front of her. The beast said that he was actually a prince, but was cursed to become a beast and the princess could help break the curse if she could get a bottle of potion that was under the big banyan tree. The beast gave the princess a piece of paper which had an encoded message on it. The message contained 16 alphanumeric characters (aep2eapбpse4ctd7) that encoded the location of the big banyan tree; that is, the encoded message contained the direction and the walking distance needed (from the castle) to find the big banyan tree. Help the princess save the prince by decoding the message to find the direction and the walking distance needed to find the bottle of potion under the big banyan tree. The direction has only four characters and the distance is computed from the four digits contained in the message. To decode the message, use the following key: ● • The direction the princess needs to go can be found by extracting the first character at the second position of the given message and then getting a character from every fourth position in the message thereafter (i.e., every fourth position relative to the second character's position). • The distance (in paces) is computed by extracting digits from positions/locations that are 4 places away from the previous position (starting at the fourth character of the message) and finding the sum of all the digits. Given the message found as input; decode and output the decoded message. Note that the input message should be able to be changed as long as it following the encoding scheme as indicated by the decoding key, and remains as the same length. For example, if the prince moves to a different location, there could be a different message left such as: fwp3rep2kse1cts4 Sample input prompts, input and output for run 1 of the program (input shown in bold blue); Enter the message found: aep2eap6pse4ctd7 To find the potion, you need to travel east for 19 paces. Sample input prompts, input and output for run 2 of the program (input shown in bold blue): Enter the message found: fwp3rep2kselcts4 To find the potion. Vou need to travel west for 10 paces.
Expert Answer:
Answer rating: 100% (QA)
def decodemessageencodedmessage Extract direction direction encodedmessage1 directionindices listran... View the full answer
Related Book For
Managing Business Ethics Making Ethical Decisions
ISBN: 9781506388595
1st Edition
Authors: Alfred A. Marcus, Timothy J. Hargrave
Posted Date:
Students also viewed these programming questions
-
The Crazy Eddie fraud may appear smaller and gentler than the massive billion-dollar frauds exposed in recent times, such as Bernie Madoffs Ponzi scheme, frauds in the subprime mortgage market, the...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
A car has a sticker price of $69,000. The car has a 100 hp engine and can accelerate from 0 to 60 mph in 15.8 seconds. The lease rate is 4.6%. The term of the lease is three years. The buyout is...
-
(a) In Section 27.7 we discussed how a magnetic dipole, such as a current loop or a magnetized object, can be attracted or repelled by a permanent magnet. Use this to explain why either pole of a...
-
Northwest Airlines runs daily flights from Detroit to Amsterdam. They face a fixed cost of $ 70,000 for each flight independent of the actual number of passengers on the plane. There are 310 seats...
-
An often-ignored concept in breach of contract is the availability, if any, of the award of punitive damages. Often, cases incorporate both breach of contract and tort actions. The tort actions...
-
Refer to the financial statements of Urban Outfitters given in Appendix C at the end of this book. Required: 1. Does Urban Outfitters use the direct or indirect method to report cash flows from...
-
The example may be a sales tax or income tax proposal at any level of government. In your initial post, explain the revenue proposal, and evaluate it for equity, adequacy of revenue generation,...
-
For R, partition the data sets into 60% training and 40% validation and implement the 10-fold cross-validation. Use the statement set. seed(1) to specify the random seed for data partitioning and...
-
Integrate xxs+sof 7
-
Since everyone wants a heated pool, Beltsville Quick Heat Pools has experienced very rapid growth in sales. The company expects the dividend payment to grow by 8% for the next 2 years and then to...
-
A share of common stock just paid a dividend of $3.4. If the expected long-run growth rate for this stock is 1%, and if investors' required rate of return is 6.6%, then what is the stock price? Round...
-
+ 25. Carter borrows $20,000 to pay for college tuition. The loan is fully amortized over a three-year period with an interest rate of 8%. What is Carter's remaining balance at the end of Year Two?...
-
Identify and research a large service business in your pathway. It must be a large, US, publicly traded company on the Fortune 500 list. Don't use a company that someone has already used. Access...
-
The data for ABC Corporation for the year ended 2019 is given below: (all values are in thousands) Financial indicators Net income Values $2355.12 Sales 27,412 Total assets 25,262 Stockholder's...
-
Thanos is being sued for breach of contract while Loki is facing prosecution for armed robbery. Explain the differences between these two cases. Malaysian Legal System
-
A researcher reports a significant two-way between-subjects ANOVA, F(3, 40) = 2.96. State the decision to retain or reject the null hypothesis for this test.
-
You work at the front desk of a hotel in a small town near the border between the United States and Mexico. When you check in guests, you ask them to show identification and provide the make, model,...
-
With a focus on innovation, Pegasus is a company committed to technology leadership in the new millennium. Its systems and products are selling well in markets throughout the world. The CEO wants the...
-
Darlington Foods is an integrated wholesaler and retailer of high-quality food products. It provides gourmet foods to supermarket chains and specialty stores in the United States and Europe under the...
-
A researcher measured heart rate \((x)\) and oxygen uptake \((y)\) for one person under varying exercise conditions. He wishes to determine if heart rate, which is easier to measure, can be used to...
-
A researcher is investigating the relationship between yield of potatoes \((y)\) and level of fertilizer \((x\).\() She divides a eld into eight plots of equal\) size and applied fertilizer at a di...
-
The Police Department is interested in determining the e ect of alcohol consumption on driving performance. Twelve male drivers of similar weight, age, and driving experience were randomly assigned...
Study smarter with the SolutionInn App