You are on page 1of 2

CS 11 MACHINE PROBLEM 1

DUE DATE: JANUARY 31 2013, 12 mn

GENERAL INSTRUCTIONS

1) Your submission should be a zipped file named CS 11 <section> MP 1 – <your name>.zip and submitted
via e-mail to janmichaelyap@gmail.com. The contents should be your source codes (.c files) and a PDF
file containingthe external documentation of your codes.

2) The source code should also contain documentations herewith. An undocumented or poorly documented
source code may incur demerits.

3) Apart from your source code and the by-products, an external documentation should also included. The
external documentation should contain the following sections:
● Implementation – In this section, you are to describe how the solution to the problem is
implemented. You may use plain declarative paragraphs, a pseudocode (NOT your source
code), or a flowchart depicting the algorithm / procedure you used for the problem.
● Function Description – In formulating a program, you may have created some functions to
implement some parts of the code. In this section, list down all the functions created and a brief
description of what each does.
● Resources (Optional) – If you have consulted books, journals, web pages, and/or resource
persons (IF ANY) in coming up with the program, kindly cite them in this section. This section is
optional, that is, this section maybe omitted if you have independently, and without any external
assistance, formulated the solution.
● User Manual – A brief tutorial on what your program can do and how to go about with your
program.

4) The criteria for grading your MP submission is as follows:


● Functionality (60 pts.) - If a program works for all test inputs
● Documentation (30 pts.) - If your program is well documented, i.e. vital aspects of your program
have been properly described and explained
● Code Design (10 pts.) - If coding conventions (variable naming, indentations, etc.) are properly
followed

5) Assume correct input for all the problems.

6) Should there be any doubts, questions, and other feedbacks, email me at janmichaelyap@gmail.com or
consult me during class and / or consultation hours.

7) Any form of violations to intellectual property rights would be dealt with accordingly as stated in the
course requirements and rules section of the syllabus.
MACHINE PROBLEM TITLE: CODE BREAKER

The program would initially generate a four digit random number with distinct digits, i.e., no 2 digits are the same
and each digit in that number is unique. To help you with this, consult references regarding the use of the srand
function (You can use this as starting point: http://stackoverflow.com/questions/1190689/problem-with-rand-in-c).
Afterwards, the user would be prompted to guess that four digit number. The program would provide clues by
giving a number of “black” and “white” markers. A black marker is given for an exact number within the target that
is correctly placed in the proper position. A white marker on the other hand, notifies the user that a correct
number is guessed, but placed in the wrong position. If an input consists of repeated digits, and that particular
digit is part of the target, remember that a black marker over rules a white marker, assuming that one of the
repeated digits is placed over the correct position. Otherwise, only 1 white marker is given. The user would be
given 7 chances to guess that number after which the program would then reveal the target number. If the user
guesses the number and the exact positions correctly, a notification would also be printed and the program
terminates.

Sample run:

Assume target number is 1725

Chance # 1
Enter guess> 4312
2 white
0 black

Chance # 2
Enter guess> 3711
1 white
1 black

Chance # 3
Enter guess> 1711
0 white
2 black

Chance #4
Enter guess> 1732
1 white
2 black

Chance #5
Enter guess> 1723
0 white
3 black

Chance #6
Enter guess> 1725
YOU WIN!!!

Sidetask 1 (+5 pts.): Provide the user an option to change the difficulty of the game based on the number of tries
that will be given with the following options: Easy (10 chances), Average (7 chances), and Difficult (5 chances).

Sidetask 2 (+10 pts.): When playing the game, if the user enters the Konami code by pressing the up arrow key
twice, then pressing the down arrow key twice, left arrow key, right arrow key, left arrow key, right arrow key, 'b'
key, then finally the 'a' key, then your program should reveal the target number which the user can input to win
the game.

You might also like