Introduction

Your task in this assignment to write a C program which does the scoring for little known game of You Chew

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 Rules

The score for a You Chew dice roll is calculated using these rules:

Pre-condition Score Formula Example Example Score Example Description
Any throw Sum of dices faces 9,4,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 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 29 2 2
You Chew score is 24: four 2's.
./youChew 1 2 1 3 1
You Chew score is 18: three l'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 94
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

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.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.