General Discussion Undecided where to post - do it here. |
Reply to Thread New Thread |
![]() |
#21 |
|
I would like to imagine that the rubber band only has so much elasticity. Is there some sort of formula that you could use, given the length of the rubber band and how far it stretches each day, that would calculate the maximum length the rubber band could stretch? edit - Here is the problem exactly as given: Exercise 2. This does not require an array! An elastic rope starts out with length 100 meters. The start of the rope is fixed to a pole and a worm is placed on the rope at the start and the worm starts crawling towards the end. Each day the worm crawls 6 meters along the rope. Each day the rope is stretched by 100 meters. After how many days does the worm reach the end of the rope? No help allowed from TAs or the Learning Center. Test the program 10, 6, 5 and 4 meters per day. Use a named constant for the meters per day value. |
![]() |
![]() |
#22 |
|
Yeah, that seems like a rubbish question. If you are to assume the rope can be streched out indefinitely then of course the worm will never reach the end. If you are to assume the rope can only go so far or will snap or something, you'll probably be needing more information than you've been given.
This is why I hated university. |
![]() |
![]() |
#23 |
|
I think it should be ok because the rope won't stretch to make the finish 100m further, but only a certain percentage of 100m. So, say, on the first the worm will travel 6m, then the rope will overall stretch by 100m. But since the worm is 6m from the start, the finish will only be 188m away, rather than 194m. So it would seem that each day the stretch will effect the extra distance less and less, until eventually it means an extension of less than 6m a day.
So it kinda seems plausible that the worm would reach the end eventually. If you've already taken this into account and you still get it taking infinite time, then I'm all out of ideas! |
![]() |
![]() |
#24 |
|
|
![]() |
![]() |
#25 |
|
I think that the distance from the finish that the worm is on the nth day is:
xn = (xnm1 - 6)*((1/n) + 1) where xnm1 is the distance from the end on the previous day. Looking at this it looks like the 2nd bracket will converge to 1 and so eventually xn = xnm1 - 6. So I reckon it would reach the end eventually. Just written a C++ prog to do it and it's taken a while to reach the peak distance, it's dropping now. I'll edit in an answer when it arrives! Edit: 9.7*E6 days...hmmm..Wouldn't trust the answer fully, because there is probably some issues with rounding that need to be considered. |
![]() |
![]() |
#26 |
|
Keep it simple guys....
The worm travels 6 meters and the band will get 100 meters longer everytime. It takes no fool to see the the distance from the worm to the finishline will get 94 meters longer each day. Rubber band stretched each day - distance travel each day = added distance. 100 - 6 = 94 If the rubber band only got stretched 5 meters a day, then the worm would get closer to the end every day. 5 - 6 = -1 (the distance would be 1 meter shorter each day) Conclusion: For the worm to ever reach the end of the band, it has to travel further than the rubber band is stretched. Or... (Rubber band stretched each day) < (distance travel each day) BUT........That is only so if you assume that the worms travled distance isn't affected by the rubber band stretching. |
![]() |
![]() |
#27 |
|
Thats exactly it. He didn't give enough info to determine if the stretching effects the worms position. And take a look at the sample output he provided:
Code: Code
Sample Output Day = 0 Million. Distance from end = 0 Million meters. Day = 1 Million. Distance from end = 19 Million meters. Day = 2 Million. Distance from end = 30 Million meters. Day = 3 Million. Distance from end = 39 Million meters. Day = 4 Million. Distance from end = 45 Million meters. Day = 5 Million. Distance from end = 49 Million meters. ……. When the worm crawls 6 meters per day: the worm reaches the end of the rope on day = ……. and he gave us this code to start: Code: Code
public class Worm { public static int DISTANCEPERDAY = 6; public static void main(String[]arg) { double ropeLength = 100; double distanceFromStart = 0; double distanceFromEnd = ropeLength; int day = 0; while (…………………………………..) { } System.out.println("When the worm crawls " + DISTANCEPERDAY + " meters per day:"); System.out.println("the worm reaches the end of the rope on day = " + day); } } Looking at he output only proves that the worm will never reach the end... |
![]() |
![]() |
#28 |
|
Keep it simple guys.... distance from end on nth day: xn = [(xnm1 - 6)/n*100]*100 + xnm1 - 6 which simplifies to the formula I gave in my previous post. Thing is I'm assuming that the worm is allowed to travel 6m, and then the band stretches instantly by 100m. The problem gets a little harder if you stretch the band gradually through the day while the worm travels gradually by 6m. But still this should give a similar convergent result. You can see this by taking the limit that xn is, say, a hour rather than a day. Hence, the speeds would just be 6/24 for the worm and 100/24 for the stretch per hour. Obviously for an accurate result you would take the limit to some small amount of time. But, the formula still holds true for that. |
![]() |
![]() |
#29 |
|
....Looking at he output only proves that the worm will never reach the end... My programming skills are not very good. Look at these: 'ropeLength = 100' and 'distanceFromEnd = ropeLength' The rope stretches 100m each day, so that would be: 'ropeLength = ropeLength+100' So that would mean that 'distanceFromEnd' would increase by 100 each day........unless 'ropeLength' is 'ropeLength+100-6'...but that would still increase the 'distanceFromEnd' by 94m each day. |
![]() |
![]() |
#31 |
|
it's a infinite loop as we don't know howmuch the band strecthes, not a limit provided, we may assume it is endless.. so it's a never ending story. |
![]() |
![]() |
#32 |
|
|
![]() |
![]() |
#34 |
|
|
![]() |
![]() |
#35 |
|
|
![]() |
![]() |
#36 |
|
If a frog is 1 inch from a wall and jumps half the distance from him to the wall, how many half distance jumps will it take before he reaches the wall?
________ Life saber information |
![]() |
![]() |
#37 |
|
If a frog is 1 inch from a wall and jumps half the distance from him to the wall, how many half distance jumps will it take before he reaches the wall? A similar question, which is more physics based is: Whenever you travel somewhere you must first travel to half the distance between where you are and where you are going...and then once you are at the half way point you must travel half way from where you are to the finish..etc etc. How do you ever get to where you are going, cos surely you are always only half the distance closer to where you are going compared to the previous step? ![]() I'll let you mull over it before I give a possible explanation. |
![]() |
![]() |
#38 |
|
The point of this excercise ( like all school/training ) isnt to FIND the answer, its how to get AROUND the answer. Either steal the code from someone elses computer, or tell the teacher that its stupid and you werent going to waste your time with it and you want a PRACTICAL question for the real world.
|
![]() |
![]() |
#39 |
|
A similar question, which is more physics based is: Whenever you travel somewhere you must first travel to half the distance between where you are and where you are going...and then once you are at the half way point you must travel half way from where you are to the finish..etc etc. How do you ever get to where you are going, cos surely you are always only half the distance closer to where you are going compared to the previous step? |
![]() |
Reply to Thread New Thread |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|