what can i do to improve my skill after finished python course on codecademy

Chris Angelico rosuav at gmail.com
Sun Nov 2 17:12:56 EST 2014


On Mon, Nov 3, 2014 at 9:07 AM, Dave Angel <davea at davea.name> wrote:
> Brute force would take a few millenia, as something like
>     ans = sum(range( BIG ) - sum(range(1000))
>
> But just knowing the math lets you simplify it to something like
>    ans = (1000 + BIG) * (BIG - 1000) / 2

Suggestion: Master the brute-force approach first, and use that (on
small ranges) to verify the simplified version. And if you already
happen to know the sum of all numbers from 1 to 100, say, then you can
test both approaches against that, to be sure they're right.

ChrisA



More information about the Python-list mailing list