Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do this without importing any modules What to Hand In Usually this appears last, but in this question, it's first so that you know

Please do this without importing any modules

image text in transcribedimage text in transcribed

What to Hand In Usually this appears last, but in this question, it's first so that you know what you have to hand in. As you can see, the code you develop is a small part of this work. - Your plan to complete this question: a2q2_plan . txt - Your design document: a2q2_design . txt - Your answers to the reflection questions: a2q2_reflections.txt - Your Python program a2q2.py You are allowed to use PDF, RTF, DOC files instead of TXT. Be sure to include your name, NSID, student number. course number and lecture section at the top of all documents. Problem Specification In this question you will implement a program to solve a simple task. The task itself is related to a statistical and physical model called a Random Walk. A Random Walk is a string consisting of a random sequence of the letters ' L ' and ' R '. For example: 'L R R L R'. We're going to imagine that this sequence describes a person taking a step left 'L' or right ' R ' at random along a straight line. The question we want to answer is this: In terms of steps, how far away is the person after taking all the steps? We'll call this the distance, and it will always be positive (or zero). since we don't care which side the person ends up on.| Here are some examples to help clarify: - 'L L L': distance is 3 - 'R L L': distance is 1 - ' RRL ': distance is 1 - 'R R R': distance is 3 - 'R L L R': distance is 0 - 'L R R L R': distance is 1 You will be given a number of datafiles containing random walks of different lengths. Each file will contain a number of lines. Each line will be a random walk. The program you must write will open the file, read each line, and then display the distance of the random walk for that line. For example, if a datafile contained the examples above, your program would display \begin{tabular}{l} 3 \\ 1 \\ 1 \\ 3 \\ 0 \\ 1 \\ \hline \end{tabular}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data With Hadoop MapReduce A Classroom Approach

Authors: Rathinaraja Jeyaraj ,Ganeshkumar Pugalendhi ,Anand Paul

1st Edition

1774634848, 978-1774634844

More Books

Students also viewed these Databases questions

Question

6. Identify characteristics of whiteness.

Answered: 1 week ago

Question

9. Explain the relationship between identity and communication.

Answered: 1 week ago