Hi,
At 110 in the python track, my side learnings have brought me to graph theory. I now realise that some programming problems are really fiddley with nested lists, but easier with graph theory. Such as: searching a grid, or testing a grid boundary, or looking at neighbouring cells, or even on an isometric grid. But these are easier with a graph theory tool. I can do some of the problems with import NetworkX as nx
locally and pass the tests, but I did have to pip install NetworkX
. So is this library available on the code testing servers? or is the point of the exercises to learn by doing it the fiddley way? Always checking if you are at a boundary, or have already been in this cell, or if you have counted that neighbour, or donât count it since it is outside the map/grid?
Thanks
Try it and see? Iâm fairly certain youâre mostly limited to the Standard Library but it should be really easy to run an import statement to check if a module is available or not.
The goal is Exercism is to become fluent in the language, not to explore third party packages. Writing your own graph search in Python is good practice, too!
The way to see whatâs available:
- navigate to the python-test-runner repo
- look at the Dockerfile
- see that it does
pip install -r requirements.txt
- look at requirements.txt
Python Maintainer here
Currently, we do not support any third-party libraries in our student-facing tooling with the exception of pytest
, pylint
, and their related plugins.
We wouldnât support NetworkX
even if we did have external libs. It is a difficult library (it takes up a bunch of space and has a ton of dependancies for the full version) that is buggy for several versions of Python we have to support â and its utility for our problem set is quite limited.
As Isaac has said, our primary focus is on fluency in core Python â the modules and code that come pre-packaged when you install the language from the PSF.
@glennj â the only problem with your method is that the requirements.txt
file has dependancies that we donât support for student code as uploaded to the website. While we use pytest
, pylint
, black
and others in the server, student solution code that explicitly used them would likely fail â although I havenât tried writing an ad-hock test and uploading it, so it could work? But probably not.
âŚas I go through documentation and other cleanup tasks here at year-end, I will make a note to annotate requirements.txt
files to that effect (and maybe be clearer in the track docs that weâre âfun freeâ when it comes to third-party libs).
Thank you so much everyone for such great answers (quick too), Plenty to work with here. (Over the break!)
Joined insiders.
Seasons Greetings.
@clexp On the other hand, assuming that youâre working locally, you could create a solution that uses 3rdparty libraries and upload it knowing it will fail the online tests but self-confident you are passing the tests locally. I have done this with Perl and Lua solutions.
My thoughts above were triggered by trying connect and dominoes.
I started with connect, hexagonal pathfinding challenge. I found this excellent resource, and thought, here is an exercise, the learnings from which will be usable. As I tried it out I was getting bogged down in translating hex to 2d, for graph edges, every step.
Then separately I read âIntroduction to Graph Theoryâ by Richard Trudeau, and heard a few podcasts about graph theory. I realised connect.py would be easier with a recursive path finding algorithm, so I did this. Wow, once graphed - the code for path finding is short and effective.
With my new found excitement over what graph methods could do, I approached Dominoes. This, I came to discover also lent itself to graph methods. Since it must start and finish with the same number, and since each domino is a fully defined edge in the graph, what you are looking for is an Eulerian path. However I could not find anyone attempting this method in the community solutions. How wrong am I?
What I did find, and was floored by, was a very slick and concise use of nesting recursive generators, by Lorimer1, for the dominoes exercise. I was so inspired, I had to do that instead.
Never the less, I still think there is room for an âEulerian pathâ graph method here. Or Not?