Grandma’s Rules
Input file: GrandmasRulesIn.txt
Output File: GrandmasRulesOut.txt
You are giving a birthday party to celebrate your Grandma’s one hundredth
birthday. The cake you have ordered comes precut into n pieces. Grandma,
who has always been careful to not offend anyone, has mandated two rules
concerning the distribution of the cake:
1. Each guest will be given an equal number of pieces of
cake
2. All the pieces will be distributed
You’re not sure how many people will come to the party, but you do know that
you will only be able to satisfy Grandma’s cake distribution rules for certain
numbers of guests, G.
Write a program to determine the values of G that satisfy grandma’s rules,
for a given value of n.
Inputs
The value of n
Output
The values of G that satisfy grandma’s rules, one per line in ascending order.
Sample inputs
182
Sample outputs
1
2
7
13
14
26
91
182
LED Clock
Input File: LEDIn.txt
Output File: LEDOut.txt
Your Great Uncle Thaddeus is always late for family appointments because
he refuses to read a digitial clock, considering it the “common man’s
timepiece”. He has asked you, as his favorite family member, to write a program
that coverts the time on a digital clock into 4 decimal numbers (2 for hours,
2 for minutes) representing which LED segments would be lit on the display
at that given time. To do this a sample of a 7 bit LED display is given below
with the bit value of each segment noted. A segment value is set to 1 if
the segment is lit or 0 if not.
For example a 1 has the first and second segment lit so it is represented
in binary as:
00000110
which is equal to a decimal value of 6.
Inputs
Times given in the format HH:MMAM or HH:MMPM. If the hour is less than 10
a blank will be found in the first H position. A 999 signifies the end of
the input and should not be converted.
Outputs
The output will be 4 decimal values (2 for hours, 2 for minutes) which is
the conversion of the binary number created from the LED display for each
number in the time. The high order bit of the first hour value is set to
0 – AM and 1 – PM.
Sample input
9:35AM
6:47AM
11:18PM
999
Sample output
0 103 79 109
0 125 102 7
134 6 6 127
Save the Cookies
Input File CookiesIn.txt
Output File CookiesOut.txt
Maggie’s Uncle Sam has given her one more chance to calculate her taxes properly
before incarcerating her. Her friend Nadia has calculated Maggie’s taxable
earnings, and all that remains is to compute the taxes on these earnings.
You’ve volunteered to write a program to compute her taxes, in exchange for
a plate of those delicious cookies she bakes. A lot is at stake here, since
her impending incarceration would put you into heavy cookie withdrawal. Taxes
are calculated as:
Tax = Taxable Income * Tax rate – Subtraction Amount
where the Tax Rate and Subtraction amounts are given in the below table.
Taxable Income Tax Rate Subtraction Amount
Up to $117,250.00 25% $6,525.00
$117,250.01 to $178,650.00 28% $10,024.50
$178,650.01 to $319,100.00 33% $18,975.00
over $319,100 35% $23,357.00
Inputs
The first input is the number of tax years to be processed. This will be
followed by two inputs per tax year: the year, followed by the taxable income
for that year.
Outputs
One line per tax year processed, containing the year and the computed tax
for that year. The tax should be displayed in dollars and cents, formatted
as $x,xxx.xx
Sample input
4
2001 106251.67
2002 57122.66
2003 461986.34
2004 50123.00
Sample output
2001 $20,037.92
2002 $7,755.67
2003 $138,338.22
2004 $6,005.75
As I Was Going to St. Ives
Input File: StIvesIn.txt
Output File: StIvesOut.txt
As I was going to St. Ives,
I met a man with seven wives.
Each wife had seven sacks.
Each sack had seven cats.
Each cat had seven kits.
How many were there going to St. Ives?
We shall generalize this problem, assuming the traffic was merging so that
all these char-
acters were going to St. Ives! The travelers might be different and the numbers
might be
different.
Inputs
The description of each traveler appears on a separate line beginning with
the name and followed by how many of the next traveler it can hold. The last
traveler can obviously hold only 0 of the next (non-existing) traveler. Assume
that otherwise only positive integers are used and there will be no overflow.
Names may be up to 20 letters in length. There will be at least one traveler
and possibly many different travelers.
Outputs
Indicate how many travelers in all are going to St. Ives. Format as in the
sample
output.
Sample input:
man 7
wife 7
sack 7
cat 7
kit 0
Sample output:
There are 2801 travelers going to St. Ives.
The Beasts
Input File BeastsIn.txt
Output File: BeastsOut.txt
Mild-mannered Mr. Hwmbo collects baseball cards and keeps them in a folder
sorted by the players’ names. There are only two things that get him angry:
pens that skip and grandchildren who drop his baseball cards. After a visit
from his grandchildren, Mr. Hwmbo is angry, and not because his pen is skipping.
The “beasts,” a group name he uses for his grandchildren, have done their
thing and several cards are out of order.
Your mission, should you decide to accept it, is to write a program to identify
which cards are out of order, and to rearrange the cards in sorted order.
Inputs
The first input is the number of cards, an integer, followed by the players’
names in shuffled order, one name per line.
Outputs
Two groups of players’ names, one name per line. The first group of names
will be the names of the players who are out of alphabetic order, ordered
as they appeared in the shuffled deck. The second group of names will be
all the players’ names, in correct alphabetic order. Each group will be preceded
by the number of players named in the group.
Sample input
9
Brooks, John
Tracy, Alice
Davis, Joseph
Green, Mike
Ingram, Albert
Brooks, Ken
O’Mara, John
Vasquez, Tom
Zenick, William
Sample output
2
Tracy, Alice
Brooks, Ken
9
Brooks, John
Brooks, Ken
Davis, Joseph
Green, Mike
Ingram, Albert
O’Mara, John
Tracy, Alice
Vasquez, Tom
Zenick, William
Word Search Anyone
Input File: WordSearchIn.txt
Output File: WordSearchOut.txt
Your family asks you to babysit for your beloved 7 year old cousin Eunice.
She is an adorable child who always needs to be kept busy or else she will
wreak incredible havoc. Since Eunice has just learned to read, she enjoys
doing puzzles that search for words that are hidden in a two dimensional
square grid of letters. The words may be located vertically, horizontally,
or diagonally, and even in reverse order. For this problem you are
given a two dimensional grid of letters and a word to search for. Help Eunice
by outputting the location of the word's first letter, giving
its row (1-max number of rows) and column (1-max number of columns) .
Inputs
The first line of input will contain the word (in uppercase) you are
searching for in the grid. A square grid of uppercase letters (no spaces).
Assume the word does
appear in the grid.
Outputs
The row and column values for the location of the word’s first letter separated
by commas.
Sample input
CONTEST
DUBUEMTLEP
IEVNEITCSA
EIOWEIOLZV
EUXNBNPXNW
OGPETXNIEO
NVKESENGKA
IBSENSLTIA
PTEOELSITY
WEENIBNSLZ
NIBELSTIYE
Sample output
2, 8