Starting from:

$35

Assignment 1 Solution

Where's That Word?

In this assignment, you will implement a two­player word search game. There are several small parts to this task; all of them use concepts that you are learning about during the first three weeks of the course.

Goals of this Assignment

Use the Function Design Recipe (design_recipe.pdf ) to plan, implement, and test functions.


Write function bodies using variables, numeric types, strings, and conditional statements. (You can do this whole assignment with only the concepts from Weeks 1, 2, and 3 of the course.)


Learn to use Python 3, Wing 101, provided starter code, a checker module, and other tools.


We have prepared

a video to show examples of how the game will work

(https://www.youtube.com/watch?v=zX0fBYDNYfw)

(https://www.youtube.com/watch?v=zX0fBYDNYfw)

when you complete the required functions.

Starter code

For this assignment, we are giving you some files, including some Python starter code files. See the Files to Download section below for more information.

How to not be interviewed for an academic offence

"The truth is that on every campus, a large proportion of the reported cases of academic dishonesty come from introductory computer science courses, and the reason is totally obvious: we use automated tools to detect plagiarism"

Professor Ed Lazowska, chair of computer science and engineering at the University of Washington, Why Computer Science Students Cheat (Link

(https://www.pcworld.com/article/194486/Computer_Science_Students_

).

We are very good at detecting cheating. We hate finding it, though, so we have written this short guide on how to avoid being interviewed by us for an academic offence.

A typical penalty for a first offence is a zero on the assignment. The case will also be entered into the UofT academic offence database. (If you get caught a second time ever as an undergrad, the penalties are much, much more severe.)

Our tips:

Remember that figuring out what code needs to be written is the most important part of the assignment. Typing out code based on steps that someone else gave you is considered cheating, as you are submitting someone else's ideas as your own.

Don't search the web for solutions. We've already done that and will be comparing what we found with what you submit. It doesn't help to change variable names and move functions around. Our software will still find those.

Don't ask your friend for their solution, even if you just want it to "see how to solve it". Don't show your friends your solution


FORWARD_FACTOR

Constants

Constants are special variables whose values do not change once assigned. A different naming convention (uppercase pothole) is used for constants, so that programmers know to not change their values. For example, in the starter code, the constant FORWARD_FACTOR is assigned the value 1 at the beginning of the module and the value of FORWARD_FACTOR should never change in your code. When writing your code, if you need to refer to the multiplicative factor of a forwards word (see Scoring the Game below), you should use FORWARD_FACTOR , rather than 1. The same goes for the other constant values

Using constants simplifies code modifications and improves readability. If we later decide to use a different forward factor, we would only have to change the factor in one place (the

Your puzzle_functions.py file should contain the starter code, plus the function definitions specified above. puzzler_functions.py must not include any calls to the print and input functions. Do not add any import statements. Also, do not include any function calls or other code outside of the function definitions.


How should you test whether your code works?

First, run the checker and review ALL output — you may need to scroll. You should also test each function individually by writing code to


verify your functions in the Python shell. For example, after defining function get_winner , you might call it from the shell (e.g.,


get_winner(10, 4) ) to check whether it returns the right value ( 'player one wins' ). One call usually isn't enough to thoroughly test the


function — for example, we should also test get_winner(5, 5) where it should return 'tie game' and get_winner(2, 10) where it should

return .


Once you've checked each function individually, play the game by running the puzzle_program.py starter code to see whether it works as expected. If not, go back to testing the functions individually. It is part of the assignment for you to decide which tests to use.

A1 Checker


We are providing a checker module ( a1_checker.py ) that tests two things:

whether your functions have the correct parameter and return types, and whether your code follows the Python and CSC108 Python Style Guidelines.


To run the checker, open a1_checker.py and run it. Note: the checker file should be in the same directory as your puzzler_functions.py , as provided in the starter code zip file. We have posted

a demo of the checker being run (https://www.youtube.com/watch?v=SXREdJ1GrzU)

(https://www.youtube.com/watch?v=SXREdJ1GrzU)

and included it in the Week 3 Prepare exercises on PCRS. Be sure to scroll through and read all messages.

If the checker passes for both style and types:

Your function parameters and return types match the assignment specification. This does not mean that your code works correctly in all situations. We will run additional tests on your code once you hand it in, so be sure to thoroughly test your code yourself before submitting.


Your code follows the Python Style Guidelines.


If the checker fails, carefully read the message provided:

It may have failed because one or more of your parameter or return types does not match the assignment specification, or because a function is misnamed. Read the error message to identify the problematic function, review the function specification in the handout, and fix your code.


It may have failed because your code did not follow the style guidelines. Review the error description(s) and fix the code style.


Please see the PyTA documentation (Link (http://www.cs.toronto.edu/~david/pyta/) ) for more information about errors.

Make sure the checker passes before submitting.

Marking

These are the aspects of your work that may be marked for A1:

Correctness (80%): Your functions should perform as specified. Correctness, as measured by our tests, will count for the largest single portion of your marks. Once your assignment is submitted, we will run additional tests not provided in the checker. Passing the checker does not mean that your code will earn full marks for correctness.


Coding style (20%): Make sure that you follow that we have introduced and the Python coding conventions that we have been using throughout the semester. Although we don't provide an exhaustive list of style rules, the checker tests for style are complete, so if your code passes the checker, then it will earn full marks for coding style with one exception: docstrings may be evaluated separately. For each occurrence of a PyTA error, one mark (out of 20) deduction will be applied. For example, if a C0301 (line­too­ long) error occurs 3 times, then 3 marks will be deducted.


What to Hand In

The very last thing you do before submitting should be to run the checker program one last time.

Otherwise, you could make a small error in your final changes before submitting that causes your code to receive zero for correctness.


Submit puzzle_functions.py on MarkUs (http://markus108.teach.cs.toronto.edu/csc108­2018­09) by following the instructions on the syllabus. Remember that spelling of filenames, including case, counts: your file must be named exactly as above.