Does the game ensure that a track of the given length even exists?
It does! Actually when the game creates a new level the “goal track” is the first thing created, then random tiles are placed around it, and finally all tiles orientations are shuffled.