Type: Group Assignment

Due: by 10:00 PM on Tuesday, September 18, 2018

Prologue

This is a group assignment. Remember that you should always be working with your partner. You may NOT divide up the work and complete the parts independently. All work you submit must be fully authored by both you and your partner. I also suggest that you work on one computer and take turns using the keyboard. Here are some suggested policies.

  1. Set a timer for 10-15 minutes and switch who is using the keyboard. Even if you’re not comfortable using a keyboard, it is important that you get experience doing so in this course.
  2. If you are currently the driver (i.e. the one using the keyboard), practice talking out loud what you are thinking as you are typing.
  3. If you are currently the navigator (i.e. the one not using the keyboard), pay close attention to what the driver is doing, offer feedback, and stay involved throughout that time. Do NOT simply sit idly and let the driver work alone.
  4. Ask each other questions. If you’re confused about something your partner is doing, let them know and ask them if they could explain or clarify their idea. Talking to each other and checking each other’s work is the best way to pair program!

I recommend that you create a folder named assignment2 in your StuWork directory. If you have the COURSES drive mounted already, you can do this by executing the commands.

$ cd /Volumes/COURSES/cs111-03-f18/StuWork/USERNAME
$ mkdir assignment2
$ cd assignment2

Note that USERNAME should be replaced with your actual username.

After executing the third command above, you will be inside the assignment2 directory and ready to work.

Part 1: Word Search Puzzles

Introduction

A word search puzzle is a game that consists of a list of words and a large table of characters, and the objective is to find every given word in the table. The challenge is that the words may appear horizontally, vertically, or diagonally; similarly, they may appear backwards or forwards. Thus, there are eight possible orientations of a word in the table. To make them especially hard to find, any unused space in the table is filled with random characters.

Below is an example of a word search puzzle.

List of Words:

COMPUTER SCIENCE TITUS ELLIE

Table of Letters

P Q G V S K B F K K S I H J F
K K G N T A X N M U Y P V D B
B P I I Q R W N T L P P I L B
P O O F L I D I O G M X K Z I
E C G B R S T Y S H V T W S F
C N I M M B I Q L N T Z E D Z
N D Y S J A Y R C G D Y Z C C
E J B V S P E B A A M I P O H
I R V S K Z L Z B R W A M K K
C W T B E P L O U X D P X L B
S Q U G P Q I K G B U Y E V H
H Y D J O G E O Q T J G J B B
S A F X M A B F E M Q B T M L
C C R A I H N R O C I O S O O
Z L U Q W S E A B X X D T V I

Word Search Algorithm

Your task for this part is to describe an algorithm in English that, given an instance of a word search puzzle, will help me successfully find the locations of all the words. The challenge of the problem is that you must assume that I have very limited memory, but I have a lot of paper and a pencil. You may assume that I can do the following things reliably:

  1. Understand the English alphabet,
  2. Draw symbols such as alphabetic characters or place special markings on characters (e.g. circling, drawing a line through, or placing a dot above a character or word),
  3. Use an eraser extremely precisely (e.g. remove a marking from a character),
  4. Remember a few words or characters in my head, but not more than three,
  5. Recognize a word or character I am thinking about, and
  6. Use my fingers to keep track of where I am on the paper and understand concepts such as left, right, up, down, etc.

You may also assume that I know how to copy the list of words and the entire table of characters onto paper so that I can mark on it in future instructions.

The final product of the algorithm should be a piece of paper that includes the table of characters with each of the hidden words circled. No other markings or symbols should be present.

You should write your algorithm in a plain text file named word_search.txt. Instructions for how to submit your files is provided at the end of the assignment.

Part 2: Basic Python

This part is designed to get you started writing simple python programs.

a. Temperature Converter

Write a Python program named convert.py that converts temperatures from Fahrenheit to Celsius. It should prompt the user for a number, and then print the result.

b. Average of Three

Write a Python program named average.py that asks the user for three numbers and then prints the average of the three as output.

c. Voting Age

Write a Python program named voter.py that asks the user how old they are and then prints the first U.S. presidential election year that they can vote in. This is a bit trickier since the user needs to be at least 18 to vote and presidential elections only happen on years that are divisible by four.

Below is a hint about decades that might be helpful.

birth_year = 1998
decade = int(birth_year / 10)
print("You were born in the", decade, "0s.")

# Or with slightly better spacing
print("You were born in the " + str(decade) + "0s.")

How to Turn in Your Code

a. Make sure that you and your partner are clearly identified at the top of every file you have created for this assignment.

b. All of your files need to be placed into the Hand-in/USERNAME/assignment2 directory. You can do this visually in Finder by copying all of your files in your StuWork/USERNAME/assignment2 directory into your Hand-in/USERNAME/assignment2 directory.

(If you prefer to do this in the Terminal, I will guide you through it at the end of this page.)

c. Send all of your files to your partner so they have access to them, too!

Copying via the Terminal

I am assuming that you did all of your work in the StuWork/USERNAME/assignment2 directory as described above.

a. Make sure you are in the course directory by executing

$ cd /Volumes/COURSES/cs111-03-f18

b. To copy your StuWork/USERNAME/assignment2 directory into the Hand-in/USERNAME directory, all you need to do is execute

$ cp -r StuWork/USERNAME/assignment2 Hand-in/USERNAME

The -r in the copy command stands for “recursive” and makes the command copy all sub-folders and files contained in the folder, too.