Facebook Hacker Cup

Back to General discussions forum

smwentum     2015-01-09 16:15:02

Hi all,

Not to take away from this site, but Facebook is having a programming competition for the next two days check it out.

https://www.facebook.com/hackercup

Rodion (admin)     2015-01-09 17:17:37
User avatar

Yes, thanks for sharing!

I recommend everyone who have a couple hours of free time this weekend at least try to participate in this qualification round!

Rodion (admin)     2015-01-12 03:06:25
User avatar

It's over now! Who have participated?

I've spent about hour with a half to solve first and second problems. I discussed solutions shortly in my blog.

Then I thought I can make replicas of these problems for those who did not participate, so there they are #191 and #192.

Have anyone tried / solved the third problem?

Matthew Cole     2015-01-12 04:11:09

I answered both the first and second problems.

I need to tweak my solution for the first problem so that it'll accept hexadecimal input. That was a nice twist in the problem.

I'll also need to improve my solution for the second problem as it's a brute force solution. My current solution took 5:20 to calculate, barely within time limits. Effectively, for M cases, with N yes/no decisions, I have to check M x (2^N - 1) possibilities. For the contest data set, that was 2,097,152 possibilites in under six minutes. I recognize that broadly the problem is a variation of the knapsack problem. I haven't quite figured out how to get the classical algorithm to get what I'm looking for yet.

The last problem, I had an idea, but not enough time to implement. The way I see it, you must recognize that the game board (lasers, walls and open space) exists in four states: turn 0, turn 1, turn 2, turn 3 because the group of lasers each have four and only four configurations. Each space in the 4 MxN matrices represents safe spaces on each turn that do not collide with a wall or a laser beam. Next, you build a tree data structure with the position-state at each turn being a node, the children being the position-state in next turn, and the turn for calculating the lasers' aim equal to mod(tree level, 4).

You return an answer by looking at the minimum depth in the tree that has a position equal to the finish position. You return 'impossible' if the tree reaches a height of 100 and you haven't found a solution, or if all remaining leaves have no children.

Rodion (admin)     2015-01-12 06:28:26
User avatar

> I need to tweak my solution for the first problem so that it'll accept hexadecimal input

My main idea was to prevent solutions working on integers instead of strings... While for original problem this was ok... I did not want to plainly borrow their statement.

> For the contest data set, that was 2,097,152 possibilites in under six minutes.

Hm... That is exactly why I thought that brute-force is the supposed way to do this. I usually assess that modern computers (even my old netbook) perform about 10^6 or more iterations of some simple loop per second.

So my code (in Java) worked for about 5 seconds overall... If you used Python I think it could be 3-5 times slower, but not too long also...

I mean if they wanted users to invent some whimsical solution (I know not any) they will make K=50 or more, so that brute-force was out of question... In such challenges limits are often a hints...

I hope to take a look into the third problem, but I doubt my skills would be relevant to it :)

Moff     2015-01-12 07:47:58
User avatar

I've missed this competition.

But during last 2 weeks I has a rest from work and I've used this time for playing with kids, skiing, hoсkey and simple forest walking outside the city.

Rodion (admin)     2015-01-12 08:14:29
User avatar

This sounds as you were quite lucky - here pleasant weather with enough snow for outdoors activities came only a couple days ago... So we were mostly spending time at homes or with relatives, occasionally visiting some concertoes and exhibitions... Glad to return to work again, ha-ha! :)

P.S. I think there will be more similar competitions. E.g. Google Code Jam is scheduled at beginning of March. I hope I will not forget to announce it in time.

smwentum     2015-01-12 13:59:50

I got the first two, but for the second one it wouldn't let me do the millionish loops, so i just did somethign dumb and threw out any of the foods where any of the values were greater than the total. That luckly worked, see you all in round one.

Ashish Padalkar     2015-01-12 14:37:30
User avatar

I solved all the first two , i have two ticks so hopefully both of them are correct.

Did anyone of you have participated in the last year's competition. Does the level increases a lot ?

Thanks Matthew Cole , I will try to solve it your way and see if i succeed.

Rodion (admin)     2015-01-12 15:30:03
User avatar

> i have two ticks so hopefully both of them are correct.

If they turned to green in the score board today (after end of the round) - they are correct. :)

> Did anyone of you have participated in the last year's competition. Does the level increases a lot ?

I did. I'd say the level remains pretty the same. If I'm not mistaken you can find old problems here and for Round 1 here.

Moriarty     2015-01-15 01:05:20
User avatar

Congrats Rodion. It seems we solved the same problems. My solution to Cooking the Books was alarmingly similar to yours. :)

I managed to solve 3rd but ran into some trouble during submission. :S

See you next round.

Rodion (admin)     2015-01-16 15:16:17
User avatar

Thanks - though I do not think I will be able to achieve much more in this contest... :)

Reminder Round 1 will took place this weekend: see time and date for your zone

Contest will long for 24 hours.

Ashish Padalkar     2015-01-21 01:27:01
User avatar

Did anyone from here clear the round 1 ??

Rodion (admin)     2015-01-21 04:50:58
User avatar

I do not think so :)

I myself had no idea how to save the 4-th problem. So even if I coded remaining three without mistakes I could not advance (you see, people from first 500 positions have all problems solved). Even more so since I made shameful mistake in the 2-nd problem (it worked for all cases except ones with X-0, so silly).

(FB shows me that Moriarty and Eugene Lim also did not try the 4-th - perhaps it required the knowledge of some more special algorithm - I hope to study it later)

One need to build skills in Competitive Programming methodically and strategically to advance high in such contests :)

I.e. being "orange" or "red" at dedicated sites like CodeForces is roughly the measure of required skills. I've never managed to get higher than "violet". But if you are curious, I dare to recommend to try - it is at least funny... :)

P.S. I know at least several masters of competitive programming registered at CodeAbbey, but usually for them our problems are bit too easy and somewhat boring - that is what I meant by "I do not think so".

smwentum     2015-01-21 18:37:17

I didn't get through the first round either. I got the first one, I kept trying the second one but I was missing something about the second problem, at that point i knew i wasn't going to advance, so i just gave up. I still had fun and this was the furthest I have gotten in the cup so I guess I can't complain.

Ashish Padalkar     2015-01-22 12:29:17
User avatar

Same here , It was also my first online programming contest :)

Rodion (admin)     2015-01-22 15:51:23
User avatar

I'd say you both are pretty cool. My first (and second, and third...) contest were mainly a total failure.

By the way do you know Zuckerberg himself was not very strong in online competitions (though it was many years ago)? Look at his TopCoder profile for curiosity :)

Ashish Padalkar     2015-01-24 13:50:19
User avatar

Thank you Sir .

Its pretty interesting to know cause he was shown as a genius programmer in the movie :P

Rodion (admin)     2015-01-24 14:37:23
User avatar

You see, Sir, it is hard to tell what makes "genius" programmer :)

Problem solving is useful, but to build social network, to manage, develop and promote it carefully it, probably, is not the most important :D

Otherwise guys like Petr Mitrichev and Gennadiy Korotkevich would build some famous projects and not Zuckerberg...

Please login and solve 5 problems to be able to post at forum