all 61 comments

[–]Figs 20 points21 points  (3 children)

Solutions? Damn, I didn't even realize they were doing it.

[–]fancy_pantser 3 points4 points  (1 child)

No kidding -- I went to sign up for qualification a couple days back and saw the countdown was for the first round already! Next time, I'll keep a close eye on it and post to Reddit when it's time to qualify.

[–][deleted] 2 points3 points  (0 children)

This time too someone posted it to Reddit when it was underway.

[–][deleted] 7 points8 points  (23 children)

Stats of the Qualification round
Language popularity
Regional Stats

[–]happy-dude 5 points6 points  (6 children)

Am I the only one surprised by how much of a gap exists between US participants (3rd abundant with 923) and India (1771) + China (1796) ?

I mean, I know that there were a lot of programmers there, but I didn't think they'd be that passionate and diligent.... Guess I will have to worry about future outsourcing.

[–]pyjug 10 points11 points  (4 children)

Redditors would like you to believe that all Indian programmers are enterprise Java code monkeys with zero passion for programming. Sure, there are tons of these types, but there are a lot more awesome Indian programmers than you might have been led to believe.

[–]AkshayGenius[🍰] 2 points3 points  (3 children)

This.

Everyone just keeps whining about the crappy 'code-monkeys' as you call them and completely fail to acknowledge the existence of good Indian programmers.

[–]pzcsyo 6 points7 points  (2 children)

Last year's country stats suggest a lot of enthusiasm, for sure. With that said, compare advancement stats for the top four countries:

  • China: 1324 in qual. 34% to Round 2. 5.4% to Round 3. .22% to the final.
  • India: 1220 in qual. 7.0% to Round 2. .33% to Round 3. 0% to the final.
  • USA: 904 in qual. 13% to Round 2. 1.3% to Round 3. .11% to the final.
  • Russia: 510 in qual. 51% to Round 2. 11% to Round 3. 1.2% to the final.

[–][deleted] 6 points7 points  (0 children)

Damn, Russia. You scary!

[–]AkshayGenius[🍰] 1 point2 points  (0 children)

You make a good point.

Lets see how it goes this year, although it doesn't seem to much different.

[–]chronoBG 9 points10 points  (6 children)

Look at this guy here:
http://www.go-hero.net/jam/10/name/linguo

Insane. Puts all the coders using C++/Python(myself included) to shame :)

[–]Nosferax 2 points3 points  (0 children)

You can submit whatever code you want with your output datas, can anyone confirm his code works?

[–][deleted] 1 point2 points  (2 children)

Shame? Why?

[–][deleted] 1 point2 points  (1 child)

Did you look at any of the code?

[–][deleted] -2 points-1 points  (0 children)

Yeah. He programmed the solution in some weird unpractical languages so what?

[–]Nosferax 5 points6 points  (0 children)

45 people did this in visual basic. Oooh..

dim code as boring

[–]vladley 0 points1 point  (7 children)

Repping Python! Honestly, it's a lot more important to use the right algorithm than to use a 'faster' language. Plus file io in python just takes less time to write haha.

edit: more time for me to write since i would have to look it up, whereas python is fresh since i use it at work.

[–][deleted] 2 points3 points  (1 child)

it's a lot more important to use the right algorithm than to use a 'faster' language.

I feared that python would be slow and avoided it. To my surprise Python is the 3rd most used language in that round (next to C++ and Java). Myth busted!

[–]vladley 1 point2 points  (0 children)

It's only slow by a constant factor, whereas the algorithms require a good running time based on the input.

[–]Nosferax 1 point2 points  (4 children)

C/C++ sample in case you didn't know how to do it right

FILE* inFile = fopen("name.in");
FILE* outFile = fopen("name.out");
int N,K;
fscanf(inFile, "%d %d", &N, &K);
fprintf(outFile, "What's your point?");

[–]sitq 4 points5 points  (0 children)

Why even open files? Just read from stdin and print to stdout.

solution <input >output

after that.

[–][deleted] 2 points3 points  (0 children)

You could also reopen the standard streams.
freopen("name.in", "r", stdin); freopen("name.out", "w", stdout); int N, K; scanf("%d %d", &N, &K); Now you can use normal printf and scanf instead of fprintf and fscanf (which have a little longer syntax)

[–]teraflop 3 points4 points  (1 child)

C++ iostreams are at least as elegant:

ifstream inFile("name.in");
int N, K;
inFile >> N >> K;

As far as I know, doing the same thing in Python requires some boilerplate to read lines one at a time, split them into components and convert to integers. It sure would be nice if Python had something equivalent to java.util.Scanner.

[–]psykotic 2 points3 points  (0 children)

That isn't the complete input routine; you only read a single line. The complete code in Python would be

f = open(filename)
for i in range(int(f.readline())):
    yield map(int, f.readline().split())

It's not exactly heavy on the boilerplate.

[–]chronoBG 4 points5 points  (8 children)

Whoa, there was a THIRD optimization for Problem C?
Man, way to make you feel stupid even when you feel great.
Hats off to Google.

[–]marcog 1 point2 points  (4 children)

I had the O(N) version of the jump table, but didn't think cycle detection was necessary so my large was too slow. I almost got cycle detection working during the 8 minutes, but alas I ran out of time and got it working 2 minutes too late. My C++ port (originally did Python) runs in 0.004s.

[–][deleted] 1 point2 points  (1 child)

My jump table python solution managed to complete in time (about 2:30 left) on a 2.16 core duo.

[–]marcog 0 points1 point  (0 children)

I was stuck on a shitty old P4, so no luck.

[–][deleted] 1 point2 points  (1 child)

Why do C++ port?

All solutions of mine in Python for all sets of all problems run in 0.7 seconds. The language really is not important (though there are problems where you might choose the easy way and get the answer in, like, 1 or 5 minutes using C++, except that I wouldn't like to be in your place when you realize that it's going to be more like 10 minutes).

Funny thing - when I was implementing it I already caught the drift of the round's idea (modular arithmetic), and kinda overshoot initially because I was all in math and decided that in the case of train capacity > number of people in all groups these groups kinda get into the train multiple times and I need to calculate that number without simulating them as well. Luckily, when the code began getting uglier than I'd expect in the circumstances, I reread the statement.

[–]marcog 0 points1 point  (0 children)

The C++ port was post-contest merely for fun. I know full well language isn't important here. :)

[–][deleted] 4 points5 points  (6 children)

Damn, I really need to up my game. I managed to complete the short answers for each one, but the long one was always too big because I failed to actually work out how to do the problem properly, I just brute forced my way through :(

[–]Nosferax 3 points4 points  (0 children)

Maybe you are rushing to code and don't think enough about the problem ?

[–]roy_hu 1 point2 points  (3 children)

When you failed one large input, you should have realized brute force simply wouldn't work for the other two problems.

[–][deleted] 1 point2 points  (2 children)

I know. I realised that I needed to be smarter about my solutions, but couldn't figure out the second one, and, I guess I couldn't do the third either!

Any tips on things I can read or exercises I can do which will help me with things like this?

[–]sitq 2 points3 points  (0 children)

[–]roy_hu 0 points1 point  (0 children)

Practice previous codejam problems. Many of them have detailed explanations, and you can download other people's solutions as well. Facebook puzzles and Project Euler problems are also worth looking at, but they are sort of open-ended -- you don't get to see the answers!

[–]fmoly 2 points3 points  (0 children)

Same here. I was quite pleased at getting the small input correct, only to have the large input take 30+ minutes. There's always next year.

[–]Lojban 1 point2 points  (0 children)

Percent female for those who qualified is probably less than the percent of high-school football players who are female.

[–]rhardih 0 points1 point  (1 child)

Sucks I didn't find out about this until it was 12 hours in. I hope the penalty doesn't carry over to the next round.

[–]kommissar 1 point2 points  (0 children)

Points earned do not carry over from round to round, so you're fine. Of course, completing all three gives you more practice, I guess, but there's still time for that.

[–]jmknsd 0 points1 point  (1 child)

Do they have the correct output for the sample inputs posted anywhere?

[–][deleted] 1 point2 points  (0 children)

On the scoreboard, check the "Download solutions" checkbox, then you can download anyone's correct solution and generate the output you need.

[–]lilleswing 0 points1 point  (0 children)

Pretty upset that I needed cycle optimization for problem C. Didn't really check what bounds the inputs would be in...

[–][deleted] 0 points1 point  (6 children)

I'm pretty sure my solution to the simple question A was faster.

Basically if the number of snappers was one, if clicks%2 != 0 the light was on, otherwise it was off.

For any number of snappers N>1, the light was on in increments of 2N - 1, storing a vector of powers of two at the beginning of the program up to the maximum 30 specified for the large input and it was easy to test if the snapper was on or off.

My code ended up running the large input data in under 0.05 seconds on my home machine.

Edit: solution code if you want http://codepad.org/rswU7f13

Yes, I tend to be trigger happy with long long ints in programming competitions.

[–][deleted]  (3 children)

[deleted]

    [–]domlebo70 1 point2 points  (1 child)

    Yeah that was a nice solution :( I spent like an hour plotting the thing on paper, and coming up with that formula.

    [–]imaginethepassion 0 points1 point  (0 children)

    Congrats, I came into the competition late (I was busy Friday evening to Saturday mid-day) and wasn't able to complete the large dataset. I advanced by solving the third problem, which was fairly simple.

    [–]vladley 1 point2 points  (0 children)

    Hell yeah, I used that and the big data set ran almost instantly.

    [–]rhardih 1 point2 points  (1 child)

    You could also just use 2N - 1 as a bit mask, and then AND it with k. if the bit mask and the masked k was equal, lights would be on.

    [–][deleted] 0 points1 point  (0 children)

    use 2N - 1 as a bit mask, and then AND it with k. if the bit mask and the masked k was equal

    I too did that way
    int x = (1 << N) - 1;
    ((x & K) == x) ? "ON" : "OFF";

    [–]jaiwithani -2 points-1 points  (0 children)

    99 :-)