Wednesday 31 July 2013

Configuring the TopCoder Arena for C# developers

If you read my previous post (Learning Algorithms with TopCoder - Getting Started Guide) you are probably motivated in solving TopCoder problems and putting yourself under test. You probably created an account and tried the arena and you quickly realized that the experience is not that great.

Why?

  • You have to read the text of the problem inside the arena
  • You have to manually create the class and copy the method signature
  • Testing the code with the examples is a manual process in the arena
  • Debugging against the examples force you to code all the examples manually
  • You have to copy the code from Visual Studio into the Coding Area

This is tremendously annoying!

Fortunately, there is a solution to these problems using some arena plugins. It is a little bit annoying to setup but once done your coding experience is vastly improved and you can finally focus on writing algorithms.

You can find some only-text documentation at the following link:
http://www.topcoder.com/contest/classes/ExampleBuilder/ExampleBuilder.html

First of all, download the TopCoder.zip file and extract it into C:\TopCoder

The folder contains an empty Visual Studio .NET 4.5 C# console application and a folder jars with the plugin code.



In this post, I want to explain step by step how to configure the TopCoder arena to be able to start solving SRM problems in TopCoder using C# and Visual Studio.

Launch the arena and open the Editor options.


Add a new editor with the following information:

  • Name: ExampleBuilder
  • EntryPoint: codeprocessor.EntryPoint
  • ClassPath: C:\TopCoder\jars\CodeProcessor.jar;C:\TopCoder\jars\FileEdit.jar; C:\TopCoder\jars\ExampleBuilder.jar


Select the new editor and click Configure.

Insert the entry point fileedit.EntryPoint and the processor class tc_plugin.ExampleBuilder

Then, click Verify.


Press OK and then Click Configure.

Specify the enter directory to C:\TopCoder, check "Write the problem description using HTML" and check "Write the Problem Description to separate file" with extension html.


Click the Code Template tab, select the C# language.

Copy the template code from here but feel free to customize it as you like.


Save everything.

Now you have everything set up and you are ready to code.

Open one of the past SRM: Practise Rooms > SRMs.


Select one of the problem.


The default editor will launch by default. Make sure that you select C# as your language.


Change your editor to ExampleBuilder.


This will trigger the creation of two files:

  • A C# source file with the problem and the tests
  • An html file with the description of the problem


You can open the html file and read the problem statement in your favourite browser (maybe in a separate screen if you have a multi-monitor setup).

At this point, you can open the TopCoder Visual Studio solution and include the file in the project.


You can see that all the examples has been automatically added as tests and the only thing that you need to do is to provide the implementation of the algorithm in the method.

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class BinaryCode 
{
    public string[] decode(string message) 
    {
        // IMPLEMENTATION GOES HERE  
        string[] res = new string[0];
        return res;
    }
    
    // BEGIN CUT HERE

    public static void Main(String[] args) 
    {
        try  
        {
            eq(0,(new BinaryCode()).decode("123210122"),new string[] { "011100011",  "NONE" });
            eq(1,(new BinaryCode()).decode("11"),new string[] { "01",  "10" });
            eq(2,(new BinaryCode()).decode("22111"),new string[] { "NONE",  "11001" });
            eq(3,(new BinaryCode()).decode("123210120"),new string[] { "NONE",  "NONE" });
            eq(4,(new BinaryCode()).decode("3"),new string[] { "NONE",  "NONE" });
            eq(5,(new BinaryCode()).decode("12221112222221112221111111112221111"),
                  new string[] { "01101001101101001101001001001101001",                  
                                 "10110010110110010110010010010110010" });

        } 
        catch(Exception exx)  
        {
            Console.WriteLine(exx);
            Console.WriteLine(exx.StackTrace);
        }
        Console.ReadKey();
    }
    ...

    // END CUT HERE
}

You can see the results of the tests simply running the project with F5.


How do you actually submit your code?

Click Compile and the source code will be automatically copied into the arena.

Finally click Submit.


To summarize, once you setup your development machine like I explained in this post you will be able to open any TopCoder problem, start coding your algorithm immediately and have a lot of fun. During a competition, this technique can also save you a lot of time and increase the chance of getting an higher score.

Enjoy coding!

Andrea


Saturday 27 July 2013

Learning Algorithms with TopCoder - Getting Started Guide

I have lots of friends who are passionate developers and every so often we discuss about
algorithms design and how important this is. The TopCoder platform offers a very good opportunity to put yourself under test, improve your skills and compete among other coders around the world. Everyone is pretty excited when I explain them about the platform and they seems willing to try it out but for some reasons this does not happen.

Let me be clear now.

Do you know what is the reason?

The answer is that...

They are frightened!

Saying that you don't have time is not an excuse because a competition is just 90 minutes long and everyone can give it a try. They are coders so why should they be scared of coding?

Why?

The reason is because they "don't feel ready to compete". They fell they need to do additional learning before actually competing otherwise they hurt their reputation and self-esteem. This is perfectly reasonable and I completely understand these feelings because this is how I constantly feel. TopCoder problems are usually very difficult and this fear of failing is completely blocking them.

So what?

What they don't consider is that TopCoder is not only a competing platform but also a learning platform. Once registered you have access to all the exercises from previous competitions with solutions completely explained, you can try them on your own without competing, you have access to lots of tutorials. There are tons of materials. You will be never ready so after trying few exercises I recommend to try a SRM (Single Round Match) competition. Competing really change the game and makes you more aware of your true skills. You are then able to identify areas of improvement, practise and then compete again. At the end of the day, you are always and constantly learning!

TopCoder is a learning platform!

Competitions can be seen as just a way of learning but you are not forced to compete.

However, if you are ambitious and you are truly committed to becoming a great coder, like I am sure you are, competing is the best way to put yourself under test and really find your potentials and limitations.

If you are scared you probably are not really serious of becoming a great coder.

It does not matter how strong you become compared to others. What matters is constantly learning and improving yourself.

This idea is also clearly expressed by the founder of TopCoder, Jack Hughes:

"TopCoder intends to help developers increase their skill level as well as increase their value to employers"

Then what?

If you read so far, it means that I convinced you to try TopCoder and in this post I would quickly introduce you to the platform.

First of all, you need to register.

Open the following website and click on Register Now in the top right cornerhttp://community.topcoder.com/tc

TopCoder allows you to learn and compete in many different areas. If you want to practise your algorithmic skills just select "I want to compete on TopCoder" and then follow the procedure where you will be asked to provide all your personal details.

Once registered, you can login into the website.

Expand the Competitions menu item and enter into the Algorithm category and then into the Single Round Matches section. It is probably a good idea to read the Overview page and then the Algorithm Competition Guide.

You can access to all the past problems clicking the Match Archive link under Statistics. In addition, you can also read the code submitted by all the people who participated to the competition. This is a lot of stuff!

There are also an interesting set of tutorials about algorithms that you can find in the Tutorials page.

However, there is nothing better than actually trying a problem yourself.

If you want an experience that is similar to a rate event, you can launch the Arena clicking the O(n) image in the top-left corner or the Launch Arena link.

The Arena is written in Java and you need to have it installed.

In the arena you enter a practice room and you can submit your code to a problem and get a score of how well you did it. The biggest value of the practise room for a learning point of view is the ability to run the system tests and discover bugs in your algorithm. You can also challenge the code written by other coders to find bugs in their implementations.

More information here: Practising in the TopCoder arena.

You can code using one of the following languages: C++, Java, C#, VB or Python.

The platform has been recently updated to the latest version of the languages.

If you decide to compete, you will get a score and you will be ranked against all the other top coders. You can find statistics about your performance clicking on your login name in the top-right corner.

For example, the followings are my current statistics. As you can see, I am still quite weak. 



I hope with this post that I have stimulated your curiosity.

Happy coding and see you in the arena!

See how to configure the TopCoder Arena for C# developers.

Andrea






Thursday 25 July 2013

DotNetToscana is Community of the Year 2013

I am pleased to announce that DotNetToscana has been awarded by Microsoft as Community of the Year 2013.

My sincere congratulations to all the members of the staff and all of our followers and supporters.

This is the picture taken during the Microsoft Community Lead Summit with Marco Minerva, our community lead, and Marco Dal Pino recently awarded as Nokia Developer Champion for Windows Phone.

Well done!






Sunday 7 July 2013

My TechEd 2013 in Slides

Microsoft TechEd Europe 2013 conference was held the last week of June in Madrid, Spain. As usual, Microsoft published online the entire content of the sessions. This is a lot of free materials!

Considering an average of 1.5 hours per session, it would require almost 4 working months to watch all of the sessions.

Even an avid learner like me, needs to give up on such idea. That's why I think that downloading all the sessions in advance is usually a crazy idea.

In the past, I watched only few sessions and I simply ignored all the others. The problem with that option is that you might easily miss some important news.

This year, I decided to follow a different approach. I decided to fully watch only the keynotes and to read the slides of all the other sessions. The goal is obviously to learn all the latest news from Microsoft without missing anything. Following this approach, allows me to identify topics I didn't consider and that might be of interest. In addition, nobody stops me to watch a particular session in full later if I need to understand more deeply a subject I am particular interested.

I spent almost 18 hours to do this and in this post I would like to summarize the conference showing the slides that I liked the most.

Statistics and Trends

This slide include really impressive information about the amount of data that is transferred on the Internet every minute. This is astonishing and it is growing incredibly fast.

The challenges faced today by the organisations are complex.




Cloud computing is the answer and hybrid cloud computing looks like the most favourite trend.



In addition, mobile malware is increasing in particular in the Android world. Security is surely a big and important topic.



Windows Server 2008 R2 is the most used Windows Server OS right now and there is still a significant portion of Windows Server 2003 deployments out there.



Windows XP is still incredibly popular and share a similar slice of the client OSs with Windows 7. Windows 8 instead is still quite irrelevant. Hopefully the future release Windows 8.1 will get more traction thanks to the reintroduction of the start button of the ability to further customize the desktop. As a consequence of this, there are still a lot of VB6 applications in production.



Microsoft Cloud Vision

Microsoft is clearly investing a lot in building a complete cloud infrastructure.












Microsoft and Citrix

Microsoft is the lead for desktops and Citrix is the lead of Desktop Virtualization. As a Citrix employee, I am quite interested in the relationship between these two companies, and in this edition of TechEd there were many sessions mentioning Citrix products.

First of all, it was quite interesting to read about the interconnected history of the two companies.

 




The following slides describes the power of combining XenApp and Configuration Manager 2012 and I am particularly proud to say that I personally worked in some part of these projects in Citrix in the last few years.




The Mobile SDK for Windows Apps allows to mobilize applications that are hosted on Citrix XenApp or XenDesktop and delivered to any mobile device with Citrix Receiver.



SQL Server 2014


Windows Server 2012 R2




I simply love the ability to create virtual networks. Thanks to the new Windows Azure Active Directory will be easier then ever to create a private virtual network that spans across Azure and the corporate network. This is a significant step forward for my point of view!



















Software Development

  


 






MSDN Benefits

The new MSDN benefits for Windows Azure are incredible. In particular, I like:
  • No charge for Stopped VMs
  • Pay by the Minute Billing
  • Heavily Discounted MSDN Dev/Test Rates
  • MSDN Monetary Credits