dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: coding challenge

  1. #1
    Join Date
    May 2010
    Posts
    1

    coding challenge

    There is a factory production line around a single a conveyor belt.

    Components (of type A and B) come onto the start of the belt at random

    intervals; workers must take one component of each type from the belt
    as they come past, and combine them to make a finished product.

    The belt is divided into fixed-size slots; each slot can hold only one
    component or one finished product. There are a number of worker

    stations on either side of the belt, spaced to match the size of the
    slots on the belt, like this (fixed-width font ASCII pic):
    v v v v v workers
    ---------------------
    -> | A | | B | A | P | -> conveyor belt

    ---------------------
    ^ ^ ^ ^ ^ workers

    In each unit of time, the belt moves forwards one position, and there
    is time for a worker on one side of each slot to EITHER take an item

    from the slot or replace an item onto the belt. The worker opposite
    them can't touch the same belt slot while they do this.
    (So you can't have one worker picking something from a slot while
    their counterpart puts something down in the same place).


    Once a worker has collected one of both types of component, they can
    begin assembling the finished product. This takes an amount of time,
    so they will only be ready to place the assembled product back on the

    belt on the fourth subsequent slot. While they are assembling the
    product, they can't touch the conveyor belt. Workers can only hold
    two items (component or product) at a time: one in each hand.

    Create a simulation of this, with three pairs of workers. At each

    time interval, the slot at the start of the conveyor belt should have
    an equal (1/3) chance of containing nothing, a component A or a
    component B.

    Run the simulation for 100 steps, and compute how many finished

    products come off the production line, and how many components of each
    type go through the production line without being picked up by any
    workers.


    Implementation in C or C++?

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,649

    Re: coding challenge

    That actually sounds like a funny little exercise if combined with some animation.

    Anyway, the bitter reality is that since I don't have any deadline to meet as you have you probably will beat me to it. Looking forward to see the final result though.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

  3. #3
    Join Date
    Feb 2016
    Posts
    2

    Re: coding challenge

    totally agree with sma i would be a really appealing if you could put some animation along with it, still if you seek some help you can contact these people conveyor belt rubber hope they might be able to help you out. thanks

  4. #4
    Join Date
    Jun 2011
    Posts
    1

    Re: coding challenge

    Hi ,

    If you have the solution please share the link.

    Thanks



    Quote Originally Posted by tuderplank View Post
    There is a factory production line around a single a conveyor belt.

    Components (of type A and B) come onto the start of the belt at random

    intervals; workers must take one component of each type from the belt
    as they come past, and combine them to make a finished product.

    The belt is divided into fixed-size slots; each slot can hold only one
    component or one finished product. There are a number of worker

    stations on either side of the belt, spaced to match the size of the
    slots on the belt, like this (fixed-width font ASCII pic):
    v v v v v workers
    ---------------------
    -> | A | | B | A | P | -> conveyor belt

    ---------------------
    ^ ^ ^ ^ ^ workers

    In each unit of time, the belt moves forwards one position, and there
    is time for a worker on one side of each slot to EITHER take an item

    from the slot or replace an item onto the belt. The worker opposite
    them can't touch the same belt slot while they do this.
    (So you can't have one worker picking something from a slot while
    their counterpart puts something down in the same place).


    Once a worker has collected one of both types of component, they can
    begin assembling the finished product. This takes an amount of time,
    so they will only be ready to place the assembled product back on the

    belt on the fourth subsequent slot. While they are assembling the
    product, they can't touch the conveyor belt. Workers can only hold
    two items (component or product) at a time: one in each hand.

    Create a simulation of this, with three pairs of workers. At each

    time interval, the slot at the start of the conveyor belt should have
    an equal (1/3) chance of containing nothing, a component A or a
    component B.

    Run the simulation for 100 steps, and compute how many finished

    products come off the production line, and how many components of each
    type go through the production line without being picked up by any
    workers.


    Implementation in C or C++?

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,734

    Re: coding challenge

    Quote Originally Posted by rajeshkumar1984 View Post
    Hi ,

    If you have the solution please share the link.

    Thanks
    Since the the op posted this single question 8 years ago and hasn't been back since, it is unlikely that he will return to give an answer. Probably best to solve homework questions yourself. Students that do this usually end up finding jobs and success; those that don't, well...

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)