Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: help with a programing problem

  1. #1
    bornwithnoname's Avatar Bit Master BT Rep: +1
    Join Date
    Sep 2006
    Location
    USA
    Posts
    364
    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.
    Last edited by bornwithnoname; 01-29-2008 at 09:50 PM.

    I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. (Terry Prattchet)

  2. Internet, Programming and Graphics   -   #2
    Barbarossa's Avatar mostly harmless
    Join Date
    Jun 2002
    Location
    Over here!
    Posts
    15,180
    What are you trying to find out? The number of steps?

  3. Internet, Programming and Graphics   -   #3
    bornwithnoname's Avatar Bit Master BT Rep: +1
    Join Date
    Sep 2006
    Location
    USA
    Posts
    364
    no I need to designa program that models the worm’s behavior in the given scenario.

    I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. (Terry Prattchet)

  4. Internet, Programming and Graphics   -   #4
    Barbarossa's Avatar mostly harmless
    Join Date
    Jun 2002
    Location
    Over here!
    Posts
    15,180
    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


  5. Internet, Programming and Graphics   -   #5
    bornwithnoname's Avatar Bit Master BT Rep: +1
    Join Date
    Sep 2006
    Location
    USA
    Posts
    364
    I contend that ThrustCount will = 0 until penis enters vagina, but I degress. Thanks for the help

    I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. (Terry Prattchet)

  6. Internet, Programming and Graphics   -   #6
    Barbarossa's Avatar mostly harmless
    Join Date
    Jun 2002
    Location
    Over here!
    Posts
    15,180
    Couldn't resist changing the variable names, sorry!

  7. Internet, Programming and Graphics   -   #7
    bornwithnoname's Avatar Bit Master BT Rep: +1
    Join Date
    Sep 2006
    Location
    USA
    Posts
    364
    Quote Originally Posted by Barbarossa View Post
    Couldn't resist changing the variable names, sorry!
    It was more interesting than apples anyway

    I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. (Terry Prattchet)

  8. Internet, Programming and Graphics   -   #8
    bornwithnoname's Avatar Bit Master BT Rep: +1
    Join Date
    Sep 2006
    Location
    USA
    Posts
    364
    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

    I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. (Terry Prattchet)

  9. Internet, Programming and Graphics   -   #9
    Barbarossa's Avatar mostly harmless
    Join Date
    Jun 2002
    Location
    Over here!
    Posts
    15,180
    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

  10. Internet, Programming and Graphics   -   #10
    bornwithnoname's Avatar Bit Master BT Rep: +1
    Join Date
    Sep 2006
    Location
    USA
    Posts
    364
    sorry about that... It was a left over thought from tryi ng to solve the problem

    I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. (Terry Prattchet)

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •