Since people keep asking, the questionsPosted: July 13, 2007
These are the questions we handed out for the most recent I2CAP competition.
Note: These kids have had maybe 2-3 months practice by teachers who got a 3 day intensive training course. Just to put things in perspective. Points were also withheld for things like a lack of type checking. The winning teams all had running solutions for about 2-3 of the problems. One of them had solutions for all 4. They all had pretty much figured out the problems. The non-running solutions were due to tiny bugs and not flaws in logic. At the bottom end of the spectrum, some losing teams barely made it through one problem
As a new ruby programmer, your friend who has no ruby programming knowledge has approached you to help him with a program. This program should accept two values as input through the keyboard, and as output, produce the product of the two numbers (e.g. 6, 9 becomes 54 and 12,-20 becomes -240). The program should output an error message if a string or zero(0) is entered.
Program Name: Product
Input: 45, 10
Output: The product of the two numbers is 450
Write a ruby program that accepts integer X from the keyboard and use it to create an inverted triangle with X levels
Input: 5 Output:
In the early days of Roman numerals, the Romans didn’t bother with any of this new-fangled subtraction “IX”. It was straight addition, biggest to smallest, so 9 was written “VIIII”, and so on. Write a method that, when passed an integer between 1 and 5000 (or so), returns a string containing the proper old-school Roman numeral. In other words, old roman numeral 4 should return “IIII”. Make sure to test your method on a bunch of different numbers. Hint: Use the integer division and modulus methods. 15 Marks
For reference, these are the values of the letters used:
I=1 V=5 X=10 L=50
C=100 D=500 M=1000
Program Name: Roman_Numerals
integer : 75
Output: The roman numeral for 75 is LXXV
As a new ruby programmer, write a ruby program that uses loops to convert from Ghana cedis (GH¢) to cedis (¢) and vice versa. The program should print out a menu with the following options:
Ghana cedis (GH¢) to cedis (¢)
Cedis(¢) to Ghana cedis (GH¢)
Based on the option selected by the user, the program should accept a number from the user and perform the appropriate conversion.
Welcome to my Ghana cedis conversion program.
Select an option from the menu below.
Ghana Cedis to Cedis
Cedis to Ghana Cedis
Enter amount in Cedis: 200000
Amount in Ghana Cedis is : 2.00
Enter amount in Ghana Cedis: 450
Amount in Cedis is : 4500000