Dominion Strategy Forum

Please login or register.

Login with username, password and session length
Pages: [1]

Author Topic: Google Code Jam  (Read 6047 times)

0 Members and 1 Guest are viewing this topic.

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Google Code Jam
« on: April 12, 2013, 08:10:09 pm »
+1

Just started today. Anybody here registered for it?
Logged
I have a blog! It's called Sorta Insightful. Check it out?

dnkywin

  • Scout
  • ****
  • Offline Offline
  • Posts: 43
  • Respect: +57
    • View Profile
Re: Google Code Jam
« Reply #1 on: April 13, 2013, 08:20:35 am »
0

Me! I'm dnkywin on the code jam as well.
Logged

rrenaud

  • Administrator
  • *****
  • Offline Offline
  • Posts: 991
  • Uncivilized Barbarian of Statistics
  • Respect: +1197
    • View Profile
    • CouncilRoom
Re: Google Code Jam
« Reply #2 on: April 13, 2013, 01:05:38 pm »
+1

Logged

theory

  • Administrator
  • *****
  • Offline Offline
  • Posts: 3603
  • Respect: +6125
    • View Profile
    • Dominion Strategy
Re: Google Code Jam
« Reply #3 on: April 13, 2013, 03:16:12 pm »
0

I wrote this problem for Code Jam 2008.

https://code.google.com/codejam/contest/32008/dashboard#s=p2&a=2

That looks way scarier than even the TopCoder Level Threes.  Care to walk us through how to solve it?
Logged

rrenaud

  • Administrator
  • *****
  • Offline Offline
  • Posts: 991
  • Uncivilized Barbarian of Statistics
  • Respect: +1197
    • View Profile
    • CouncilRoom
Re: Google Code Jam
« Reply #4 on: April 13, 2013, 03:36:45 pm »
+1

It's not really scary at all.

I thought it was cool because so many programming contest problems are dynamic programming problems, and my intended solution isn't really DP.  But alas, there is a simple DP solution ;(.

There are plenty of solutions online.  This one is simple/good.

http://chrk.atwebpages.com/index.php?title=Test_Passing_Probability

My intended solution is basically finding the top M shortest paths in a very structured/restricted graph induced by the test questions.  Anytime you pick a particular response for a question, you pay a cost that is proportional to the log of the probability of it being right.  And then the cost of a set of responses(=path) is the sum of the individual costs.  The independence assumptions means that all the good response sets are very related so you can explore only the best ones without suffering from the exponential explosion of brute force.
Logged

soulnet

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2142
  • Respect: +1751
    • View Profile
Re: Google Code Jam
« Reply #5 on: April 13, 2013, 06:56:03 pm »
0

I wrote several problems for Google Code Jam and the Europe-only version back when it was managed by TopCoder and I was actively writing for them. I also participated in the first couple of versions, currently "retired" from competing and just writing and managing ICPC regionally.
Logged

blueblimp

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2849
  • Respect: +1559
    • View Profile
Re: Google Code Jam
« Reply #6 on: April 13, 2013, 07:30:10 pm »
0

Thanks for pointing out the start of the contest. When I was still in university, I did a lot of contests, but lately I haven't done many and keep missing the starts of the good ones since I'm not following the scene anymore.
Logged

werothegreat

  • Adventurer
  • ******
  • Offline Offline
  • Posts: 8172
  • Shuffle iT Username: werothegreat
  • Let me tell you a secret...
  • Respect: +9630
    • View Profile
Re: Google Code Jam
« Reply #7 on: April 14, 2013, 12:05:06 am »
0

It doesn't say - which language are you supposed to code in?
Logged
Contrary to popular belief, I do not run the wiki all on my own.  There are plenty of other people who are actively editing.  Go bother them!

Check out this fantasy epic adventure novel I wrote, the Broken Globe!  http://www.amazon.com/Broken-Globe-Tyr-Chronicles-Book-ebook/dp/B00LR1SZAS/

soulnet

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2142
  • Respect: +1751
    • View Profile
Re: Google Code Jam
« Reply #8 on: April 14, 2013, 12:41:21 am »
0

It doesn't say - which language are you supposed to code in?

Whichever you want. You can download the test inputs and need to upload the output, they may be generated with any means you want as long as the programs used (compiler, interpreter), if any, are freely available. You can solve them by hand, although usually it is not possible. There should be a FAQ somewhere.
Logged

Davio

  • 2012 Dutch Champion
  • *
  • Offline Offline
  • Posts: 4787
  • Respect: +3412
    • View Profile
Re: Google Code Jam
« Reply #9 on: April 14, 2013, 07:04:34 am »
0

Is it similar to project Euler? I dabbled in that one, about 50 problems solved.
I always used imperative languages like Java and C# while mathy problems may be easier with functional languages like Haskell...
Logged

BSG: Cagprezimal Adama
Mage Knight: Arythea

DStu

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2627
  • Respect: +1490
    • View Profile
Re: Google Code Jam
« Reply #10 on: April 14, 2013, 07:07:30 am »
0

Is it similar to project Euler? I dabbled in that one, about 50 problems solved.
I always used imperative languages like Java and C# while mathy problems may be easier with functional languages like Haskell...
I haven't see much numerics be done in Haskell, so I doubt this...
Logged

Avin

  • Spy
  • ****
  • Offline Offline
  • Posts: 86
  • Respect: +99
    • View Profile
Re: Google Code Jam
« Reply #11 on: April 14, 2013, 08:53:14 am »
0

Thanks for mentioning this here! I participated back in 2004 but completely missed the signups and start for it ever since then. The format has gotten a lot better now that they are doing it independently from TopCoder. I was able to see this thread with about two hours to spare from the end of the qualification round, and it took me that long to try a practice problem, then do the first two qualification round problems (although had I seen the third I probably could have done that very quickly, I just didn't even read it).

Are the points cumulative? In other words am I starting with a disadvantage due to only attempting two of the problems in the qualification round?
Logged

Davio

  • 2012 Dutch Champion
  • *
  • Offline Offline
  • Posts: 4787
  • Respect: +3412
    • View Profile
Re: Google Code Jam
« Reply #12 on: April 14, 2013, 02:07:21 pm »
0

So I am too late or can I still participate starting Round 1?
Logged

BSG: Cagprezimal Adama
Mage Knight: Arythea

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Re: Google Code Jam
« Reply #13 on: April 14, 2013, 03:13:55 pm »
0

So I am too late or can I still participate starting Round 1?

If you didn't do the Qualifying round, then you can't participate. However, you can look at the problems.

Thanks for mentioning this here! I participated back in 2004 but completely missed the signups and start for it ever since then. The format has gotten a lot better now that they are doing it independently from TopCoder. I was able to see this thread with about two hours to spare from the end of the qualification round, and it took me that long to try a practice problem, then do the first two qualification round problems (although had I seen the third I probably could have done that very quickly, I just didn't even read it).

Are the points cumulative? In other words am I starting with a disadvantage due to only attempting two of the problems in the qualification round?

Points aren't cumulative. Only your current round score matters.
Logged
I have a blog! It's called Sorta Insightful. Check it out?

dnkywin

  • Scout
  • ****
  • Offline Offline
  • Posts: 43
  • Respect: +57
    • View Profile
Re: Google Code Jam
« Reply #14 on: April 14, 2013, 05:12:15 pm »
0

Hooray I qualified.

My program for C-large-2 failed because I didn't include square palindromes of the form Xrev(X)^2 where X is 25 digits long (for example, 1010000000000000001000000001000000000000000101^2) because my loop stopped at len<25. Once I changed the <25 to a <26 my program passed the second large case  >:(
Logged

theory

  • Administrator
  • *****
  • Offline Offline
  • Posts: 3603
  • Respect: +6125
    • View Profile
    • Dominion Strategy
Re: Google Code Jam
« Reply #15 on: April 15, 2013, 06:04:19 pm »
0

It's not really scary at all.

I thought it was cool because so many programming contest problems are dynamic programming problems, and my intended solution isn't really DP.  But alas, there is a simple DP solution ;(.

There are plenty of solutions online.  This one is simple/good.

http://chrk.atwebpages.com/index.php?title=Test_Passing_Probability

My intended solution is basically finding the top M shortest paths in a very structured/restricted graph induced by the test questions.  Anytime you pick a particular response for a question, you pay a cost that is proportional to the log of the probability of it being right.  And then the cost of a set of responses(=path) is the sum of the individual costs.  The independence assumptions means that all the good response sets are very related so you can explore only the best ones without suffering from the exponential explosion of brute force.

I think the key in there was realizing that you didn't actually have to find the optimal strategy yourself in order to solve the problem.
Logged

rrenaud

  • Administrator
  • *****
  • Offline Offline
  • Posts: 991
  • Uncivilized Barbarian of Statistics
  • Respect: +1197
    • View Profile
    • CouncilRoom
Re: Google Code Jam
« Reply #16 on: April 15, 2013, 08:44:38 pm »
0

You can modify that solution so that it can return the kth best strategy in O(Q) time (==length to print it out) by keeping around some back pointers without an asymptotic slow down in time usage, as long as k < M.  The memory usage would increase to O(M*Q) instead of O(M).

The key insight to solve it used by that answer is that a top M solution after k steps contained a top M solution after k-1 steps.  So you never need to keep around that many partial answers to get a great final answer.
Logged

Avin

  • Spy
  • ****
  • Offline Offline
  • Posts: 86
  • Respect: +99
    • View Profile
Re: Google Code Jam
« Reply #17 on: April 20, 2013, 11:08:05 am »
0

Hooray I qualified.

My program for C-large-2 failed because I didn't include square palindromes of the form Xrev(X)^2 where X is 25 digits long (for example, 1010000000000000001000000001000000000000000101^2) because my loop stopped at len<25. Once I changed the <25 to a <26 my program passed the second large case  >:(

I'm curious the execution time of your program and for anyone else who solved the large-2 input.

Without precalculating the fair and square numbers my program runs in 18.657 seconds, and I'm using C#.

Unfortunately I didn't actually attempt this problem during the preliminary round since as I mentioned above I didn't start it until late. I took a few hours getting it down to this running time too but I thought it would be an interesting challenge to see how fast I could get it even after I had it fast enough to solve the problem at all.
Logged

dnkywin

  • Scout
  • ****
  • Offline Offline
  • Posts: 43
  • Respect: +57
    • View Profile
Re: Google Code Jam
« Reply #18 on: April 21, 2013, 01:43:17 pm »
0

Hooray I qualified.

My program for C-large-2 failed because I didn't include square palindromes of the form Xrev(X)^2 where X is 25 digits long (for example, 1010000000000000001000000001000000000000000101^2) because my loop stopped at len<25. Once I changed the <25 to a <26 my program passed the second large case  >:(

I'm curious the execution time of your program and for anyone else who solved the large-2 input.

Without precalculating the fair and square numbers my program runs in 18.657 seconds, and I'm using C#.

Unfortunately I didn't actually attempt this problem during the preliminary round since as I mentioned above I didn't start it until late. I took a few hours getting it down to this running time too but I thought it would be an interesting challenge to see how fast I could get it even after I had it fast enough to solve the problem at all.

My program ran in 1.013 seconds on a 2.60GHz machine (used C++, with precalculation).

Who's doing Round 1A this Saturday?
Logged

qmech

  • Torturer
  • *****
  • Offline Offline
  • Posts: 1918
  • Shuffle iT Username: qmech
  • What year is it?
  • Respect: +2320
    • View Profile
Re: Google Code Jam
« Reply #19 on: April 21, 2013, 07:25:32 pm »
0

It's not really scary at all.

I thought it was cool because so many programming contest problems are dynamic programming problems, and my intended solution isn't really DP.  But alas, there is a simple DP solution ;(.

There are plenty of solutions online.  This one is simple/good.

http://chrk.atwebpages.com/index.php?title=Test_Passing_Probability

My intended solution is basically finding the top M shortest paths in a very structured/restricted graph induced by the test questions.  Anytime you pick a particular response for a question, you pay a cost that is proportional to the log of the probability of it being right.  And then the cost of a set of responses(=path) is the sum of the individual costs.  The independence assumptions means that all the good response sets are very related so you can explore only the best ones without suffering from the exponential explosion of brute force.

This problem is a nice example of where laziness can be useful.  In Haskell you can use the same logic as the DP solution to construct the full list of strategies ordered by effectiveness.  Taking the the top 40 elements of that list will result in the program doing pretty much exactly the same work as the DP solution, but you've separated the concerns of comparing the strategies and computing no more than you have to.
Logged

Avin

  • Spy
  • ****
  • Offline Offline
  • Posts: 86
  • Respect: +99
    • View Profile
Re: Google Code Jam
« Reply #20 on: April 22, 2013, 09:34:05 am »
0

My program ran in 1.013 seconds on a 2.60GHz machine (used C++, with precalculation).

Okay but how long was the precalculation? The algorithm to generate the numbers is what I'm interested in.
Logged

Drab Emordnilap

  • Torturer
  • *****
  • Offline Offline
  • Posts: 1832
  • Shuffle iT Username: Drab Emordnilap
  • Luther Bell Hendricks V
  • Respect: +1887
    • View Profile
Re: Google Code Jam
« Reply #21 on: April 22, 2013, 04:45:22 pm »
+1

My program for C-large-2 failed because I didn't include square palindromes

 >:(
Logged

blueblimp

  • Margrave
  • *****
  • Offline Offline
  • Posts: 2849
  • Respect: +1559
    • View Profile
Re: Google Code Jam
« Reply #22 on: April 23, 2013, 01:23:26 am »
0

Hooray I qualified.

My program for C-large-2 failed because I didn't include square palindromes of the form Xrev(X)^2 where X is 25 digits long (for example, 1010000000000000001000000001000000000000000101^2) because my loop stopped at len<25. Once I changed the <25 to a <26 my program passed the second large case  >:(

I'm curious the execution time of your program and for anyone else who solved the large-2 input.

Without precalculating the fair and square numbers my program runs in 18.657 seconds, and I'm using C#.

Unfortunately I didn't actually attempt this problem during the preliminary round since as I mentioned above I didn't start it until late. I took a few hours getting it down to this running time too but I thought it would be an interesting challenge to see how fast I could get it even after I had it fast enough to solve the problem at all.

My program ran in 1.013 seconds on a 2.60GHz machine (used C++, with precalculation).

Who's doing Round 1A this Saturday?
I'll be doing Round 1A, but in my time zone, it's Friday.

Online round 3 looks like the real killer in this format. 500 people whittled down to 25. When I was doing competitions regularly, getting top 500 would be easy, but I was never good enough to get top 25 reliably. Too bad the algorithm competition boom has mellowed a bit--used to be the on-site numbers were bigger, like 100 (Google Code Jam 2008) and 72 (TopCoder Open 2008). Still fun to participate online, but far more difficult to get a free trip.
Logged

dnkywin

  • Scout
  • ****
  • Offline Offline
  • Posts: 43
  • Respect: +57
    • View Profile
Re: Google Code Jam
« Reply #23 on: April 23, 2013, 11:31:18 am »
0

My program ran in 1.013 seconds on a 2.60GHz machine (used C++, with precalculation).

Okay but how long was the precalculation? The algorithm to generate the numbers is what I'm interested in.

The 1.013 seconds includes the precomputation.

I'm just in the competition for the T-shirt... sadly I didn't get my T-shirt last year even though I made Round 3...  >:(
Logged

Titandrake

  • Mountebank
  • *****
  • Offline Offline
  • Posts: 2210
  • Respect: +2856
    • View Profile
Re: Google Code Jam
« Reply #24 on: April 27, 2013, 02:27:49 am »
0

Qualified for round 2, just. I failed one of the large test cases that I was sure I had gotten, so it was a lot closer than I was expecting.

I'm satisfied with this, since my goal was to at least tie what I did last year (qualify for round 2, then solve none of the problems.)

Edit: Okay wow, just realized why I got it wrong. Pro tip: reading the questions other people ask helps a lot.
« Last Edit: April 27, 2013, 02:32:19 am by Titandrake »
Logged
I have a blog! It's called Sorta Insightful. Check it out?
Pages: [1]
 

Page created in 0.052 seconds with 21 queries.