Great Computer Challenge
Scientific Programming
Level IV
Your team will be scored on their solutions to the following problems.
1. “Lies, damned lies and statistics” - Mark Twain -
You are to generate a code that loads an unknown number of space delimited integers from a file called “data.txt”. Your code should compute and display the mean (average), median (middle value), and mode (most common value) for the data set. You should provide your own test data file; the judges will be providing additional files for your software to analyze.
2. Secret Agent Man
One simple method of generating a secret code (or decoding one) is called alphanumeric shift. Basically we are going to generate a unique integer value based on a simple linear shift (sample s = 8 with the index of the letter as the input (starting with a at index 0). The output character would have index at s mod 26*. For example if the encode function shift s = 8 and the input message is “hello bobby” then the mapping would be as follows:
Input character / Alphabetic Index / Index + Shift (S=8) / S%26 / outputh / 7 / 15 / 15 / p
e / 4 / 12 / 12 / m
l / 11 / 19 / 19 / t
o / 14 / 22 / 22 / w
b / 1 / 9 / 9 / j
y / 24 / 32 / 6 / g
And the output message would be “pmttw jwjjg”. Furthermore spaces must be replaced with other characters such as sequential capitals (first space = A, second = B etc) then our message would read “pmttwAjwjjg”. Lastly prepend a capital letter with the index of the shift to the beginning of the string this will allow the receiver to decode the message. For our example since the shift is 8, the 8th letter is H our message becomes: “HpmttwAjwjjg”. Write a code that accepts an index shift S from the keyboard then accepts a message from the user in plain English and then displays the encoded message to the screen.
*Mod is the remainder after dividing, so 7 % 3 = 1, 12 % 5 is 2, and 100 % 10 is 0
3. Dealers difficulty! It is possible for card experts to do a perfect shuffle. That is they divide the deck into 2 equal parts then fold them together. You are to write a code that simulates this behavior with integers. Your code will accept from the user the values N (number of integers) and S (number of shuffles) after each shuffle print the result to the screen. For example for user input of 7 and 3 the result would be. (n.b. please pay close attention to the placement of even and odd sized sub arrays,)
Initial sequence:
1 2 3 4 5 6 7
Shuffle #1:
è 1 2 3 and 4 5 6 7
4 1 5 2 6 3 7
Shuffle #2
è 4 1 5 and 2 6 3 7
2 4 6 1 3 5 7
Shuffle #3
è 2 4 6 and 1 3 5 7
1 2 3 4 5 6 7
There are no constrains to the size of N or the number of shuffles S.
4. There are only 4 amino acids right? Watson and Crick, two names that are associated with scientific greatness. Their analysis of the structure of DNA has lead to seemingly limitless scientific advancements and standing on the shoulders of those giants was George Garnow who first suggested a 3 letter code to encode the 20 standard amino acids used by living cells (not that GAA is the same as AAG).
Alanine/A GCU, GCC, GCA, GCG / Leucine/L UUA, UUG, CUU, CUC, CUA, CUGArginine/R CGU, CGC, CGA, CGG, AGA, AGG / Lysine/K AAA, AAG
Asparagine/N AAU, AAC / Methionine/M AUG
Aspartic acid/D GAU, GAC / Phenylalanine/F UUU, UUC
Cysteine/C UGU, UGC / Proline/P CCU, CCC, CCA, CCG
Glutamine/Q CAA, CAG / Serine/S UCU, UCC, UCA, UCG, AGU, AGC
Glutamic/E GAA, GAG / Threonine/T ACU, ACC, ACA, ACG
Glycine/G GGU, GGC, GGA, GGG / Tryptophan/W UGG
Histidine/H CAU, CAC / Tyrosine/Y UAU, UAC
Isoleucine/I AUU, AUC, AUA / Valine/V GUU, GUC, GUA, GUG
START AUG / STOP UAA, UGA, UAG
You code should prompt the user for the name of a text file which contains a sequence of characters that represents the building blocks of various amino acids. The code should look for the start codon(AUG) . Once it is found then the code should travel down the string processing the data until STOP has been found or if STOP is encountered first then continue until START is found. Each codon will be translated into the various amino acids in the protein between the START and STOP codons. Two run time samples follow of the same protein sequence but one encounters START first, the other encounters STOP first.
Runtime Sample data 1: Runtime Sample 2:
GGUUUUAUGAAUCCCGUUUGACCC / CCCUGAGUUCCCAAUAUGUUUGGUOutput / Output
GGU * / CCC *
UUU * / UGA STOP
AUG START / GUU VALINE
AAU ASPARAGINE / CCC PROLINE
CCC PROLINE / AAU ASPARAGINE
GUU VALINE / AUG START
UGA STOP / UUU *
CCC * / GGU *
5. 4, 3, 2, 1, LAUNCH!
You are a technician with the responsibility to perform evaluations on possible fuel mixtures for a new booster rocket. You know the properties for each component substance and how they react with one another. The rocket is designed in a way that up to two of the solid blocks of fuel can be consumed at any one time. This is called a stage. The rocket consumes one stage of fuel per time step.
The maximum amount of acceleration that the rocket can undergo without breaking apart is 1000 meters per time step. If at any point the acceleration or deceleration- that is the absolute value of the change in speed at the current time step minus the speed at the previous time step- is greater than this amount of allowable stress (1000), then the rocket will be destroyed and the solution is not valid. The data input will be an unsorted string, up to 20 characters in length, where each character ('A', 'B', or 'X') represents one unit of the respective substance. All provided fuel units MUST be utilized in the launch.
Your assignment is to design the burn of the available fuel components into stages for maximum effectiveness (height reached) while still not destroying the rocket.
Substance: Velocity at end of burn
A: 1000 meters/ time step
B: 1500 meters/ time step
X: 500 meters/ time step
A+A: 2000 meters/ time step
A+B: 3000 meters/ time step
A+X: 5000 meters/ time step
B+B: 4000 meters/ time step
B+X: 6000 meters/ time step
The data output will be a string of capital letters that create your solution, where each stage is separated by a '|' (pipe/absolute value) character, followed by a space, and then a number that represents the distance covered at the end of all stage burns. We assume all accelerations are linear and that distance traveled in one time step is = average velocity for that time step.
Distance traveled = initial velocity + ½ * acceleration * time2 but time is 1 step
Runtime examples:
Input:
BX
Output:
X|B 1250
(Explanation: this means that the X stage is fired first with final v=500 (distance traveled = (500+0)/2 = 250, then B is fired in the second stage with a final velocity of 1500, allowed acceleration is 1500-500/1.0, distance for this time step is (1500+500)/2 = 1000, thus the total distance traveled is 1250. The opposite B|X is rejected because the initial acceleration is > 1000.)
Input:
AAAABBBBXX
Output:
X|B|AA|AB|BB|AX 13000
(Explanation: X is fired, final v = 500, distance = 250
B is fired, final v = 1500, distance = 500
AA is fired, final v = 2000, distance = 1750
AB is fired, final v = 3000, distance = 2500
BB is fired, final v = 4000, distance = 3500
AX is fired, final v = 5000, distance = 4500
Total distance traveled = 13000
A|AA|AB|BB|BX|X is rejected even though it covers more distance because the final deceleration from BX to X exceeds mission maximums)
Input:
B
Output:
Fail
(Explanation: no solution exists)
Page 1 of 1
Scientific/Non-Business Programming - Level IV
Great Computer Challenge, 2011