Okay, my question this morning is inspired by trying to solve a problem for my sons (5, and 2.5 years old).

Over the course of the last several years, we've collected several sets of toy train tracks. Some are "Thomas the Train", some are Tomy, and some are GeoTrax. Toy tracks are generally built in a similar fashion -- several pieces of varying lengths and curvatures. There are generally straight, curved (usually either an eighth or quarter circle), split curved (a straight track with a curved bifurcation), and bridges (these tend to differ from set to set, but the simplest is a straight up and straight down, with a tunnel to support the middle). For an example of Geotrax, see http://www.fisher-price.com/us/geotrax/default_flash.asp

Arranging these tracks can involve a lot of trial and error. Although I'd be happy to let my sons engage in this work (heck, that should be the fun of it), I end up doing quite a bit of it (and I find it a bit tedious setting up and rearranging tracks all the time). What I'd like is to be able to have a program that would give me workable (i.e., closed) arrangements. I'm not really sure even what sort of algorithm I'd use. I'd need to start with the number of pieces of each type.

As a "simple" example (I hope simple, anyway): I'm sure there must be some algorithm for this. I've also considered trying to create track objects (with length, curvature, endpoint properties) and then laying them on a virtual grid and simply trying to determine by coordinate whether the figure is closed or not. In a way, this is as much an exercise to expand my knowledge of perl/programming, so any pointers as to direction would be appreciated.

If not, it's not a hugely important problem, though it would let me lay out designs for my children without spending an hour shifting track around.

In reply to Closed geometry: a train track problem by SamCG

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.