A great way to learn a new language is by solving small problems and receive feedback from more experienced developers. There happens to be a wonderful new platform that does just that.
Hold on to your cross because a new devil is in town called Exercism!
Let’s get ready for some exercise!
I don’t want to spoil your fun and solve an actual exercise. So let’s make our own.
A typical exercise has three files:
This is where the problem gets explained.
Here are all the tests that need to pass in order for the problem to be solved.
This is where you will write your own code.
Our own exercise
We have to understand the problem before we can think of a neat and clever solution.
Lucky for us, every exercise comes with a
Here is a sample you will encounter in your typical exercise.
Now we know the problem, but how do we know when we are done?
Great question, my dear reader.
Every exercise comes with its own test suite. When all the tests pass you are done, how convenient!
Speaking of test suites, here is ours:
You might have noticed that every test method is marked as skipped, if you didn’t don’t worry you would’ve figured it out when running the test suite.
Lucky for us. That’s what we are going to do next!
After running the tests we unskip the first one.
The test fails because it can’t find
calc. Let’s make a file called
calc.py and run those tests again.
Oh no, now it can’t find the
The simple solution is usually the best one and in this case it looks like we need to define the
add function which accepts two numbers. We then have to return the sum.
Now we continue with the next test, we are making progress!
Unskip the second test and run the test suite again.
They pass too, how cool is that?!
All the tests are passing and obviously this masterpiece must be shared with the world, it would be rather selfish if we didn’t. So let’s do that!
Exercism makes this very easy for us. Just run the command
exercism submit calc.py.
Now our masterpiece is up for review and other awesome developers can comment on our piece of code. That’s Exercism in a nutshell. Don’t be shy and try your first exercise on this wonderful learning platform.