Since people keep asking, the questions

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

Question 1.

 

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.

5 marks

Program Name: Product

Example

Input: 45, 10

Output: The product of the two numbers is 450

Question 2

 

Write a ruby program that accepts integer X from the keyboard and use it to create an inverted triangle with X levels

 

Example:

 

Input: 5 Output:

*****

****

***

**

*

 

Question 3

 

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

 

Example 1

Program Name: Roman_Numerals

Example 1

Inputs:

integer : 75

Output: The roman numeral for 75 is LXXV

 

Question 4

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:

 

  1. Ghana cedis (GH¢) to cedis (¢)

  2. 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.

 

 

Example 1:

 

Menu:

Welcome to my Ghana cedis conversion program.

Select an option from the menu below.

 

  1. Ghana Cedis to Cedis

  2. Cedis to Ghana Cedis

 

Input:

Select: 2

Enter amount in Cedis: 200000

 

Output:

Amount in Ghana Cedis is : 2.00

 

 

 

Example 2:

 

Input:

Select: 1

Enter amount in Ghana Cedis: 450

 

Output:

Amount in Cedis is : 4500000

 

Advertisements

6 Comments on “Since people keep asking, the questions”

  1. Nice problems! Now the next questions: What were the usual/interesting/exceptional smart/just weird solutions? 🙂

  2. eyedol says:

    The questions aren’t bad.

  3. kwasi says:

    Joachim,
    The funniest group of them all attempted to solve a bunch of the problems not by figuring out the logic but by restricting the user to a small number of options which they then hard coded.

    e.g. for the triangle problem you could only select numbers between 0 and 7 and then they printed out the appropriate triangle for you.

    That one made me laugh for a while. It was just a weird kind of inventive

  4. good stuff, kwasi; please ignore my earlier comment on the other post to send questions. thx

    C&R,
    — eokyere

  5. Crystal says:

    Mm you are very interesting, I sat and read your old and new journal. I would be lying if I didn’t say you do not remind me of my boyfriend. He is from Accra, I found your journal very informative and will give me some new things to speak with him about. Thanks

  6. kwasi says:

    I’m glad you find it interesting Crystal


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s