Due: Thursday, August 30, 2018 at noon 50 pts.
For this assignment, you will type and submit three (3) algorithms. Make your algorithms clear and concise step-by-step procedures that solve the problems given. I think that each of these should require at least three steps and probably (though, possibly) no more than twenty steps. Think about your answers.
You are to edit a single file in your DFS account using an editor (I like jpico ... nano is also good) that your lab instructor has shown you in your CS 1580 lab #1( or #0 depending on who your lab instructor is). First though, make a new directory inside your SDRIVE directory and call it cs1570 (from home, change directory to SDRIVE. Then type mkdir cs1570 and enter). Change into that directory (cd cs1570). Now, make a new directory under this cs1570 directory and name it hw1. Change into that directory and then create the file with your answers in it, naming it something clever like "hw1.txt". The .txt extension is used for files that are nothing but text (not to be compiled). What ever you name that file, make sure it has a .txt extension. This assignment is NOT C++ programming. You are not to compile this. In this (one and only) file (for this assignment), you are to number your answers for the following 3 problems. Also, be sure to put your name and section letter at the top!!
I think everyone knows the game "tic tac toe". If not, ask a friend or your instructor. Ok, so you are going to write an algorithm to describe to an interested person (or a slug or a chicken or ...)1 just how to play that game. You can assume that there is already in place a pencil and a piece of paper. You can also assume the person wanting to play the game is at least as smart as a chicken, but not as smart as you. And if you are not as smart as a chicken, then don't ever play tic tac toe.
Write an algorithm to determine the prime factorization of any positive integer n, n > 1. We'll exclude negative numbers because there's really no such a thing...just ask any chicken. If you don't know what the prime factorization of an integer is, here's an explanation:
If what you read on that webpage makes your head hurt, then consider these examples.
15 = 3 x 5 because 3 x 5 is indeed 15 and 3 and 5 are primes
117,306 = 21 x 32 x 73 x 191 because my calculator says so and 2, 3, 7, and 19 are all primes
Here's a problem that has the potential to make you rich2. The town of Chickendale has implemented an incentive program for road-side recycling - the town picks up your recyclable waste. It works like this: once a week the truck shows up at your house to pick up your recyclable stuff, and at the same time gives you a listing of the incentives for the next week. Then they take your recycling stuff and leave. The listings of the incentives for the next week will tell you:
How much money you will be given for each unit (that's how everything is measured) of a recyclable material (glass, paper, metal, or coffee grounds).
How many units you are allowed to recycle that coming week
Thus, for example, if you are allowed 14 units, then you could recycle 3 units of paper, 5 units of glass, 2 units of grounds, and 4 units of metal. Of course, you'd want to recycle as much of the best-paying material. And, of course, you can only recycle only as many units of any given material that you have. Your job is to write an algorithm that determines the most lucrative recycling "package" to leave at the curb the next week.
1This is quite possibly the stupidest game ever invented. Not even cavemen played this game (never seen any tic tac toe cave art, have you?? ... evidence that cavemen were smarter than chickens).
2Not likely!
To submit this homework, you are going to use the cssubmit program for your section of cs1570. This assignment will be used for all sections. Your answers should be written up using your favorite editor in a subdirectory called hw1 hanging off your cs1570 subdirectory. Remember: make a different directory under cs1570 for every one of your assignments. From that directory, at the UNIX command, type "cssubmit 1570 a 1" if you are in section a. If you are in section b, type "cssubmit 1570 b 1". If you are in section c, type "cssubmit 1570 c 1", etc. (Can you see the pattern?) Hit enter. Of course, when submitting homework #2, your last entry in that command should be a 2. Don't type cssubmit 1570 a h2 or some other variant like that; just the digit 2. Use this scheme for subsequent submissions. If you have any questions about using the editor or submitting, just ask. You can look here for guidance on submitting using the cssubmit command.
NOTE: You can submit the same assignments multiple times. If you submit and then remember something you forgot, you can edit your file, save it, then submit again. The new submission will overwrite the old; we won't see the old one. Time stamps on submissions apply to the latest submission. Always run the submit script from the directory in which the file(s) to be submitted reside(s). Any questions, just ask. Remember, there is a due date/time. Try not to exceed that.