SRU-Style (and beyond) Questions
Question 1: Partial-Summable Numbers. We (and only we) shall say an integer is partial-summable if one can split the number into a non-empty left-hand side and a non-empty right-hand side, and the sum of the digits on the two sides is equal. So, the number 39264 is partial-summable (3+9 = 2+6+4), but 3926 is not. Read in an integer and output YES if it is partial-summable, along with two actual sums which prove this, and NO otherwise.
Question 2: Zero-Summable Numbers. We (and only we) shall say an integer is zero-summable if one can sum each digit in that integer or that digit's negation to total zero. So, the number 178 is zero-summable (1+7-8), but 177 is not. Read in an integer and output YES if it is zero-summable, along with an actual sum which proves this (if more than one exists, any one will do, with the digits in any order), and NO otherwise.
Question 3: Pascal Numbers. In Pascal's Triangle, as you all know, every row begins and ends with a 1, and every number between these 1's is the sum of the two numbers above that number in the triangle. So the first row is "1", the second is "1 1", the third is "1 2 1", the fourth is "1 3 3 1", and so forth. We (and only we) shall say a number is a Pascal Number if it is the sum of a row in Pascal's triangle. Thus, for example, 8 = 1+3+3+1 is a Pascal Number. Read in an integer and output YES if it a Pascal Number, and NO otherwise.
Question 4: Infinite Exponentiation, Finite Answer. Read in a positive floating point number y and output the positive floating point number x such that the infinite exponentiation of x equals y, that is: x^(x^(x^(x^(x^(x^(x^(x^(x...)))...) = y.
Question 5: Random Tic-Tac-Toe. Start with an empty 3x3 Tic-Tac-Toe board. On each step, randomly select whether X or O moves, then randomly place that piece on the board (removing any prior piece at the given location, if necessary). Stop when either X or O has 3 in a row. Using Monte Carlo methods, output the average number of moves expected in such a game.
Question 6: They Call it "Luck". Often in sports, people confuse expected results as lucky (or unlucky) streaks. Read in a batter's hitting percentage (a number between 0 and 1, usually around .275, or .175 for the Pirates), and (using Monte Carlo methods, and assuming a batter gets 400 at-bats in a season) output a table with two columns -- the first column is the length of the hitless streak (number of consecutive at-bats without a hit), starting with 1 and increasing by 1 on each row thereafter, and the second column is the likelihood that a streak of that length or longer occurs in a season. Print out the table until the value in the second column falls below 5%.
Question 7: Word Search. Read in lines forming a
word search, followed by a blank line, followed by a term to search for.
Output the starting location (row,col, where 0,0 is the top left) of any
occurrence of that word in the puzzle, or "not found" if the word does
not occur in the puzzle.
Sample input:
DOGLBEAR
WORMERAT
MOUSEEOX
EEL
Sample output:
2,5
Question 8: Spiral Sentences [ Borrowed from
http://hs1996.csc.lsu.edu/vetprobs96.html ]
Write a program which will receive as input two data lines. The first line of
input will be a string of characters. The second line of input will be a
positive integer, N. The program should print out the input string repeatedly in
the form of a square spiral, until a total of N characters have been printed.
All blanks in the input string should be replaced with the character '+' to
give the arms of the spiral a more connected appearance. Put the character '*'
between successive appearances of the string. The input string will be no more
than 35 characters; N will be no more than 200. The arms of the spiral should be
separated by one blank column/row (see illustration). The number of blank lines
between the output line 'SPIRAL SENTENCE:' and the topmost arm of the spiral
does not matter; the number of blank columns between the left edge of the screen
and the leftmost arm of the spiral does not matter. The position of the
centermost character of the spiral on the page does not matter.
Sample Input:
OLD KING COLE WAS A MERRY OLD SOUL
100
Sample Output:
+GNIK+DLO*LUO
C S
O LO*LUOS+D +
L D
L D
E + OC+GN O L
+ K L I + O
W I E O K Y +
A N + LD+ R Y
S G W R R
+ + AS+A+ME R
A
C E
+ OLE+WAS+A+M
M
ERRY+OLD+
Good Luck!!!!
DK