¦ 34 ¦ 21 ¦ 32 ¦ 41 ¦ 25 ¦
¦ 14 ¦ 42 ¦ 43 ¦ 14 ¦ 31 ¦
¦ 54 ¦ 45 ¦ 52 ¦ 42 ¦ 23 ¦
¦ 33 ¦ 15 ¦ 51 ¦ 31 ¦ 35 ¦
¦ 21 ¦ 52 ¦ 33 ¦ 13 ¦ 23 ¦
ifmanwasThe coded message is obtained by reading down the columns going left to right. For example, the message above is coded as:
haveaniceday hae and via ecy
feedthedog fto ehg ee dd
chillout clu hlt io
1. Write a program to convert roman numerals into their arabic equivalent.
Read one or more roman numerals from standard input. Process one line at a time. Each input line contains only one roman numeral, starting in column one. Assume the characters are all upper case with no embedded blanks.
The arabic equivalent of each input roman numeral is displayed on standard output, starting in column one.
Here are the arabic equivalents for roman symbols:
The "basic" roman
The "auxiliary" roman symbols
I X C M V L D
1 10 100 1000 5 50 500
Convert the roman numeral to arabic processing the symbols from left to right according to the following rules:
ERROR HANDLING REQUIREMENTS
In each of the error conditions below, display the given message and skip the numeral and continue processing the next line.
"Invalid character in input. Valid characters are I,V,X,L,C,D,M."
2 ABCGiven a seven digit telephone number, print all 2187 possible "words" that number spells. (They may not be real english words, but just some sequence of characters). Since the digits 0 and 1 have no alphabetic equivalent, an input number which contains those digits should be rejected. The input will be one or more seven digit integers from standard input.
The problem can be made a bit more challenging by outputting more than one word per line. Usually about seven words will fit on a line.
th 2.37% in 2.20% fj 2.00% ... (6 per line)
(100 letter pairs)
Output represents 73.44% of 23641 letter pairs.
Accept any number of lines of input entered from standard input. A valid line contains a word and a number. The word comes first, and is up to twenty alphabetic characters (A-Z) in upper or lower case. The word may be preceeded and followed by any number of blanks. The number is a decimal integer greater than zero, and may be followed by any number of blanks or a return. Input is terminated by EOF character. For each input word, print all possible "subwords" that have as many characters as specified by the number. A "subword" is a n-letter word comprised of only characters that are found in the given word. If you are familiar with the game Scrabble, it's as though the input word is your pool of letters, and you want to find all possible arrangements of n letters from your pool. .nf For example, CAT 2 would produce CA CT AC AT TA TC and DOG 1 would produce D O G and BIRD 3 would produce BIR BID IRD RID DIR RIB ... Note, that we are producing combinations WITHOUT replacement, so in the BIRD 3 example, BBB and RRR are NOT possible subwords. The output should echo the input line to standard output, followed by the list of subwords, one word per line, left justified. Each set of output words should be followed by one blank line. The program should respond to invalid input by echoing the input line to the output, and then issuing a one line message indicating the nature of the error:
"Illegal character in number"
"Number greater than length of word"
"Word longer than 20 characters"
A bowling match consists of ten frames. Each frame except for the tenth consists of one or two balls, or attempts to knock down the ten pins at the end of the alley. Doing so on the first ball of the frame is called a strike, and the second ball of the frame is not rolled. Knocking down all ten pins with both balls (having left some up with the first ball) is called a spare. If both attempts to knock down the pins leave some standing, the frame is called an open frame. A spare in the tenth frame gives the bowler one extra ball; a strike in the tenth gives him or her two extra balls. A bowling score is computed as follows. A strike counts as 10 points plus the sum of the next two balls. A spare counts as 10 points plus the next ball. Any other balls merely count as themselves, as do any bonus balls rolled as a result of a strike or a spare in the tenth frame. Suppose for example that the sequence of balls was
9 1 0 10 10 10 6 2 7 3 8 2 10 9 0 9 1 10The score for the ten frames would be
Frame scoreWrite a program to accept from standard input the scores for a sequence of balls and output the scores for the ten frames. There may be multiple lines of input, where each input line will be the scores for one player. The scores will be separated by one or more blanks. You may assume that the number of scores on the line is valid.
Cobbletown has a lottery (a small version of California's Lotto) in which players guess four number between 1 and 9. Larry likes to play and thinks he has a scheme to pick winning numbers. He keeps a history of past winning numbers in a text data file. Larry thinks that if a number hasn't occurred recently then it is more likely to show up as a winner. (Obviously Larry isn't familiar with the statistical fact that each number has an equal likelihood of being picked, since each week's drawing is an independent event). Larry wants us to write a program to assist him in his wacky scheme.
The lotto history data: a file of unknown length, with four integers per line. Each integer is in the range 1 to 9.
1. The four least frequently occurring integers in the history data. (That is, counting all the weeks, the four numbers that appeared fewer times than any others).
2. The one integer with longest time since last occurrence. (That is, if you count backward from now, the number for which you count the most weeks since it occurred).
(You may assume that no data validity checking is required).
Note: To make the problem easier, if there is a tie between two or more numbers for fourth place, it doesn't matter which one is printed.
2. Determine and display the integer which has gone the longest without appearing in a winning sequence.
At a minimum your program must work correctly for the following sample data.
1 2 3 4
5 6 7 8
8 7 6 5
1 5 6 7
4 3 2 1
|Write a program to play a simple "adventure"-style interactive game. The adventure world consists of up to five castles each of which has up to seven rooms (35 total). Each room has a treasure, worth a certain number of points, and a creature guarding the treasure. The treasure can be captured by bluffing or fighting the creature. Bluffing always has a 30% chance of succeeding. The odds for winning a fight vary from creature to creature. The object of the game is to visit different rooms and gain as many treasure points as possible. The player begins with 9 lives and each fight lost costs a life. (There's no penalty for losing a bluff.) When all the lives (or all treasures) are gone the game ends. The adventure world information (like castle and room names) is stored in a text file. The program must read the text file and create a data structure to represent the world. (HINT: Use a record structure for each room.) The program must handle interaction with the player, including display of menus for castle and room choices, display of current lives and treasure points accumulated, and responding to one-character commands to fight, bluff, or move around the world.|
Sudoku Solver assignment
Last modified on 05/13/2001 12:36:16