Permutations (25 total points)

FAMAT 2010 State Convention
Computer Programming Competition
 This one-hour computer programming competition will consist of a collection of problems,
each of which will require students to write a program that displays correct output for
each input value or set of input values provided by the judge. Each problem's value is
displayed in the problem. Problems may be solved in any order.
 Each school is limited to one team of three members and must supply its own computer and
necessary power cables. Acceptable programming languages are BASIC, Pascal, C/C++, and
Java. No calculators or cell phones are permitted in the room. In addition, all writing
implements must be approved before the contest. One programming language reference
book is allowed. Java programmers may use the Java API's instead of a reference book.
All reference material must be approved by the judges before the contest. Please do not
bring textbooks or example books that include sample programs.
 Each program has multiple input lines. Each program may be run once and must run
continuously for all input lines. Points are assigned by the correctness of each output line.
Partial credit is possible. If, in the opinion of a judge, the data has been entered incorrectly,
a restart is possible. No additional programming or corrections will be permitted before any
additional runs.
 If you wish to have a problem graded, one member of your team should raise his/her hand
and wait for a judge to come to your area. The judge will provide input and will check to
make sure your program displays the correct output for the value(s) provided.
 Whenever you ask to have a problem judged, the judge must initial your score sheet in the
appropriate location to indicate whether or not the problem was solved correctly and enter
any scores that have been earned.
 Unless otherwise indicated, numerical input and output values will be real numbers, and
string input values will not exceed 100 characters in length.
 Round-off error in output values will be ignored, provided the output is sufficiently accurate
to determine that it is the correct answer.
 Maximum run time for any submission is 1 minute.
 All programming must STOP when the judges call time.
opportunity to grade a SINGLE program after that time.
You will have one additional
 All DISPUTES will be handled in the testing room by the judges. All decisions of the judges
are final.
 Places will be determined as follows: Highest Score, Sudden Death (first points missed),
Submission Time.
 The sample input and output accompanying each problem do not necessarily test all possibilities.
FAMAT STATE CONVENTION 2010
Computer Programming
Scoring Sheet
Place
School Id:
School Name:
Captain Name and ID:
Member 1:
Member 2:
1
2
3
4
5
Total
1.
2.
3.
4.
5.
6.
7.
8.
Enter total points and initials in each subsection. When problem is finished, total
each line.
1) Codes
(25 pts) Billy-Bob was excitedly reading a book on the properties of positive numbers.
He decided to combine these numbers into rational numbers and then to create
polynomials with these numbers as roots. To decode his work, factor each polynomial,
find and reduce each rational root, and then check the numerator and denominator to see
if it is any of the following:
1: perfect square
2: perfect cube
4: perfect number
8: triangle number
16: Fibonacci number
Report your answer as follows. For each of the numerator and the denominator, sum the
code for each property that applies and then report that sum in hexadecimal.
The input will consist of the degree, n, followed by n+1 integer coefficients.
For each line of input, the output will consist of n lines of data consisting of 3 values: the
root, the code for the numerator and the code for the denominator. If a root is not
rational, output NR. If no codes apply, output the root and NC.
input:
2,18,-63,40
3,1,-1,1,-1
output 1:
5/6 10 4
8/3 6 18
output 2:
7: NC
NR
NR
( etc. Total of 5 data sets)
2) Triangle Solver
C
(25 pts) Write a program to solve
a
triangles. There will be 4 lines of
b
input. Each input will consist of 6
parts of a triangle. Unknown parts
B
c
A
will be entered as -1. The output will
be all 6 parts, accurate to two decimal
places. (You may display as many digits as you want, but we will only look at first two
decimal points. You can truncate, round or leave your answer alone) Angles will be
measured in degrees.
Input and Output will be in the following order A,B,C,a,b,c. Triangle is NOT drawn to
scale. If triangle is impossible, output: DNE. If several triangles are possible, output all
possibilities.
SAMPLE DATA
input:
A,B,C,a,b,c
90,-1,-1,-1,3,4
-1,-1,-1,2,3,10
ouput
90, 36.869, 53.130, 5, 3, 4
DNE
( etc – 4 lines of input data)
3) Display (25 pts)
A school has a digital display board at the main entrance. The board has an 8x8 grid of
light bulbs that are used to create messages for the community. The bulbs are laid out as
in the sample diagram. Bulb 1 is in the lower left-hand corner. You are writing a
program to help test the board's display. You will be told which lights are on, and then it
is your job to determine how many 2-by-2 blocks of lights are on. For example, if the 10
bulbs at locations 25-28, 17-19, 9, 10 and 1 were on, then there would be three square
blocks lit: 25, 26, 17 and 18; 26, 27, 18 and 19; and 17, 18, 9, 10.
57 58 59 60 61 62 63 64
49 50 51 52 53 54 55 56
41 42 43 44 45 46 47 48
33 34 35 36 37 38 39 40
25 26 27 28 29 30 31 32
17 18 19 20 21 22 23 24
9 10 11 12 13 14 15 16
1 2 3 4 5 6 7 8
Input: Five sets of data. Each set consists of a integer n, which indicates how many data
elements follow, and then n data elements in the range of 1-64 which represent which
bulbs are to be turned on. The data sets are cumulative. Once a bulb is turned on, it stays
on for the entire program.
Output: the number of 2x2 blocks that are lit (5 data sets)
Sample:
Input #1 : 8, 3, 1, 9, 10, 11, 19, 18, 12
Input #2 : 4, 15, 14, 22, 23
Input #3 : 4, 31, 32, 24, 16
Input #4 : 2, 21, 5
Input #5 : 2, 20, 13
Output #1: 1
Output #2: 2
Output #3: 4
Output #4: 4
Output #5: 7
4) Compress (25 pts.)
You are part of a programming team that is writing a compression program. A "block" is
a series of 2 or more adjacent elements of an array that have the same value. You are to
write a program that counts the number of blocks in a given array.
Input: There will be 5 lines of input. Each line will consist of an integer, n, that
represents the number of data elements to follow and then n integers.
Output: The number of blocks in the array
Sample
Input: 6, 1,2,2,3,4,4
Ouput: 2
Input: 5, 1,1,2,1,1
Ouput: 2
(etc. 5 data sets)
5) Find and Sum (25)
Given a string, return the sum of the digits appearing in the string. Digits may appear as
either numerical digits (i.e. 0, 1,2,3,4,5,6,7,8,9) or as words (ZERO, ONE, TWO,
THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE). Words must be contiguous and in
capital letters. In addition, digits may also be negative
(i.e. -1, -2, -3, -4, -5, -6, -7, -8 or -9) and so may words (NEGATIVEONE,
NEGATIVETWO, etc) Negatives and –'s are cumulative. Ignore all others letters.
(There will be NO lowercase L's!)
Input: A string of no more than 40 characters.
Output: The sum of the digits.
Sample
Input: 123xyNEGATIVENEGATIVEONEyx
Output: 7
Input: ONETWO11THREE-4
Output: 4
Input: -ONENEGATIVE1
Output: 2
(etc. 5 data sets)
6) Artistic
You are contacted by a graphic designer who is in charge of creating large murals. He
has noticed that there seems to be a great deal of wasted paint after each job, so he is
contacting you to write a program to calculate the amount of paint needed for each job.
Your program will take a set of points represented by a set of ordered pairs and returned
the area of the polygon enclosed by those points. The input line will consist of an
integer, n, telling how many points are in the set, and n sets of ordered pairs of doubles.
The output will be the area enclosed. The points are guaranteed to be in order. Display
the output to the full accuracy of your machine. Do not round.
Input: 3,0,0,1,0,0,1
Ouput: 0.5
Input: 5,2,-4,5,2,3,7,-4,5,-6,-2
Output: 81
(etc. 5 data sets )
7) Maximum Bridge Length (25)
Consider the left-most and right-most appearances of some value in an array. The
"Bridge Length" is the number of elements between the two values, including the end
values. A single value has a "Bridge Length" of 1. Return the largest span found in the
given array. The input will be an integer, n, which will indicate the number of elements
in an array. This integer will be followed by n integers.
Input: 5, 1,2,1,1,3
Output: 4
Input: 7, 1,4,2,1,4,1,4
Ouput: 6
(plus more. Total of 5 data sets)
8) Trivia Questions
Output the following information
1) Last name of the current president of FAMAT, the region to which your school
belongs AND your Region Director. (Region must match student ID)
2) Last name of the current student president of FAMAT
3) What is the maximum possible score for a single team in an Alpha Bowl if all
questions are answered correctly in the 4th minute?
4) What is the last name of two previous Mu Alpha sponsors who were honored by
having a state-wide test named after them?
5) What is FLSAM?
Judges Scoring Information – Run all Data
square: 1,4,9,16,25,36,49,64
cube: 1,8,27,64
perfect: 6,28,496,
triangle: 1,3,6,10,15,21,28
Fibonacci:
1: perfect square
2: perfect cube
4: perfect number
8: triangle number
16: Fibonacci number
1) Codes
1
2
3
4
5
NOTE: varying scoring values!!
Input: 1,3,-1
Output:
(note: 1/3
11011
1/3, 1B, 18
pts
total
1B 11000 18)
5
5
Input: 2, 243, -684, 256
Output:
4/9, 1, 1
64/27, 3, 2
2
2
4
Input: 2, 675, -667, 84
Ouput:
21/25, 1B, 1
4/27, 1, 2
2
2
4
Input: 3, 24, -46, 29, -6
Output:
1/2, 1B, 10
2/3, 10, 18
3/4, 18, 1
2
2
2
6
Input: 3, 7, -11, 14, -22
11/7 NC, NC
NR
NR
2
2
2
6
2) Triangle Solver Note this problem has 4 inputs but there are 5 lines
of output. Input #3 has 2 outputs
1
Input #1: 42, -1, -1, 22, 12, -1
Output#1:
42, 21.4063, 116.5936, 22, 12, 29.40
5 pts
2
Input #2: 85, -1, -1, 15, 25, -1
Output#2:
DNE
5 pts
3
Input #3: 20.5, -1, -1, 12, 31, -1
Output 3 and 4:
20.5, 64.783, 94.7167,12,31, 34.1493
10 pts
4
20.5, 115.2167,44.2832,12,31, 23.9243
5
Input #4: -1,-1,-1,8,19,14
Output#4:
22.0750, 116.8007, 41.1241, 8, 19, 14
5 pts
3) Display (25 pts 5 pts each)
Test Data
Input #1: 8, 26, 27, 19, 20, 11, 12, 4, 5
Input #2: 6, 14, 22, 30, 38, 39, 23
Input #3: 1, 31
Input #4: 3, 33, 35, 34
Input #5: 2, 21, 13
5
5
5
5
5
Output #1:
Output #2:
Output #3:
Output #4:
Output #5:
1
1
3
4
7
57
49
41
33
25
17
9
1
58
50
42
34
26
18
10
2
59
51
43
35
27
19
11
3
60
52
44
36
28
20
12
4
61
53
45
37
29
21
13
5
62
54
46
38
30
22
14
6
63
55
47
39
31
23
15
7
4) Compress Test Data
5
Input: 5, 1,1,1,1,1
Output:
1
5
Input: 3, 1,2,3
Output:
0
5
Input: 10, 2,2,1,1,1,3,1,1,2,2
Ouput:
4
5
Input: 0
Output:
0
5
Input: 13, 0,0,0,2,2,1,1,1,2,1,1,2,2
Output:
5
64
56
48
40
32
24
16
8
5) Find and Sum (25)
Test data
Input
1
x123456789y
2
ONETWOTHREEFOURFIVESIXSEVENEIGHTNINE
3
1TWO3FOURNEGATIVESIX
4
O1NET2WOTHREE3FO4URNNEGATIVE4
5
NEGATIVENEGATIVENEGATIVIEFIVE
Output
45
45
4
9
-5
pts
5
5
5
5
5
6) Artistic (25 pts)
Test Data:
Input 1: 4,3,-7,-1,1,0,5,-6,2
Input 2: 4, 6,0,8,3,1,9,-10,-1
Input 3: 8,6,0,3,3,0,6,-3,3,-6,0,-3,-3,0,-6,3,-3
Input 4: 16, 6,0 ,5,2, 4,7, 3,9, 0,15, -3,9, -4,7, -5,2, -6,0, -5,-2, -4,-7, -3,-9, 0,-15, 3,-9, 4,-7, 5,-2
Input 5: 5, 7.23, 2.1, 3.62, 7.37, -2.1, 3.7, -2.2, -1.8, 2.11, -4.76
pts
Output 1:
28.5
5
Output 2:
91
5
Output 3:
72
5
Output 4:
162
5
Output 5:
69.79495
5
(accurate to 2 decimal places at least)
7 Maximum Bridge Length
Input 1: 5,1,2,1,1,3
Input 2: 7, 1,4,2,1,4,1,4
Input 3: 0
Input 4: 3, 3,9,3
Input 5: 10, 1,2,3,4,5,1,2,3,4,5
Output 1:
Output 2:
Output 3:
Output 4:
Output 5:
4
6
0
3
5
pts
5
5
5
5
5
8. Trivia Questions 30 pts (Be lenient with spelling)
1
2
3
4
5
Friedlander plus one of the following
1) Pridgen 2) Altman 3) Vong 4) Wiley 5) Vichez
Ross
192 (note: sliding scale)
Nunn Dostel
Florida Student Association of Mu Alpha Theta
pts
6 3 for Fried
3 for reg and name
6
6
6
3 points for each
6