The standard allowance is 35 feet of total duct, and that number is not the whole story because bends spend it. Each 90-degree elbow counts as roughly five feet and each 45 as two and a half. So a run with four right-angle turns has used twenty of its thirty-five before covering any distance. Manufacturers publish their own maximums for a given machine, and where those are shorter than code, the manufacturer's figure is the one that applies.
Only as a short listed transition connector between the machine and the wall, and even there rigid or semi-rigid is better. In the concealed run — through walls, ceilings or floors — it is not permitted, for two good reasons: every ridge catches lint, and it crushes flat the moment somebody pushes the dryer back against the wall. If your concealed run is foil, replacing it is the most worthwhile thing on this page.
Replacing foil with rigid metal on a short accessible run is a half-day job at the low end of this trade. A new exterior wall penetration costs more, mostly for coring, sealing and making good rather than for duct. Routing through a finished ceiling, or terminating at the roof, is higher again. The two things that move the number most are wall construction and whether the path already exists.
It can, and sometimes a middle-of-the-house laundry leaves no alternative. It needs a proper roof cap rather than a wall hood, and it should be planned knowing that lint has to travel upward, so the run will need cleaning more often than a wall-terminated one. If an outside wall is reachable at reasonable cost, take it — the difference in maintenance over twenty years is not small.
Not into a crawl space, attic, garage, soffit or wall cavity — all of which put warm wet lint-laden air into the structure, and all of which we still find. Not into a chimney flue, ever. And not somewhere the discharge blows straight back at a window, an air intake or a walkway. The termination needs a hood with a backdraft flap and no fine mesh screen.