← Questions

Count ordered routes that visit one shop of each of four types

0
OpenAICodingLast asked Oct 2026

You need four things from four kinds of shop: a bookshop, a school-supply shop, a sports store and a stationery store. The town has many shops of each kind, joined by roads. Before searching for the shortest route, count how many ordered paths along the roads visit exactly one shop of each kind in the required order.

Explain how you count without listing every path, and the time it takes on a large town.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding