One possible solution to make this as simple as possible to quickly get a working algorithm would be as follows. The simplest layout is of course 12C (12 curved tracks all with the same orientation (relative to each other), and forming a simple circle. This will be the basis upon which we can build on.
So the basic algorithm will be to maintain the 360 degree continuous loop layout at every step when adding tracks. We can do this by examining how many curved tracks we have remaining, and adding them to the layout in groups such that the 360 degree property is maintained. For example, start with our 12C layout (a simple circle). We know we have 20C total so we have 8C remaining. The simplest addition of some of those that would maintain the 360 degree property would be to add a reverse orientation curve and a same orientation curve (same as the main circle we started with). We would then to do the same to the opposite side of the layout. In this simple example, we would have added 4 more curves to the circle layout so 12C would become 16C (with 4C leftover). We would continue placing curves until all 20 (in this example) are properly placed. Note that this layout consisting of all curves is a valid closed loop layout. The train can use this layout, however, it consists of all curved tracks so we are not yet done.
The straight tracks would then be inserted the same way except those can be added in pairs (2 tracks) since they are not changing the 360 degree property. They can be inserted anywhere so I think it would be best to first place ALL of the curved tracks, then go back and make a 2nd pass to place the straights randomly (but symmetrically).
This is the simplest algorithm I can think of for now. It is guaranteed to produce a 360 degree closed loop, a symmetrical track, and assuming the # of curves is a multiple of 4, and the # of straights is a multiple of 2, it will use each and every track.
One thing to consider though (when using this algorithm either on a computer or just in your mind as you are building the layout), is, there may be space restrictions more so in one direction than the other. For example, on a patio that is long, but not so wide. When using the algorithm, it should be biased more towards the long dimension of where the layout will be assembled.
If someone can figure out an algorithm to form an asymmetric layout using all of the tracks, that would be even more impressive.
The difference in complexity between the simplest solution and the most complicated is staggering. Starting with a circle (12C) is about as simple as it gets for this problem and is reasonable for kids, however it is very interesting to analyze a generic solution that can produce ANY valid layout (including asymmetric ones).
In reality, a non computer algorithm would be to just add some "cool" shapes to the layout and get it close to connecting, then go back and fine tune it so that it does indeed connect (for a closed loop). With 70 track pieces total (44C and 26S), a huge layout is possible. I calculated a total of about 67 feet of track which is about 20 meters. The train should take about 1 minute to loop that entire layout once.
Another candidate solution would be to take the actual measurements of each track and remember the rightmost edge of the layout. When building the layout, you can start with a straight track or with a left curve (counterclockwise), accumulating how far away the last added track is from that rightmost edge, and then when adding other tracks, never allowing a combination of tracks that will bump or cross that rightmost edge or maybe not even get close. So for example, start with a straight track (no 12C initial circle on this candidate solution), then randomly pick another track piece. Notice from the start we would NOT allow a right (clockwise) turn, since that would break the rule of "crossing" the rightmost edge. After the first straight track, our only options are another straight or a left (counterclockwise) curve. Another rule to enforce would be after a straight, we are not allowed to add more than 9 same orientation curves in a row, otherwise it will be likely to bump/cross some other tracks already in place. That limit could even be reduced to 8 for more clearance, and if that occurs, the next track MUST be a reverse oriented curve (since a straight may cause problems).
This algorithm would need some help to get it to come back and connect to the other side of that first added track piece. We can do that by insisting that counterclockwise curves count as +1 and clockwise curves count as -1, and those must add up to 12 on the last added curve. We can help this out by biasing the CC (counterclockwise) curves at a 4:1 ratio with clockwise curves, so that chances are we get 16 CC and 4 clockwise, which will effectively net a 360 degree circle. If the algorithm attempts to add a CC curve but bumps existing tracks, we have 2 options at that point, try an opposite orientation curve, or abandon the layout and start over. I would think that on a fast computer, eventually it will get a good layout.
I am not yet sure if this method would yield the all the same layouts as the starting with 12C, but perhaps it might be easier to implement on a computer since there are only a few rules to enforce, and we are building the layout one track at a time.
Actually, I just thought of a 3rd possible candidate solution that should work and is not too difficult to implement. It goes as follows.
Use the technique described above, but only make a half layout (using half of the tracks of each type, so 10 curves and 5 straights. We have the computer pick random tracks but only accept layouts that end up with a net of 180 degrees of left turn (because we are enforcing a right border that no track can touch or cross. Okay so assume the computer very quickly finds a valid "half layout". Then what we do is simply take an inventory of how many clockwise curves, and counterclockwise curves there are, and duplicate that in the other half of the track (but not necessarily symmetrically). For the straights, we have to record at what angle they were inserted at then match them in the other half of the track, but again, not necessarily symmetrically.
Lets try an example using S for Straight, O for cOunterclockwise curve, and C for Clockwise curve. Concentrating on the half layout first.
The first straight track will be going away from us and that defines our rightmost edge that we are not allowed to cross.
SOOSOCSOOSSOOOC - This is a valid half layout since it has 5 straights and 10 curves with a net of 6 counterclockwise curves (2 of the 8 were "cancelled out by 2 clockwise curves).
Now we need to "keep tabs" on what angle the straights were inserted at and match those with a same angle (but opposite direction) track to "cancel" them out.
1: 0 degree angle straights
0: 30 degree angle straights
2: 60 degree angle straights
0: 90 degree angle straights
2: 120 degree angle straights
0: 150 degree angle straights
0: 180 degree angle straights
So to "match" this on the other half of the layout and make it so it connects to the single starting straight track, we just need to match the same number of Os and Cs, but also match the same # of straights at the +180 degree "returning" angle. For example, a 60 degree straight better have a 240 degree straight on the other side of the layout somewhere, not necessarily exactly opposite. This is because the 60 degree straight will go mostly to the left and a little up (using this scheme) and the 240 degree straight will bring it back to the right and back down the same amount to effectively "cancel" those 2 tracks contributions to deviating from the starting track position.
So now all we need to do to create the "missing half" of the layout is take the known tracks we need (and knowing at what angles the straights have to be), and just "scramble" them in any order.
There may be a way to NOT have to match exactly the one half of the layout with "complementary" tracks on the other side, but that would involve some more complex math and there probably isn't enough time to solve that in the time the bounty is active for. There is also a chance that not all the tracks would be used that way and some slight bending of the track would be required. We can ignore this special property for this question.
I actually made an asymmetric track to see if it would work and it seems it did. Using S for straight, O for cOunterclockwise curve, and C for Clockwise curve, plus the angle (in degrees) relative to the starting straight track, I got the following for the upper half:
S0, O30, O60, S60, O90, C60, S60, O90, O120, S120, S120, O150, O180, O210, C180
For the bottom half of the track I got:
O210, O240, S240, C210, O240, S240, O270, O300, S300, S300, O330, O360, O390, C360, S360
Actually the picture was taken from the wrong side so the top and bottom are flipped. The first track layed was the straight near the blue trashcan and coming towards the viewer of the pic and the 2nd track is the counterclockwise curve.
It seems like this technique would work for many even number of curves and even number of straights, including 44C and 26S which is my ultimate goal. This is really encouraging since an electronic computer isn't really necessary to solve this, I can just have the kids build just about any half circle shape they want with half of the tracks (22C and 13S), then "correct" their design so that it is 180 degrees, then "match" the other side of the track, not necessarily symmetrically.
You would have to be careful if you were to create 180 degree half layout where the starting track and the ending track are very close together. For example, the shape of the upper part of a question mark "?" (without the dot) but continue that upper curve so it comes around more and a straight going down from that would be very close to the straight that is above where the dot was. Then for the bottom half, you would NOT be able to do more counterclockwise curves right away since there are other straights there from the "top half". The image of my closed loop layout worked because I had no "bottlenecks" in the "upper" half but of course those are possible as I just described.
The "problematic" train layout is when one half of the track makes somewhat of an hourglass shape with a narrow middle. In that case, you almost have to "mirror" the top part because certain curves cannot be made since the tracks are so close to each other. Here is an example...
Another interesting observation is that 4 zigzag curved tracks is almost an exact replacement (as far as linear distance spanned) for 5 straights. However too many of these will create a significant difference in length. As stated in the UPDATED section above, 20 zigzag curves is almost an exact match (for linear distance) as 24 straights.
Using this technique, a giant layout can be made with all 70 track pieces. It would start with a 12C circle, then on one side, I could insert
24 straights (240 inches long). On the opposite long side of the layout (to almost match the length of the straight side), I would use 20 zigzag curves (also about 240 inches long). Those should almost line up and a slight bend should make it work. The remaining tracks (2 straight and 12 curved) could easily be placed to keep the layout "balanced" (and connected).