I'm going to offer a dissenting opinion, for two reasons.

1. Python is almost always going to be good enough for Code Jam problems,
but once in a while it isn't. It's so much slower than C++ and Java for
certain kinds of algorithms that it can be hard to distinguish between a
good algorithm and a bad algorithm in C++ without knocking out some good
algorithms in Python. See below for a sort-of example.

2. Programming contests in general, and Code Jam in particular, are great
for expanding your knowledge of new languages! What better way to get
comfortable with the basics of any language than to use it for some basic
I/O and some algorithmic problem solving? Amit's object doesn't have to be
doing well at Code Jam: it can be simply learning!


Here's the example I mentioned above. I'm mostly writing this because it
might be a fun insight into the sorts of challenges I used to face, and
others still do, when writing problems for Code Jam.

The thought experiment: Consider writing a problem where there's an O(N^2)
algorithm that's clever and challenging to come up with, and an O(N^3)
algorithm that's dumb and simple. If I'm the problem writer, I want the
clever algorithm to pass, and the dumb one to take comfortably more than 8
minutes on a fast computer on the Large dataset.

Let's assume the dumb one is made up of operations that take a small number
of CPU cycles, and it's actually N^3 / 6; and the clever one is made up of
slower operations. But wait -- you also want at least a few test cases.
Usually you want 100, but let's say you're OK with T=20.

   - If you make N=1e4, the clever algorithm takes ~2e9 slow operations,
   and the dumb one takes ~3e12 fast operations. Given eight minutes, that's
   4e6 slow operations/second for the clever algorithm, or 7e9 fast
   operations/second for the dumb one. Uh-oh... on a fast computer, I can make
   that work just by breaking up the input file into (#processor cores) chunks
   and running the test cases in separate processes.
   - Now make N=2e4. An implementation of the clever algorithm needs to run
   2e7 slow operations/second, and an implementation of the dumb algorithm
   needs 6e10 fast operations/second. I think N is big enough there: now to
   get "dumb" you need to use multiple machines or maybe use a graphics card,
   both of which I figure are challenging enough that it isn't dumb anymore.

OK, so to distinguish between our hypothetical O(N^2) and O(N^3)
algorithms, the O(N^2) algorithm needs to run 2e7 slow operations (for some
value of "slow") per second. I wouldn't count on Python to get that done on
the first writing of the program; maybe with some tweaks.

For what it's worth I think there haven't been a ton of problems like this,
partly because they're such a pain to set up, and partly because we didn't
like setting problems that are hard to solve in particular languages (the
same reason problems generally avoid numbers over 10^18).

Cheers,
Bartholomew


On Wed, May 4, 2016 at 12:56 PM Xiongqi ZHANG <[email protected]>
wrote:

>
> > On Wednesday, May 4, 2016 at 2:29:05 PM UTC-4, Amit Attia wrote:
> > > Hello,
> > > I'm new to competitive programming, currently at GCJ round 2. I
> program using python, but familier with cpp from university course. I want
> to switch, but I don't feel like my cpp skills are flexible enough for
> competitive pragramming. Any tips for doing the switch?
> > >
> > > Another question: In order to use cpp I need to compile and run the
> data sets, in which environment and how contestants do it fast? Using an
> ide and creating a new project for each solution sounds like a time waster.
> > >
> > > Thenx in advance,
> > > Amit.
> >
> > Why do you want to switch? Python is great for competitive programming!
>
> +1, Python is a great language for competitive programming, especially for
> Codejam.
>
> Most OJs have very tight runtime limit (e.g. 1s for C++ and 2s for Java)
> and therefore C++ is usually preferred because it runs much faster than
> other language (may not be true at all!)
>
> Codejam provides much flexible runtime (4 min for small dataset and 8 min
> for large dataset, download/upload time included) and the runtime of a
> correct implementation will be mostly within 10 seconds. There is no need
> to switch to one particular programming language that has Fast runtime but
> stick to some programming language that make you comfortable.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/c88af6ca-def0-4dbd-beea-daa8de8c12d9%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAHaiWHPKRx-AFpnBZhvizE6G3YWs8HxRxdDOUzSgDL%2B_6isp1g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to