Google Answers Logo
View Question
 
Q: Generate Set Randomly ( Answered,   0 Comments )
Question  
Subject: Generate Set Randomly
Category: Computers > Algorithms
Asked by: xtrashock-ga
List Price: $20.00
Posted: 21 Nov 2006 14:34 PST
Expires: 21 Dec 2006 14:34 PST
Question ID: 784604
How can I write a function (prefer in perl/php language) to return a
set of items based on following input arguements?

min. number of items to be generate (at least 1 item)
max. number of items to be generate (at least min. items)
average value of items (each item assigned a value from 1 to 5)

Request for Question Clarification by answerguru-ga on 21 Nov 2006 16:57 PST
Does pseudocode work for you on this one? I'm not big on perl or php personally.

answerguru-ga

Clarification of Question by xtrashock-ga on 23 Nov 2006 12:14 PST
yes, pseudocode should be fine. please note where should i return the
error. thanks. :)
Answer  
Subject: Re: Generate Set Randomly
Answered By: keystroke-ga on 09 Dec 2006 12:15 PST
 
Hello xtrashock,

Thank you for your question.

I am going to write you the pseudocode for this:

------------------------------------------------

1 Accept input from command line or other input device

2 parse command line and find minimum item amount and maximum item amount.

3 if minimum item < 1 then display error "minimum items must be more than 0

4 if maximum < minimum or maximum <1 then display message "your
maximum level is incorrect, it must be greater than minimum and also
greater than 0.

5 if all arguments are correct in a for loop structured as
for x = min to max do print generated item

6 after each item is generated add the value to a counter that is
keeping a sum of the total values,

7 after each item has been generated calculate average using the following funtion
average = value total / max items

8 display average

9 end program run

Search strategy:
Personal knowledge

This should answer your question. If you need any additional
clarification, let me know and I'll be glad to assist you.

--keystroke-ga
Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy