Introduction
Your task in this assignment is to write a C program which plays the game Yum-Yum.
Yum-Yum is a popular game in some regions of Scandinavia & the Baltic. Yum-Yum starts with the creation of 6 random
numbers. Historically the numbers were produced by rolling 6 many-sided dice carved out of Walrus tusks in Scandinavia or by
drawing 6 numbered tiles from a bag of 54 carved wooden tiles in the Baltic. These days a smart phone app is usually used to
generate the numbers.
The 6 numbers are placed in front of the players in sorted (non-decreasing) order.
The players then have 30 seconds to find the highest score that they can make from the numbers using the Yum-Yum rules.
Before the 30 seconds are up they must write on a piece of a paper the rule they wish to use, and its score.
There is a precise format that must be followed exactly when writing out the Yum-Yum rule.
The player who finds the highest scoring rule wins, as long as they write it out completely correctly.
The Yum-Yum rules are described in the following table.
Rule Required Condition Score Formula Example
Case
What the Players must Write
total none x + x + x + x + x + x 3 4 5 7
Rule total - score 34.
match-2 x == x 2 * x + 19 1 3 4 5
Rule match-2(7) - score 33.
match-3 x == x == x 3 * x + 21 1 5 5 5
Rule match-3(5) - score 36.
match-4 x == x == x == x 4 * x + 23 4 4 6 6
Rule match-4(6) - score 47.
match-5 x == x == x == x == x 5 * x + 25 8 9 9 9
Rule match-5(9) - score 70.
match-6 x == x == x == x == x == x 6 * x + 27 9 9 9 9
Rule match-6(9) - score 81.
sequence-
x + 1 == x 2*x + 17 2 3 5 5
Rule sequence-2(8,9) -
score 35.
sequence-
x + 2 == x + 1 == x 3*x + 18 5 5 6 6
Rule sequence-3(5,6,7) -
score 39.
sequence-
Rule sequence-4(5,6,7,8) -
score 51.
sequence-
x + 4 == x + 3 == x + 2 == x + 1
== x
5*x + 20 1 2 2 3
4 5
Rule sequence-5(1,2,3,4,5)
- score 45.
sequence-
x + 5 == x + 4 == x + 3 == x + 2
== x + 1 == x
6*x + 21 2 3 4 5
6 7
Rule sequence-
6(2,3,4,5,6,7) - score 63.
sum-2 x + x == x x + x + 22 3 3 4 4
Rule sum-2(3+4=7) - score
32.
sum-3 x + x + x == x x + x + 29 1 2 4 5
Rule sum-3(1+2+5=8) - score
sum-4 x + x + x + x == x x + x + 38 1 2 2 3
Rule sum-4(1+2+2+3=8) -
score 47.
sum-5 x + x + x + x + x == x x + x + 49 1 1 1 1
Rule sum-5(1+1+1+1+1=5) -
score 55.
a b c d e f
a b a
a b c a
a b c d a
a b c d e a
a b c d e f a
a b b
a b c c
a b c d d
a b c d
e
e
a b c d
e f
f
a b c a c
a b c d a d
a b c d e a e
a b c d e f a f
yum-yum x + x == x && x + x == x x + 2*x + 3*x + 4*x +
5*x + 6*x
1 2 4 5
6 8
Rule yum-yum(1+4=5,2+6=8) -
score 110.
Note: x , x , x , x , x , x can be any of the numbers
Your Yum-Yum Player
Your will write a C program named yumYum.c Your program will be given one and only one line of input. This line of input will
specify the Yum-Yum numbers. In other words the line of input should contain 6 integers between 1 and 9 inclusive. The
numbers should be in sorted (non-decreasing) order.
Your program should produce exactly one line of output. This line of output should describe the best Yum-Yum rule to use for
these numbers, and its score
There is one and only one correct output line for every input line and you must output it exactly down to the last character.
A perfect Yum-Yum player (reference_implementation.py) is available. For any input numbers it will find the best Yum-Yum
rule to use for these numbers, and its score.
You should use the perfect Yum-Yum player (reference_implementation.py) to check your understanding of the rules.
Try to make your program match its behaviour EXACTLY.
Occasionally multiple rules will produce the same score. In this case the rule with the alphabetically first description wins.
There is always a unique correct (best) output for any input line.
Although its good practice to print a prompt before reading input your program should not print anything before reading its
input. Your program should read its input (6 numbers) and it should produce exactly one line of output EXACTLY as in the
examples below.
Here are some examples of how your program should behave:
dcc yumYum.c -o yumYum
./yumYum
1 3 4 5 7 9
Rule sum-3(1+3+5=9) - score 39.
./yumYum
3 3 3 5 7 7
Rule match-2(7) - score 33.
./yumYum
3 3 5 5 8 8
Rule yum-yum(3+5=8,3+5=8) - score 122.
./yumYum
1 2 3 4 5 4
Invalid input: 6 integers 1..9 in sorted order must be supplied.
./yumYum
1 2 3 4 5 42
Invalid input: 6 integers 1..9 in sorted order must be supplied.
./yumYum
1 2 3 apple
Invalid input: 6 integers 1..9 in sorted order must be supplied.
./yumYum
1 2 3 4 5
Ctrl^d
Invalid input: 6 integers 1..9 in sorted order must be supplied.
Note: The reference implementation will handle situations where this is not enough input slightly differently. In your
implementation you would need to type in less that 6 inputs, newline and then Ctr^d as shown in the example above. In the
reference if you simply type in less than 6 inputs,press enter and you will immediately get an error message. This should be
the only difference between your implementation and the reference.
Your C program should be placed in a single file named yumYum.c
a b c d e f a b c d
e f
a b c d e f
Assumptions
Like all good programmers, you should make as few assumptions about your input as possible.
You may assume you are given exactly one line of input.
You can assume this line contains at most 1024 characters.
Most testing will be on legal input lines but your program may be tested on invalid input.
If you use scanf in the obvious way your program will accept mutliple lines of input - for example reading the numbers if each
is on a separate line. This is fine - but your program will only be tested with a single line of input.
Hints
You should follow discussion about the assignment in the course forum
Questions about the assignment should be posted there so all students can see the answer. If you need an urgent reply also e-
mail Angela.
Use an array to store the 6 input integers.
Use scanf to read the 6 input integers.
Don't panic! Get the easiest rules working first. Don't worry about the inputs your program can't handle. You'll get marks for
every input it can handle.
Start with the total rule. Then try the match-2 rule.
Remember your program is going to be automatically marked so be careful to produce exactly the desired output.
Submit early & submit often so you can see the results of the submission (dryrun) tests in case they reveal problems, and
know a copy is on CSe's servers.
Blog
You must keep notes on your blog every time you work on this assignment.
How to Blog
1. Go to the COMP1911 Home Page
2. Log in with your zid and zpass
3. Click on the speech bubble icon at the bottom of the side navigation panel near your name.
4. Click on "Create Post"
Your blog should include
The amount of time you spent
Whether you were reading and understanding, designing, coding, debugging or testing.
What you learnt or achieved
Mistakes you made and how you could try to avoid or minimise them next time
Hints:
Be specific and include concrete examples of what you did. Only tutors can read your blog so you can include code
snippets
Don't panic if English is your second language or if you are not a 'great' writer. We understand and we do not expect the
next great novel of our time.
There is a 1 mark penalty for missing or trivial blogs.
Assessment
This assignment will contribute 15% to your final mark.
The assessment for the assignment recognizes the difficulty of the task.
20% of the marks for assignment 1 will come from hand marking of the readability of the C you have written. These marks will
be awarded on the basis of clarity, commenting, elegance and style. This will include using suitable variable names, using
consistent layout and indentation, breaking down the problem into functions etc. In other words, your tutor will assess how
easy it is for a human to read and understand your program.
80% of the marks for this assignment will be based on the performance of your program. It will be automatically tested on a
large number of inputs and will receive marks according to how many times it produces the correct output.
Note: We do not just use the same tests as the submission autotests. We test on a whole batch of unknown test cases. Passing
all the submission tests is a great start, but does not guarantee you will pass all of our test cases.
There is a 1 mark penalty for missing or trivial blogs.
Here is an indicative marking scheme.
100% all inputs handled correctly, beautiful C code
90% most inputs handled correctly, very readable code
80% 11 rules applied correctly, very readable code
70% 6 rules applied correctly, readable code
55% 3 rules applied correctly, tried to make code readable
0% Knowingly providing your work to anyone and it is subsequently submitted (by anyone).
0 FL for COMP1911 Submitting any other person's work. This includes joint work.
academic
misconduct
Submitting another person's work without their consent.
The lecturer may vary the assessment scheme after inspecting the assignment submissions but it will remain broadly similar to
the description above.
Originality of Work
The work you submit must be your own work. Submission of work partially or completely derived from any other person or
jointly written with any other person is not permitted. The penalties for such an offence may include negative marks,
automatic failure of the course and possibly other academic discipline. Assignment submissions will be examined both
automatically and manually for such submissions.
Relevant scholarship authorities will be informed if students holding scholarships are involved in an incident of plagiarism or
other misconduct.
Do not provide or show your assignment work to any other person - apart from the teaching staff of COMP1911. If you
knowingly provide or show your assignment work to another person for any reason, and work derived from it is submitted you
may be penalized, even if the work was submitted without your knowledge or consent. This may apply even if your work is
submitted by a third party unknown to you.
Note, you will not be penalized if your work is taken without your consent or knowledge.
Submission
This assignment is due Thursday 26th April 23:59:59 Submit the assignment using this give command:
give cs1911 ass1 yumYum.c
To just run the automarking tests without submission run
1911 autotest ass1
Late Submission Policy
If your assignment is submitted after this date, each hour it is late reduces the maximum mark it can achieve by 1%. For
example if an assignment worth 76% was submitted 5 hours late, the late submission would have no effect. If the same
assignment was submitted 30 hours late it would be awarded 70%, the maximum mark it can achieve at that time.