In medical diagnosis, a number of problems occur concerning the correct assignment of symptoms to a specific disease.
In a clinical study, some neurologists specialized in
the Parkinson disease assigned a letter value (A,B,C..) for each one of
9 Parkinson symptoms (swinging arms, speech, independence ...) for different
patients.
Each patient record is a sequence of 9 letter values.
$’s are included at various places in the records to make them easier to
read, but have no other significance.
The sample input and expected output shown below illustrate
many valid, and some invalid, record formats.
An algorithm is set to check the development of the disease
for each patient based on the patient's record (The collection of the 9
values).
3 sets of 3 values represent some inter-related symptoms,
and are represented as the 3 corners of a triangle.
The first letter value is the first corner of the first
triangle, the second value is the first corner of the second one ...
The length of each of triangle edge is then computed
according to a pre-defined schema:
The unit step between A and B is 1
between B and C is 2
between C and D is 3
between D and E is 4
...
between A and G is 21
Each of the triangle's edge is then used to compute the value of the triangle.
Value of the triangle = (edge1)² + (edge2)² + (edge3)² + 1
Then, the 3 values of the symptom groups are then summed up. The patient is considered to have the Parkinson disease if the final value is a prime number. Otherwise, the patient is in good health.
To better understand the procedure, consider the correct patient's record A$AA$$BB$AC$BA. First look at the symptom groups, and the calculations performed:
A
A
A
/ \
/ \
/ \
1 / \3
1 / \1
0 / \ 0
/ \
/ \
/ \
B------C
B--------B
A--------A
2
0
0
Triangle1 is 15
Triangle2 is 3 Triangle3
is 1
The final value of this record is 19, which is a prime number; thus showing that the patient has the Parkinson disease.
Input file:
The sample input file contains a single data record per line, possibly preceded and/or followed by spaces. No line may contain more than 70 characters, but the data record might contain illegal characters, and more or fewer than 9 letter values. The input file is terminated by an end of file.
Output file:
The output file should include the display of the data record and a statement of invalid record in case it is so. If the record is legal, the output should specify if the patient is in good health, or has the Parkinson disease.
Sample Input:
ABCD
ABCDEFGH
A$$$BCD$HJUY$Q
AFW#GFDGFD
ABCD$EFG$$KP
AAABBACBA
Sample Output:
The data sequence ABCD is invalid.
The data sequence ABCDEFGH is invalid.
The data sequence A$$$BCD$HJUY$Q signals that patient
has Parkinson disease.
The data sequence AFW#GFDGFD is invalid.
The data sequence ABCD$EFG$$KP signals that patient is
in good health.
The data sequence AAABBACBA signals that patient has
Parkinson disease.