I am looking to randomly shuffle a list/array using a key. I want to be able to repeat the same random order using the key.
So I will randomly generate a numeric key from say 1 to 20 then use that key to try and randomly shuffle the list.
I first tried just using the key to keep iterating through my list, decrementing the key until=0,...
Hey,
I am trying to get jQuery to generate a random background on my site body absed off a number. So I'm trying to get it to generate either main1.jpg or main2.jpg and throw it into the body as a background.
For some reason it is only generating main2.jpg. Here is my code:
$(document).ready(function(){
$("body").css({'background...
Ok,
I've been doing a lot of reading on returning a random row set last year, and the solution we came up with was
ORDER BY newid()
This is fine for <5k rows. But when we are getting >10-20k rows we are getting SQL time outs, the Execution planned tells me that 76% of my query cost comes from this line. and removing this line increa...
Does anyone know how I could easily generate random numbers following a normal distribution in C/C++ ?
http://www.mathworks.com/access/helpdesk/help/toolbox/stats/normrnd.html
I don't want to use any of Boost.
I know that Knuth talk about this at length but I don't have his books at hands right know.
Thanks,
...
From an array
$my_array = array('a','b','c','d','e');
I want to get two DIFFERENT random elements.
With the following code:
for ($i=0; $i<2; $i++) {
$random = array_rand($my_array); # one random array element number
$get_it = $my_array[$random]; # get the letter from the array
echo $get_it;
}
it is possible to g...
Hi, I have been doing some testing on the Random class and I have used the following code:
while (x++ <= 5000000)
{
y = rnd.Next(1, 5000000);
if (!data.Contains(y))
data.Add(y);
else
{
Console.WriteLine("Cycle {2}: Repetation found for number {0} after {1} ...
How can you disallow some nubers from being chosen with the arc4random function?
Current code:
int random = (arc4random() % 92);
(numbers from 0 to 92)
I want it do disallow the following numbers: 31, 70, 91, 92
Thank you (:
...
Hey, I don't have any code because I don't know how to do this. I'm looking to use jQuery / javascript to randomly append the CSS class "active" to one list item within a an unordered list id'd as ul#sliding_panels.
...
I have a command which spouts a number of lines to stdout:
$ listall
foo
bar
baz
How do I extract a random entry from this, in a one-liner (preferably without awk) so I can just use it in a pipe:
$ listall | pickrandom | sed ... | curl ...
Thanks!
...
All right, so basically all I want is for a bunch of words that I input into a string(would I use one?) and then a random one would be outputted in a TextBox. So,
I'd have a list of words (let's say 100 words) and then I'd make it randomly put out 1 of those 100 words in a TextBox.
Is this possible?
Thanks!
...
I need to generate three lines of text (essentially jibberish) that are each 60 characters long, including a hard return at the end of each line. The lines are generated from a dictionary of words of various lengths (typically 1-8 characters). No word may be used more than once, and words must be separated by spaces. I think this is esse...
I'm customizing a Google Search appliance, which uses XSLT to present results to the user. Our design calls for one of several images to be included randomly on the results page. Is there a way to use randomness in XSLT? (Pseudo-randomness is just fine for this application.)
Calling random templates would be fine, as would just being ab...
I dont get. If it has a fixed length, choosing the lags and the mod over and over again will give the same number, no?
...
I want to get some random records from db. There is two solution for this :
1- Using TABLESAMPLE for getting data from db directly.
2- Write a method In my application for doing this. In this method we generate multiple random number and get data like this :
select * from db where ID = @RandomNumber
if this ID does not exist, I pass...
This is my scenario.
I have a pool of frequencies and my BaseStation needs to select one of them. The critical section for a BaseStation is the phase when it goes into frequency selection. Once it selects frequencies, control returns back to the main BaseStation class and it resumes its request generation. At the same time, i.e. as soon...
Hi there,
I'm pulling my hair out with this and I thought I'd see if the greater Java experience of others might be able to shed some light on the problem. There is a large amount of program code I have written, which is itself within a larger project so I can't simply post it. However, I will outline the problem...
The issue:
My code ...
i know of using the
ORDER BY NEWID()
feature when running a regular sql command. I'm wanting to do the same thing, but via linq2sql.
I'd prefer not to select the whole range, add in a random number via rnd.Next(), and then sort by that...
...
I use this code to generate a random number.
Random R = new Random(0);
int Rand = R.Next(7);
but i get the same random number in each run of program.
...
Does anyone have any ideas about how I could go about randomising an list each time the page is refreshed?
A jQuery solution would be perfect as I'm already using it.
Any advice appreciated!
...
I have seven words in the array:
string[7] = {x,x,x,x,x,x,x};
the x is generated from another array:
string[4]={a,b,c,d};
that means each x can be either a or b or c or d. It is randomly generated. this could be an example:
string[7]= {a,a,d,a,a,c,a}
my question is how can I check if there are five x which has the same value?...