All the questions here are answerable very, very quickly. Team members will compete individually to determine who is the fastest at solving simple problems. This person becomes our "point man" in tournaments.
Rules: No resubmissions on wrong answers. Make one program which contains the void methods q1(), q2(),.... When you complete a method, submit it by calling out the problem number, as in "Submit q3". At that point, you may no longer work on that question. At the end of the contest we will judge all the submissions together.
You have 20 minutes.
Question 1: Read in five integers. You are guaranteed that of the five, you get three copies of one number and two copies of another number. Print out the number that has three copies.
Input: 6 8 6 6 8Question 2: Read in two words, output the longer word.
Output: 6
Question 3: Read in an integer N >= 0 followed by N positive floating point numbers, and output the largest distance from any of the floating point numbers to the largest integer smaller than that number.
Input: 5 2.3 17.213 5.23 8.53 22.336Question 4: Read in three integers and output "yes" if it is possible for a triangle to have those three values for the lengths of its sides, and "no" otherwise.
Output: 0.53 (this is the distance from 8.53 to 8.0)
Question 5: Read in the name of a regular polygon and a side length, and output the perimeter. The polygon will be a triangle, square, pentagon, hexagon, heptagon, or octagon.
Input: pentagon 19Question 6: Read in a positive integer N and output the sum of the bits representing N.
Output: 95
Input: 38Question 7: Read in a string representing a note on a keyboard without flats (so it will be one of C, C#, D, D#, E, F, F#, G, G#, A, A#, B), followed by an integer representing the number of half-steps to transpose that note upwards, and output a string representing the resulting note.
Output: 3 (because 38 = 32 + 4 + 2)
Input: C# 5
Output: F#
Rules: No resubmissions on wrong answers. Make one program which contains the void methods q1(), q2(),.... When you complete a method, submit it by calling out the problem number, as in "Submit q3". At that point, you may no longer work on that question. At the end of the contest we will judge all the submissions together.
You have 2 hours minutes.
Question 1: Read in four floating point numbers, x1 x2 y1 y2 which represent two points. Output "yes" if the line described by those two points intersects the parabola y = 2x2 - 7x + 19, and "no" otherwise.
Question 2: Goldbach's Conjecture states that every even number larger than 2 is the sum of two primes. It is unproven, but verified for very large numbers. Write a program which reads in an even number larger than 2 and outputs two prime numbers which sum to that number.
Question 3: Read in integers (terminated by a 0) representing the duration in seconds of songs. Assuming you have room for 70 minutes of music on your CD, output the length in seconds of the collection of songs which takes the maximum amount of time without taking more than 70 minutes.
Question 4: Read in a positive integer N followed by a list of N positive integers, and output the number of duplicate digits seen when you print out the numbers, without spaces, in sorted fashion.
Input: 4 332 543 13 455
Output: 6 (because the sorted list without spaces is 13332455543
Question 5: Read in a list of words, terminated
by "_end_", and output in alphabetical order all the words in the list
which have an anagram of themselves also in the list. Note that your
program must run in under 15 seconds on a 70k word list.
Question 6: A Bluggle is a rather simple creature. Its brain can be described by a string of the characters L, R, U, and D, as in LUULDR. This particular string tells the Bluggle to move (at one move per second) Left, then Up, then Up, then Left, then Down, then Right, then repeat. Read in a series of lines -- each line begins with a Bluggle brain, followed by the x and y coordinates of Bluggles with that particular brain. These are terminated by a line with one number on it, N. You are to move all the Bluggles appropriately for N seconds. Then, output the average x and y position (as integer values, with truncation) of all the Bluggles (this is called the first moment, by the way).
Input:Question 7: Referring back to the Bluggles of Question 6, here you read in the same input as Question 6, only without the Bluggle brains provided, and with the resulting first moment also provided. Your task is to derive the Bluggle brains which will generate that moment based on those inputs. This is basically the inverse of Question 6, as the following test data demonstrates (compare this to the test data for Question 6).
LRUDR 0 0 1 1
RRL 1 2
7
Output: (2,1)
The Bluggle at 0,0 moves LRUDRLR to 1,0
The Bluggle at 1,1 moves LRUDRLR to 2,1
The Bluggle at 1,2 moves RRLRRLR to 4,2
The average of these positions is 7/3,1, which in integer values is 2,1.
Input:
0 0 1 1
1 2
7
2 1
Output:
LRUDR
RRL
Question 8: A positive integer is Ryanish if its digits
form a palindrome (same forwards as backwards) and the sum of its
digits is an integral factor of itself. Read in a number N and output
the Nth Ryanish number (starting from 1, so there is no 0th one).