
CodingBat: Python - shawndumas
http://codingbat.com/python
======
Luyt
Instead of

    
    
        def sum_double(a, b):
            # Store the sum in a local variable
            sum = a + b
            # Double it if a and b are the same
            if a == b:
                sum = sum * 2
            return sum
    

I wrote:

    
    
        def sum_double(a, b):
            return (a+b)*2 if a==b else a+b
    

My solution was accepted. Apparently the site evaluates the python program.
This is much better than some online C++ test I once took, where my entry had
to match perfectly a pre-canned solution letter by letter (it would even balk
on differences in whitespace).

------
megamark16
Awesome! Back when I worked at a bank we used to do timed challenges over at
<http://javabat.com> (same thing but for java). Now that I hack Python all day
this is much more my thing, although it's not that much of a challenge, it'll
give me somewhere to send the greenhorns.

~~~
freakwit
codingbat is javabat renamed. Presumably because they added python

------
jacobolus
The idea is neat, but all of these problems are trivial (that is, they’re
about following a simple set of very concrete instructions rather than
figuring anything out). It would be a more interesting site if there were some
more challenging problems.

~~~
freakwit
The real idea here is mentioned in the about page:
<http://codingbat.com/about.htm>

Summarised... a CS lecturer noticed that students who struggle with the small
things like syntax, have less time to focus on the big issues of algorithms
and data structures. The site gives short practice problems to that effect.

More challenging problems would be interesting, but there's a limit to what
you can fit in the stated goal of short problems. Although, I wouldn't say
that more difficult problems could be solved in similar space :)

~~~
jacobolus
Okay, I agree that “you also need skill in the ‘small’ – 10 or 20 line
methods”, but almost all of these can be implemented in 1 or 2 lines.

------
ek
Nick Parlante has done good with this project. At UCSB, I'm on a team that's
doing research into running this kind of website with unit tests, etc. for
even more languages and for harder problems, as a curriculum aid.

