Wednesday, April 16, 2008

Funny coding test

Today I received an email from an Irish company (that probably found my CV somewhere in the outer space) with the following content:


Test #1 - "Roman numerals"

Implement a program which can take an integer and convert it into a Roman Numeral string.

1 = "I"
5 = "V"
19 = "XIX"
101 = "CI"

The function should be capable of converting every number between 1 and 3999.

A file is included for reference (roman.txt).

Test #2 - "Hangman"

Implement a version of the "Hangman" game. A word is given, and the user tries to guess the word before the little stick figure is fully drawn.


/ \


- You may use any of the following languages in implementing your solution: Java 1.5, C, C++ or C#
- Extra credit given for elegance and neatness in code, acceptance tests, etc.
- Comments are not necessary.
- Please provide instructions on how to run the code

That was pretty funny because it seemed like at least second part of the interview ;) and I haven't sent any email to this company before.
More so there was no "Hi", "Hello", "Regards", etc. - what a rudeness ;)

Anyway - I decided to solve the first task during my coffee break and here it is:

public static final int[] NUMBERS = new int[] { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 };
public static final String[] LETTERS = new String[] { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" };

public static String convert(int number) {
for (int i = 0; i < NUMBERS.length; i++) {
if (number >= NUMBERS[i]) {
return LETTERS[i] + convert(number - NUMBERS[i]);

return "";

Funny... :D


Pawel Niewiadomski said...
This comment has been removed by the author.
Pawel Niewiadomski said...


But, are you going to send them answers and see what happens next?

Przemysław Bielicki said...

I sent them my answers and told them I'm not interested in changing my job :)

Looking forward to their response...

Anonymous said...

they wanted to see

better luck next time :P

Przemysław Bielicki said...

no, they didn't - better luck next time in reading with comprehension :P

ps. google makes people's brain smaller - it's really interesting to try implementing some stuff by yourself - otherwise you will be just a google-generation moron

pps. what I see is that both implementations are pretty much the same -

Anonymous said...

It wasn't a company that sent you that. It was some kid in intro to computer programming at some community college. Pretty smart kid.

Przemysław Bielicki said...

What makes you think that? He wanted me to solve the problem for him?
Then, why he put address to this company in reply-to - wouldn't it be smarter to get the response somehow?

And BTW. - the solutuion already exist in the net - suffice to ask google. You just have to be as smart as a monkey ;)


Anonymous said...

I would sent them a reply saying that you don't do spec work.

Przemysław Bielicki said...

Just out of curiosity - what is a "spec work"?