Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
yes some tests are random.
In your example city you can go from p2 to p0 but you cannot go from p2 to p0. To make the problem simpler, I prefered to avoid such cases as explained in the description even if there are algorithm to compute connected components in directed graphs.
Maybe it could be another kata ?
Given your question the problem was probably not correctly explained.
A district consists of all the places which are reachable, but not necessarily directly reachable. Since p0, p1 and p2 are reachable they are all in the same district. However, there is no street from p3 to the other places, so it is in another district.
To solve this problem, the order from which you start exploring does not matter.
I changed the description to make the problem more clear, I hope it will help.