PDA

View Full Version : help with a programing problem



bornwithnoname
01-29-2008, 09:29 PM
Here is the problem

Design a program that models the worm’s behavior in the following scenario:


A worm is moving toward an apple. Each time it moves, the worm cuts the distance
between itself and the apple by its own body length until the worm is close enough to
enter the apple. The worm can enter the apple when it is within a body length of the
apple.

Here is my working solution. This is not an exercise in writing a program in a specfic language, but an exercise in how to write a program.

input module

declare Wormlength, AppleDistance as real

write what is the length of the worm?
input WormLength

write What is the distance to the apple?
input AppleDistance

While AppleDistance > Wormlength
AppleDistance - Wormlength

This is where I start running into problems. I know I need some kind of loop function and I need away to keep track of the distance covered.

Any help or direction would be great.

Barbarossa
01-29-2008, 09:32 PM
What are you trying to find out? The number of steps? :blink:

bornwithnoname
01-29-2008, 09:49 PM
no I need to designa program that models the worm’s behavior in the given scenario.

Barbarossa
01-29-2008, 09:56 PM
input module

declare Penislength, VaginaDistance, ThrustCount as real

write what is the length of the penis?
input PenisLength

write What is the distance to the vagina?
input VaginaDistance

Set ThrustCount = 0

While VaginaDistance > PenisLength
Decrease VaginaDistance by PenisLength
Increase ThrustCount by 1
end while

Call Process EnterVagina

:blink:

bornwithnoname
01-29-2008, 10:28 PM
I contend that ThrustCount will = 0 until penis enters vagina, but I degress:P:w00t:. Thanks for the help

Barbarossa
01-29-2008, 10:31 PM
Couldn't resist changing the variable names, sorry! :P

bornwithnoname
01-29-2008, 10:34 PM
Couldn't resist changing the variable names, sorry! :P

It was more interesting than apples anyway

bornwithnoname
01-31-2008, 01:05 PM
I have another question relating to the original question. Is the counter actually need for this to work? I think the computer should be able to remember the value of VaginaDistance without the counter I could be wrong. I know I can have loops with and without counters. It seems to me this would be a time were a counter isn't needed. thanks

Barbarossa
01-31-2008, 01:10 PM
You don't need the counter to model the behaviour of the worm, no. I only put one in because you said you wanted a counter :mellow:

bornwithnoname
02-01-2008, 01:29 AM
sorry about that... It was a left over thought from tryi ng to solve the problem

lightshow
02-03-2008, 01:21 AM
Even better you can make it an object and use it/call it over and over again!

Just like real life ;)