I thought I would offer the brute force solution.
The idea is to try every single track layout in turn. When constructing a layout, there are only three pieces that need to be taken into consideration: a left handed curve, a right handed curve and a straight.
You can encode the track layout as a base 3 number with a width corresponding to the number of pieces in the layout. To enumerate all track layouts just count in base 3, where the encoding goes 0=straight, 1=left and 2=right.
The next stage is to check that the layout joins up at both ends. The first check is to make sure there are enough curves to go one complete circuit. If we choose an anti-clockwise sense for one circuit, then 12 left curves are needed. For every extra right curve, we need to add on extra left curve. So to check the particular layout might work, just add the number of left curves and subtract the number of right curves - this must equal 12.
Lastly, we need to check the ends actually meet. We simply plot the track on a cartesian grid. We start the origin at [0,0] and if it ends at [0,0], then it joins.
The simplest way to plot the track is LOGO style. 7
In other words we maintain a direction vector which points in the direction of the last layed track piece. If we encouter a left curve, then rotate the direction by 30 degrees and for a right curve rotate by -30 degrees - a straight does not affect the direction.
To actually plot the curves and straight, we scale up the direction vector by the size of the piece, i.e. 10 units for a straight, and 12.4 x 12 / 2 x pi (radius of complete circular track) units for a curve.
CAVEATS
Due to rounding errors in adding up floating point numbers, the plotting is not exact. And in real life we can leave some wiggle room for the ends to meet, so this needs to be catered for.
Many layouts will be the same, but shifted by one position. I can't see a way to exclude duplicate shifted layouts other than to keep previous ones and check against them.
The algorithm does not exclude layouts where pieces cross. In order to do that, you would have to check that each piece in a layout does not cross another piece in the layout (thats O(n^2)). And there would have to be checks for curve-curve, curve-straight and straight-straight crossings, and that starts to get very complex.
The running time of the algorithm is obviously O(3^N) which is exponential - and probably impractical for very large layouts.
Below is some VBA code you can paste into Excel to give you proof of concept. I've deliberately tried to keep the code as simple as possible to aid conversion to your favourite language. Any questions, please feel free to ask.
Option Explicit
Type Vector
X As Double
Y As Double
End Type
Sub GenerateTrackLayout()
Dim lCounts(40) As Long
Dim lColumn As Long
Dim lTrackLength As Long
Dim lCurveSum As Long
Dim lIndex As Long
Dim lIndex2 As Long
Dim vDirection As Vector
Dim vBase As Vector
Dim vTrackPosition As Vector
Dim fPI As Double
Dim fCurveRadius As Double
Dim fStraightLength As Double
Dim sPath As String
Dim lOutputRow As Long
Const TOLERANCE = 0.5 'inch
lOutputRow = 1
vBase.X = Sqr(3) / 2 ' 30 degrees
vBase.Y = 1 / 2 ' 30 degrees
fPI = 4 * Atn(1)
fCurveRadius = 12.4 * 12 / (2 * fPI)
fStraightLength = 10
lTrackLength = 12 ' initial track length
Application.ScreenUpdating = False
Do
' Check for closed track
lCurveSum = 0
For lIndex = 0 To lTrackLength - 1
If lCounts(lIndex) = 1 Then
lCurveSum = lCurveSum + 1
ElseIf lCounts(lIndex) = 2 Then
lCurveSum = lCurveSum - 1
End If
Next
If lCurveSum = 12 Then ' one 360 degree rotation anti-clockwise
vDirection.X = 0
vDirection.Y = 1
vTrackPosition.X = 0
vTrackPosition. 7