|
1. LETTER V Write a program that will create the letter V of any even size N _ 20. Test your program for N = 8, 10 Sample Run Enter an even number: 6 ** * ** * ** * ** * *** * Enter an even number: 8 ** * ** * ** * ** * ** * ** * *** * 2. WINNING FORM When you flip a coin you win every time it comes up heads and lose if it comes up tails. Assume the first toss is always a head and after four more tosses you note whether you are ahead (more wins than loses). If you begin with a win and end up ahead you are in WINNING FORM. What are the chances that when you toss a coin 5 times and win on the first toss that you are in WINNING FORM? Write a program that will simulate the experiment of tossing a fair coin four times after the first head and checking if you are in WINNING FORM. Remember to begin with a win. To estimate your chances of this happening, repeat the experiment 1000 times and report the number of times you are in WINNING FORM. Sample Run Beginning with 1000 wins on the first toss, you are in WINNING FORM a total of 688 times. 3. TRIPLETS Write a program that lists all triplets (groups of size three) that can be selected from a group of size N. (Assume N<=26.) Use a letter of the alphabet to identify each person. Print three letters to represent each triplet and compute the total number of triplets that can be formed from a group of size N. Note that ABC is the same triplet as BAC or CAB. Test your program for group size N = 7 and N = 9. Sample Run Group size = 7 TRIPLETS FROM A GROUP OF SIZE 7 ABC ABD ABE ABF ABG ACD ACE ACF ACG ADE ADF ADG AEF AEG AFG BCD BCE BCF BCG BDE BDF BDG BEF BEG BFG CDE CDF CDG CEF CEG CFG DEF DEG DFG EFG TOTAL NUMBER OF TRIPLETS FROM A GROUP OF SIZE 7 IS EQUAL TO 35 4. SUPER PALINDROMES The number 1001 is a super palindrome because both it and its square, 1002001, are palindromes (a number that is the same when read forward as backward). Write a program that will find all super palindromes between two numbers a and b. You may assume that a and b are between 1 and 32,000 Test your program with a,b = 100, 2000 and a,b=10000, 12345 Sample Run a,b = 100,2000 Super Palindromes between 100 and 2000 x x squared 101 10201 111 12321 121 14641 202 40804 212 44944 1001 1002001 1111 1234321 5. SAILORS AND A MONKEY Five sailors and a monkey are on an island. One evening the sailors round up all the coconuts on the island and put them in one large bin. They decide to wait until morning to divide up the coconuts, so they go to bed. During the night, the first sailor gets up, separates the coconuts into 5 equal piles with one left over, which he gives to the monkey. He decides to hide one of the piles for himself and he puts the remaining 4 piles back in the bin. He then returns to his hammock, content that at least he got his share. But he is not alone. During the course of the night, each sailor gets up and does exactly the same thing: gives one coconut to the monkey and takes 1/5th of the coconuts left for himself. In the morning the 5 sailors come together again and divide the remaining coconuts into 5 equal shares with one coconut left over for the monkey. What is the least number of coconuts that they could have begun with for all this to happen? Sample Run THE LEAST NUMBER OF COCONUTS THEY BEGAN WITH WAS ??? (The sum of the digits in the correct answer is 15.)
|