Monthly Archives: January 2014

TCO 13: Marathon Finals, part 3

Part 1 Part 2 Part 3 Part 4

Current Status

While I was doing all of the tweaking, the situation that arose on our leaderboard was quite interesting. ACRush was steadily climbing up through the ranks and at 16:45 he made a submission which suddenly puts him right behind me – my lead shrinks from 10%+ to something between 2% and 5%. On the other hand no one else seems to be doing better. The strangest part is that wleite hasn’t submitted anything since 14:40 – I have no idea what could be the reason, especially since he’s not the person to hide his best submission till the last seconds. And he was still in 3rd place. Everyone else had low score, and all of the them rarely submitted anything, so I assumed that they just took an approach where they are implementing something complex right from the start (which is completely opposite of what I was doing). To sum things up – I couldn’t feel any less confident about my temporary first place than I did.

Between one batch of local tests and another, I tried to come up with some more advanced strategies, than the silly one that I was currently using. One thing that had me worried, was that it’s quite probable that I’ll run out of all the small things I can do to improve my score, before the contest finishes. In other words, I thought the potential of my solution (simulating a lot of different greedy strategies, without using any partial results) was pretty low and it’s quite probable that I’m going to hit the dead end 1-2 hours before the end of the contest. I’ll be too tired to rewrite half of my code and I won’t have enough time to properly test it, which should be my top priority considering that I’m making a ton of bugs throughout this contest.

Continue reading

TCO 13: Marathon Finals, part 2

Part 1 Part 2 Part 3 Part 4

Multibase Solution

It’s 11:30, we’re 2,5h into the competition and I’m now absolutely forced to do the multibase strategy. No more running away. And I still have absolutely no clue how to do it. If something looks way too complex, it’s a good idea to try and split it into smaller parts. In this exact situation, I came up with the following subproblems:

  1. Which worker should build the base
  2. Where it should be placed
  3. When it should be placed
  4. When I have more than 1 base, how should I manage the workers
  5. How many bases I should build

Now I’m looking for the simplest way to accomplish each of those subproblems. First of all, let’s assume I’m trying to build at most 1 base at a time. (1) is pretty trivial. Let’s build it with any worker that can do it. Since there’s a constraint that only worker that doesn’t carry any resources can build the bases, let’s use only those. And if all of them are busy with carrying resources, just wait for one of them to be free. (2) is the scary part, so I just imagine that it isn’t here and I’m moving on with my list. The simplest solution to (3) is to build it as soon as we can (we have resources) and build the bases only after I have build all of my workers. Remember that in each simulation I know how many workers I’m going to get. For (4) I can just move each of my workers to the closest base. My intuition is that the workers will “manage themselves” after some time. It’s definitely far from perfect, but on the up side, I already have that implemented, so this is an ideal solution. (5) is even more trivial, because I use the number of bases as an input to my simulate() function and I’m assuming that I’ll just iterate over all possible combinations of workers and bases.

Continue reading

TCO 13: Marathon Finals, part 1

Part 1 Part 2 Part 3 Part 4


Small warning first. This turned out to be a very long post. Mostly because, I tried to put here all of the important information, so that you can have a full picture of how does it feel to compete at the finals and at the same time have a peek at my thought process during those very long twelve hours. And for people who had never heard of TopCoder’s Marathons before – this is an algorithmic contest where your task is to solve one very hard problem for which there’s no polynomial-time optimal solution. We don’t have to use any APIs, we’re only submitting the code that is remotely executed. And the data (tests) that are used to test our solutions are almost always artificially generated and we’re provided with the generator itself – we just don’t know exact tests that are going to be used. And that is all you really need to know.

The origins for this post are pretty simple. I always thought that those regular “Post your approach” threads were telling only half of the story. The other half is obviously how people are coming up with those mentioned approaches. And since for me, the road itself is far more important than the goal, I wanted to shed some light on that process. My goal here is provide you with a very comprehensive portrayal of what’s going through my mind during the competition. And finally, going with the problem from the finals has many advantages – the contest duration is much shorter, so I can provide more details and the time management is significantly simplified since there are no real-life distractions.

Continue reading