C# – Mutiverse Communication – problem from IT competition/exam

On the 14th September 2013 I was participating in a C# competition for advanced by Telerik Academy. After spending 5 hours, trying to solve 5 quite tough C# problems, I have obtained 140 points. With this result I was ranked in 140 position. Being in top 140 is probably not something man should be very proud of, but considering the fact that it was enough to continue I was quite satisfied. Furthermore, 6 months ago 600 people were accepted in the courses and other 200 were participating from previous years.

So, the first problem was really easy and I needed only about 30 minutes to obtain the maximum of 100 points. I was a little mad on me later, when I have obtained only 40 points more for about 4:30 hours, but the problems were really tough and I have not studied enough for the competititon.

Anyway, if you are interested in the task, I was able to resolve in 30 minutes, you may find the complete description of the problem here.

With simple words, what is required is to write a C# console application, which recognizes thirteen different 3 CHAR numbers and converts them to standard 10 digit numbers. For example, if you enter in the console “CHU” it will return “0” and if you enter “TELOFT” it will return 15. Pretty much it is like the known conversion of 16 digit system to 10 digit system, but in this case we have 13 digit system and each digits consist of three chars.

This is the code, which was provided by Telerik, as a sample of good solution to the problem:

I have not saved my code, but it was something similar as far as it has passed all the tests.

What is interesting in this code:

1. We use 3 additional methods to resolve the problem – Power of Thirteen, ConvertDigitFromMultiverse and ConvertMultiverseNumber.

2. The main method consists of only one line – writeline with a method inside. Really beautiful 🙂

3. The problem that the digits from which we should convert are actually three symbols, is beautifully resolved with just 3 lines of code:

Pretty much that was it. It may seem a standard C# problem, but for me it was something to be proud of 🙂

Here is the *.exe file, which does the conversion. So, if you ever have to transfer from any kind of digit system to the standard 10 digit system, with a little amendment in this file, you may do it.