Discover the Formula for Finding Trains of Any Length | Math Project Help"

  • Thread starter Thread starter heartless
  • Start date Start date
  • Tags Tags
    Algorithms
Click For Summary
SUMMARY

The forum discussion focuses on finding a formula for calculating the number of "trains" of integer lengths, specifically addressing the problem of determining how many unique combinations of rods can form a train of length n. The proposed formula is h = 2^(a-2) + 2^(a-3) + ... + 2^0 for a train length a greater than 3. The discussion emphasizes the importance of recognizing patterns in the values of h for lengths 1 through 7 and suggests that a recursive algorithm is the optimal approach for generating all possible trains of length n.

PREREQUISITES
  • Understanding of integer sequences and combinatorial mathematics
  • Familiarity with recursion in programming
  • Basic knowledge of algorithm design principles
  • Experience with mathematical proofs and validation of formulas
NEXT STEPS
  • Research "combinatorial mathematics" to understand the principles behind counting unique arrangements
  • Learn about "recursive algorithms" and their applications in problem-solving
  • Study "mathematical induction" to validate the proposed formula for different lengths
  • Explore "dynamic programming" techniques to optimize the generation of train combinations
USEFUL FOR

Mathematicians, computer scientists, and students interested in combinatorial problems, algorithm design, and recursive thinking will benefit from this discussion.

heartless
Messages
220
Reaction score
2
Hello math crew!

Here's the problem: http://www2.edc.org/makingmath/mathprojects/trains/trains.asp

just in case somebody doesn't want to click on the above link,

trains:
You can use rods of integer sizes to build "trains" that all share a common length. A "train of length 5" is a row of rods whose combined length is 5. Here are some examples:
trains0x.gif

Notice that the 1-2-2 train and the 2-1-2 train contain the same rods but are listed separately. If you use identical rods in a different order, this is a separate train.

* How many trains of length 5 are there?
* Come up with a formula for the number of trains of length n. (Assume you have rods of every possible integer length available.) Prove that your formula is correct.
* Come up with an algorithm that will generate all the trains of length n. Now I solved this problem, at least I think I solved it.
A formula for the number of trains of length n will be
a=length of a train
h=how many trains of a given length
2^(a-2) + 2^(a-3) + 2^(a-4)+...+ 2^2 + 2^1 + 2^0 = h
if a > 3
I'm not truly sure, if this formula is right, it works for 4,5,6,7 and seems to work for every length above 7, it doesn't work for lengths 1,2,3 though,
Also I have a problem with an algorithm.
Can anyone help me make one, or at least give some clues ont "how to make a good algorithm?" (eventually you may post some good books on algorithms. I got some books in my eye on algorithms, however still have not enough money or time to read 'em)

thanks for all the help fellows,
 
Last edited:
Physics news on Phys.org
The formula can be made much simpler. Write out a list of the h values for a = 1, 2, 3, 4, 5, 6, 7, ... There's a very obvious pattern. The idea for the algorithm should follow from the way you think about solving the first problem. Here's a hint: how do you figure out how many ways you can build an n-train if you know how many ways you can build an n-1-train, and n-2-train, ..., a 1-train, (and a 0-train)? Everything about this problem screams "recursion" so your algorithm should be recursive. You should probably end up using some sort of "recursive thinking" to solve the first problem, and you can apply this recursive thinking to figure out your algorithm.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 12 ·
Replies
12
Views
3K
  • · Replies 65 ·
3
Replies
65
Views
9K
Replies
2
Views
2K
Replies
9
Views
3K
  • · Replies 58 ·
2
Replies
58
Views
8K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K