Friday, February 11, 2011

5th SRM : SRM 497

One word. DISASTER.

Level 1 : Failed system test
Okay. In my defence, it was not the easiest problem. It wasn't rocket science either. Refreshingly, I did not panic today. Took my time to work out the filter logic. Just had to identify a single series of 'A's. I wasted some time trying to sort a vector and string with the former's elements as the key. Realised later that vector pair would have worked better. Or even my own sorting routine that sorted on the vector with the string as the satellite data. I failed to consider a case of 'AR' which was not in the example resulting in a single 'A' in the series. The golden rule of checking for boundary conditions did not seem important for Level 1 in Div 2. Stupid. To be fair to me, the example inputs usually covered all the boundary cases which never made me think about testing the code with cases beyond the examples.

Level 2 : Failed challenge
Same here. Passed all example inputs. But did not hold up to challenge. The logic seemed too simple to be true for a Level 2. Some sly problem-setter for today I realised later. The fact that I wasted a lot of time on Level 1 also made me rush through this to salvage some pride and rating. I am too simple-minded.

Level 3 : Did not submit.
I thought I had a real shot at this. It was a standard min-distance problem. Or at least that's how I saw it. I finished coding with about a minute to go. Used BFS as I was most comfortable with it even if I ran the risk of exceeding 2 sec time limit. Time ran out while I was testing. Wouldn't have mattered anyway. Did not pass system test in practice room later. 2 second time limit also would have screwed me.

Bottomline : Disaster-ville.
Lesson learnt : Correct late submission > Wrong quick submission.
Post-match rating : 949 (-179)
Match editorial : Later

Sunday, February 6, 2011

4th SRM : SRM 496 (Feb 1, 2011)

Still making up for the 2nd SRM. Easy set. Solved the Level 1 and Level 2 (for the first time), as did most of the others.

Level 1: Passed (~32 mins!)
What the hell was I thinking? Why does my mind go blank when the timer is ticking? This problem did not need more than 10 min (5 to think + 5 to code). It had something to do with anagram-free subsets. Basically, had to find no. of strings with unique signatures (example: signature of both abtgd and bgdat is abdgt ie characters of string in lexicographical order). Instead, I jumped up and started coding some complex hashing method where each string will be hashed to a value based on its characters enabling quick comparison of equal strings. Thinking for a minute would have made me realise that this a Div 2 Level 1 which cannot be this complex. Thankfully, I ran into some problem with my logic. So, I had to step back and look at the problem again. Realised there was a simpler alternative that if I just sorted each string (to reduce them to signatures) and then removed the duplicates from the collection of strings, I would get the solution. Less than 10 lines of code. Done. Felt stupid.

Level 2: Passed (~14 mins)
Wasting time is one thing. Realising it later only makes it worse. Having messed up Level 1, anything other than an easy problem would have been hard to concentrate on. Thankfully, it was a very similar in approach to the Level 2 problem that I messed up in SRM 494. I knew the pitfalls (like messing up row and column indices while modifying row-wise code to work for column-wise) and avoided most of them. Expectedly, I was done in pretty good time. This problem is proof enough that 'practice makes perfect'. The sense of comfort with a known problem and the corresponding coding time have to be seen to be believed.

Level 3 : Clueless
Having solved the first two for the first time and 20+ mins to go, had no choice but to look at this problem. What if I lucked out with some easily identifiable straightforward Dijkstra or BFS? Not to be.

Challenges : None.

Bottomline : Good (Averaging poor Level 1 and great Level 2). Could have been great. Division 1 was within grasp. Rating graph is still moving up.

Lessons learnt :

1.Think and plan before coding.
2.Learn to use predefined functions properly. Avoid wasting time by looking up correct usage.

Post-match rating :
1112 (+49)
Match Editorial : http://www.topcoder.com/wiki/display/tc/SRM+496

3rd SRM : SRM 495 (Jan 27, 2011)

2nd SRM : SRM 494 (Jan 22, 2011)

1st SRM : SRM 493 (Jan 12, 2011)

It might be shocking to know that I joined TopCoder in 2006 but did not care to open the arena until 2011! Anyway, I registered for the first SRM of the year and was keen to do well. I had to compete in Division 2 as I was unrated. (Rating 1200 and above in Division 1) Before the SRM, I practised a bit in the practice rooms where I could solve the Level 1 problems quite easily and the Level 2 ones took a lot of time and effort. My goal for this SRM was to solve the Level 1 and anything more would be a bonus.

The entire problem set was difficult according to the match editorial.

Level 1 : Passed (~26 mins)
It was of a moderate level (by my standards). Row-wise and Column-wise computation of nested loops was all that was required. I made the mistake of counting the single-element case twice since it appears in both row-wise and column-wise computation. Had to handle it as a special case and I was done.

Level 2: Clueless
It was a 2-person game where one had to predict the outcome. I had no clue. After the match when I read the tutorial on "Algorithm Games" , it didn't seem that hard. I am sure I will face such problems in the future. Now, I know what to do (I think).

Level 3: Clueless

Challenges : None. I am not very good at understanding others' code. (Is it just me?)

Bottomline : Overall satisfactory. Good start to journey. Rating 1128. Almost made it to Division 1.

Lessons learnt :
1. Read all TopCoder tutorials. Nothing like it. Can't touch Level 3 problems without mastering tutorials.
2. Don't rush to code. T(Plan + Code) < T(Code + Debug^n)
3. Use macros. Can avoid syntax errors. High-rated coders use them.


Post-match rating
: 1128 (+1128)
Match Editorial : http://www.topcoder.com/wiki/display/tc/SRM+493

Welcome!

Hi !

This blog is an account of my coding journey through TopCoder. My topcoder handle is johnywalker420 . Feel free to leave your comments.

This is how it all started....