Programming Contest Tips

programming contest

Recently I participated in a few Programming Contests: Garmin Programming Competition 2014, ACM programming contest at my University and Google Code Jam 2014. I also remember my first contest in algorithms KPI-Open 2011, in Kiev, Ukraine. It was for teams up to 3 people. There was 16 problems to solve during 2 days. We solved one.

In some contests, there is no access to the Internet. It was the case during my first contest (KPI-Open 2011). We were able to use Java, C++ or Pascal. First problem we faced was: “HOW TO READ INPUT FROM CONSOLE IN JAVA?”. None of us remembered. Fortunately, we knew how to do it in C++. Thus we had to use C++ for the first day. We were more proficient in Java though and it slower our development. Before day two, we created check-sheet (we could bring as much printed papers as we wanted) with reading input in Java and some other tricks, which you usually google for. It allowed us to solve one problem. By solving problem I mean, to deliver solution, which pass tests in required amount of time. We solved 7-8 problems (or even more?) during those two days, but only 1 got accepted. It gave us 64 place (among 83 teams).

A few months after that, I participated in ACM programming contest at Kansas State University with one friend of mine. There was a progress: 1 problem solved in 5 hours (1 day). It is better that 1 problem in 2 days 🙂 Last year, I was 1-person team, and I got 3 problems solved (I was somewhere around 6-10 place). This year: I also solved 3 problems, but it gave me 3rd place.

Last year, I was also participating in Google Code Jam. In this contest you just need to deliver solution for given input. You download input file from website and you have some amount of time to upload solution (usually up to 10 minutes). Additionally, in most of problems there is small input set and large input set. The large set has more test cases and/or bigger numbers (e.g. int is not enough to solve it).

The most important thing during the Programming Contests is time. Time, in which you solve the problem.

My general tips (based on competitions I participated in) how to prepare for programming contests:

  • Make preparation before. Do not just walk-in (especially if it is your first contest). Check Programming Contest Year Plan – Yes a year Plan to be a better Programmer.
  • Take Introduction to Algorithms book to the contest.
  • Create (and print if no internet access is allowed) template for standard program. 90% of problems has N test cases. You need to parse it, compute solution and print. My approach is to read all input first and serialize it to e.g. Case class. Then I am looping through all cases and printing output. I prepared a template file, which allows me to save time during the contest.
  • Find out what languages/technologies are allowed during the contest and practice with it before the contest. Programming in Eclipse is different than programming in Visual Studio! Especially debugging.
  • Find out how you need to provide solution (send source code or just solution?) and how to read/write input/output.
  • If possible, find problems from previous editions of particular contest and practice by solving them.
  • Don’t be afraid to write bad code. You don’t need to comply with the best practices. It doesn’t matter, whether your code is not SOLID. Your code is not readable? Who cares? Don’t waste time for refactoring. If you really feel bad with the code your have written – refactor it after the contest. The only thing, which matters is, whether it solve the problem efficiently. Check solutions of the best competitors at Google Code Jam World Finals 2013. Can I write better code? Sure I can. But nobody cares, because they (not me) were the best in last year contest.

Solving algorithmic problems is only part of programmers’ skills toolset. If somebody is not good at it, it does not mean he is a bad programmer. He may be good at something else (e.g. programming embedded devices for aircrafts or designing the rocket system). However, it is good to practice problems solving and writing code. It is like daily workout. The programmer who wrote 1000 programs will be always better than one who wrote only 10. You will definitely become a better programmer with programming challenges.

My code for ACM contests and Google Code Jam is available on github:

Garmin Programming Competition 2014

Yesterday at my university, Garmin was hosting the Programming Competition.

Competition like that is a great opportunity to practice programming, algorithms and problem solving skills.

We could form teams of 1-2 students. My partner was Daniel Wang. We could use following languages: C++, C#, Java and Python. We chose Java. We were using Eclipse IDE and git to share the code.

Organizers prepared very real-life problems.

Competitions had two parts:

  1. Read and perform simple input conversion (1 hour).
  2. Reuse code from Program 1 and do more complicated operations with input (3 hours).

We solved part 1 without any problems. Part 2 required two programs: 2A and 2B. We solved both, but our programs didn’t pass all test cases. In 2A: 3/5 test cases passed, in 2B: 4/5. There were points for correct solution and bonus points (depended on the time when solution was submitted). Additionally, there was a timer showing how many bonus points we could earn sending solution now.

You can find problems description here. Our solutions are available on Bitbucket repository. Be aware that it is bad code, written under time pressure and never refactored. However, efficient enough to pass required time constraints. This is how you write code during programming contests 🙂

After competition we asked organizers about test input sets and they sent it to us.

This is the description of the bug we had and how we fix it (you can skip this part if you don’t want to read the description of problems):

The issue we had, was reading (shift mod 26) straight from the input file. Because e.g. shift = 45 should be effectively shift = 19 (45 mod 26). The program should stop when shift = 0. Then, when original shift was e.g. 52 we had stored shift=0 and we stopped (which was wrong). We thought that we should stop when the ‘effective shift’ is 0. Unfortunately, the test cases were stopping when the ‘original shift’ was 0. Fix was pretty easy (we just store two values: shift and shiftOrig for each cell). It would be very hard to fix this without test cases from organizers 😉 It was like in real-life: small detail caused significant error.

The challenge during programming competitions is that you cannot get all test cases. This time, there were 1 sample input per program. Which make sense, because otherwise everybody could just hardcode expected solution 🙂 What is worse, you cannot see the program output (in case of runtime error). Fortunately, guys form Garmin were nice and when we asked, they were showing us the output (on their machine). It helped us (a lot) in fixing the runtime errors (during the competition).

The next event I am looking forward is Google Code Jam. It starts in April 11, 2014 (Friday). Registration begins in March 11. I really encourage you to sign up. You can learn what various problems you can face and what you should consider during writing your programs. Additionally you can practice, apply your programming skills and compete with the best programmers in the World.

I am back!

Last two months were super busy for me. The end of semester (with compilers course‘s project), applying for a PhD studies, Christmas, New Year’s eve in Poland, and a job interview. I will tell you more about all of those things later in separated posts. Maybe not all, Christmas and New Year’s eve experience I will keep for myself 🙂

I am happy that all above is accomplished and I can get back to my routine (programming, blogging, reading books and learning new things).

It is worth to summarize the last year, which was quite successful:

  1. I started Master of Science in Computer Science program at the Kansas State University.
  2. I started this blog.
  3. I created twitter account and started using it.
  4. I co-organized dotNetConfPL (with Michal Franc and Pawel Sawicz).
  5. I almost maintained 4.0 GPA (I have 3.8 for now).
  6. I applied for Microsoft Student Partner position, but Microsoft rejected me.

The main goals for this year are:

  1. Graduate with Master of Science degree from Kansas State University.
  2. Start a new job.
  3. Run dotNetConfPL 2014.

I also would like to finally attend Dev Day conference in Kraków, but I am not sure if I will be in Poland on September 26.

During ‘the break’ I came up with a lot of ideas. I have 6 drafts for blog posts, 5 topics for a blog posts on the to do list and tons of ‘new, cool things’ to check out. When you get busy, because of School, work, personal issues etc. – don’t worry. Take a break, get all of more important things done and once you get back, you will be more happy and motivated than before.

don't just wish for a great 2014, make it so

The Story of dotNetConfPL

It is all about people and cooperation!

Long story short

April 25-26 – dotNetConf took place, online conference for .NET developers, organized by Scott Hanselman and Javier Lozano

April 27 – I text Pawel Sawicz, that we can organize something similar with Polish speakers and name it dotNetConfPL, he said: “it’s a good idea”. (motivation++)

April 28 – Pawel told me that Michal Franc is also interested and we created google doc to write down ideas and todos. (motivation++)

May 24 – We ask Scott Hanselman whether we can use dotNetConfPL as a name of the conference (because it’s very similar to name of his conference). He and Javier Lozano confirmed in the same day and wished us good luck. (motivation++)

June 6 – We sent e-mail to Maciej Aniserowicz, with a proposition to be a speaker at our conference.

June 7 – He responded: yes (we had first speaker!). (motivation++)

After that, we were inviting rest of speakers and most of them accepted our invitations. We really appreciate this, because they didn’t get any benefits from that.

July 14 – We announced dotNetConfPL on facebook and gain almost 50 registrations for the event within 1 hour! (motivation++)

The week of the conference

A few days before the conference we did initial testing with speakers. To check, whether their microphone, resolution, etc. is set properly. Sometimes we had issues with Google Hangouts. Solution for that was simply disconnect and create a new ‘hangout’. Our initial plan was to make only 1 hangout for entire conference, because each one has different link. We wanted to avoid forcing people to refresh the website or use of SignalR. However after that, we decided it will be better (safer and more flexible) to create separate ‘hangouts’ for each speaker and update link using SignalR.

Website for conference was created in ASP.NET MVC framework. The SignalR+CounchDB feature was implemented day before conference. After the conference I found interesting file in our solution:

dotnetconfpl - code

It is worth to mention that during the conference I was in Manhattan, KS, while Pawel and Michal were in Wroclaw, Poland. The image below, is my Command Center. ThinkPad X220 is connected with 2 monitors and through it I am connected to speakers. On MacBook I am connected via Skype with Michal and Pawel. On Surface I have live streaming (about 30 seconds delay) to be sure everything is working fine. The only issue I had, was not enough ears. I had only two: in one I was connected to the speaker, second – Michal and Pawel, and if I had third, I would be able to track the live streaming 🙂

dotNetConfPL - center


All sessions were in Polish. If you don’t speak Polish, you can mute the sound, play this in background and watch 🙂 You won’t get full experience, but still can get a lot from each session!

What is cool, all of them are for beginners and non-beginners in the same time. Which means, everybody will learn something from each session. Additionally: all of them are in HD (720p). Google enabled it by the end of August.

Maciej Aniserowicz: Unit testing in .NET

Maciej shows TDD live example. From nothing to well-tested communication with external API.

Filip Wojcieszyn: scriptcs – C# on diet

Filip shows how to use C# in Console and/or in SublimeText.

Jakub Gutkowski: JavaScript for C# developer

Jakub shows differences between C# and JavaScript, and language flavors every developer should be aware of, which may cause hard to track bugs.

Tomasz Janczuk: Node.js, Edge.js and Windows Azure

This session blew my mind (and not only mine). Edge.js allows you to mix Node.js, C#, F#, IronPython, PowerShell and T-SQL code in one file!

Maciej Grabek: Windows Phone 8 Tips & Tricks

Maciej shows set of useful(8) tricks for WP8 developers. From displaying helper-grid during development, to how to get more ratings for your app.


Everything went well. We didn’t have any problems with streaming (thanks Google Hangouts) and website (thanks Windows Azure and SignalR). I noticed that sometimes, on my Surface RT, IE11 wasn’t refreshing the link. But, come on…it’s IE, so we can ignore it 🙂

We had room on JabbR for discussion and ask questions to speakers. For a few minutes, even David Fowler (one of SignalR developers) visited it.

I am very glad that many people attended the conference. We had more than 600 registrations, almost 100 people in JabbR room and around 100-200 online viewers. But many people were watching the conference together, and in this case 1 online viewer = more that 1 physical viewers.

dotNetConfPL - atCompany
dotNetConfPL - pizza

Thank you very much for all speakers! You did a great job guys, all sessions are international level!
Thanks to Michal and Pawel for organizing this conference with me.
Thanks to Scott Hanselman and Javier Lozano for inspiration.
And…thank you very much for all of you who were watching the conference and spreading the news!

Short list of tools/technologies we were using for the conference:

  • Google Hangouts
  • SignalR
  • CouchDB
  • Windows Azure (to be able to scale the instance, depends on the number of users)
  • Google Docs (as a database for most important information)
  • Trello (for tasks management)
  • AppHarbor (as test server)

dotNetConfPL – online conference for .NET developers

Together with Michal Franc and Pawel Sawicz we are organizing online conference for .NET Developers: dotNetConfPL. It will take place on October 12 (3pm-10pm UTC+2), on the Internet! We have many great speakers and hot sessions.

Attendees will be able to ask questions through dotNetConfPL2013 room on JabbR.

Today, we have over 500 registered users! Additionally, during the conference we will give away 6 ReSharper licenses (thank you JetBrains).

Registration is not obligatory, but only registered users will have chance to win ReSharper licenses.

See you there!