This assignment aims to give you practice in:
You Chew is a game played by packs of celebrities who are living in various jungles and desert islands around the world. The winner of You Chew gets to eat a 3 course meal for dinner, while the rest of the players are forced to forage for food or starve.
You Chew is played by rolling five 9-sided dice. The dice have the integers 1 to 9 on their faces.
The player who can come up with the maximum score from the dice roll first, using valid rules only, is the winner.
Your program will be given one and only one line of input. This line of input will specify a You Chew dice roll. In other words the line of input should contain 5 integers between 1 and 9 inclusive.
Your program should produce one and only one line of input. This line of output should describe the best You Chew possible score for the input dice roll. 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 reference implementation is available which provides the correct output line for any input line.
The score for a You Chew dice roll is calculated using these rules:
|Any throw||Sum of dices faces||9,3,4,3,6||25||sum|
|2+ dice showing the same face||14 + 2 * face||1,3,4,3,6||20||pair of 3's|
|3+ dice showing the same face||15 + 3 * face||7,9,9,4,9||42||three 9's|
|4+ dice showing the same face||16 + 4 * face||1,1,8,1,1||20||four 1's|
|5 dice showing the same face||17 + 5 * face||6,6,6,6,6||47||five 6's|
|2+ dice showing the same face and 2+ other dice showing the same face||13 + 2 * face1 + 2 * face2||3,3,5,4,5||29||pair of 3's and a pair of 5's|
|3 dice showing the same face and 2 other dice showing the same face||15 + 3 * face1 + 2 * face2||8,1,8,1,8||41||three 8's and a pair of 1's|
|4 sequential dice faces||25 + highest face in sequence||3,1,1,4,2||29||short sequence 1..4|
|5 sequential dice faces||37 + highest face in sequence||6,3,4,7,5||44||long sequence 3..7|
In You Chew the highest scoring rule that can be applied is chosen.
Occasionally multiple rules will produce the same score. In this case the rule with the alphabetically first description is used. There is always a unique correct output for any input line.
You should check your understanding of these rules using the reference implementation. The reference implementation should always produce the correct output for any input. You should match its behaviour EXACTLY.
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 (5 numbers) and it should produce exactly one line of output exactly as in the example below. If you program is named youChew it should behave EXACTLY as below.
./youChew 8 8 8 8 8 You Chew score is 57: five 8's. ./youChew 5 6 4 8 3 You Chew score is 31: short sequence 3..6. ./youChew 2 2 9 2 2 You Chew score is 24: four 2's. ./youChew 1 2 1 3 1 You Chew score is 18: three 1's. ./youChew 7 9 7 8 7 You Chew score is 38: sum. ./youChew 5 4 3 9 9 You Chew score is 32: pair of 9's. ./youChew 5 4 3 9 4 You Chew score is 25: sum. ./youChew 5 4 3 6 4 You Chew score is 31: short sequence 3..6. ./youChew 5 7 3 1 9 You Chew score is 25: sum. ./youChew 5 7 3 apple Invalid input: 5 integers 1..9 must be supplied. ./youChew 5 7 3 1 -9 Invalid input: 5 integers 1..9 must be supplied. ./youChew 5 7 3 1 Ctrl^d Invalid input: 5 integers 1..9 must be supplied.
Your C program should be placed in a single file named youChew.c
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.
Questions about the assignment should be posted there so all students can see the answer. If you need an urgent reply also e-mail Aarthi.
Use an array to store the 5 input integers.
Use scanf to read the 5 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 sum rule. Then try the pair rule.
Remember your program is going to be automatically marked so be careful to produce exactly the desired output.
Submit early so you can see the results of the submission auto tests in case they reveal problems.
You must keep notes on your blog every time you work on this assignment.
How to Blog
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.
Here is an indicative marking scheme.
|100%||all inputs handled correctly, beautiful C code|
|90%||most inputs handled correctly, very readable code|
|80%||7 rules applied correctly, very readable code|
|70%||5 rules applied correctly, readable code|
|55%||2 rules applied correctly, tried to make code readable|
The lecturer may vary the assessment scheme after inspecting the assignment submissions but it will remain broadly similar to the description above.
Remember your program is going to be automatically marked so be careful to follow the desired output.
Submit early so you can see the results of the submission autotests in case they reveal problems.
The bonus part of the assignment should be submitted separately to the standard part.
Submit the standard part of the assignment using this give command:
give dp1091 assign1 assign1.cTo just run the automarking tests without submission run
~dp1091/bin/autotest assign1 assign1.c
You can find the test cases for the autotests here
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.