The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Assigning
Author Message
Catalan_mistral
Journeyman
*

Posts: 54
Likes Given: 2
Likes Received: 6 in 5 posts
Joined: Jan 2017
Reputation: 0



Post: #1
Random Assigning
Need pointing in the right direction, i'll try an explain the scenario

Say I have a list of 5 items apple,pear,banana,orange,Football

I need to pick a random item then remove it from the list, so that the next pick is a random pick from the remaining 4 items and so on and so forth, until the last pick is the last item left by default.

I know I could pick a random item then check to see if it has already been picked, and if it has been then it picks again until it finds one that hasn't been picked before, but I am presuming the larger the list the more chance of it hitting a picked item.

The One and Only......
03-04-2017 11:27 AM
Find all posts by this user Like Post Quote this message in a reply
Ben
Sphere Developer
*****

Posts: 612
Likes Given: 2
Likes Received: 123 in 70 posts
Joined: Mar 2010
Reputation: 18

SphereCommunity

Post: #2
RE: Random Assigning
Using LIST would be my choice. http://wiki.spherecommunity.net/index.php?title=LIST
Pick a rand number from list.xxx.count, get that element, then remove it from the list.

AxisII's current version: 2.0.4j
AxisII SourceCode on Github
AxisII up to date changelog
03-04-2017 11:48 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Catalan_mistral
Journeyman
*

Posts: 54
Likes Given: 2
Likes Received: 6 in 5 posts
Joined: Jan 2017
Reputation: 0



Post: #3
RE: Random Assigning
Bah should of thought of that, already played around with lists on another script for the sorting aspect of it, Thank you Ben

The One and Only......
03-05-2017 12:13 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)