basically i have a function that generates random alphabets .i have done this using the rand() function to generate numbers and them converted them to their corresponding ascii equivalents.
but i want the vowels to be generated in higher numbers as compared to other alphabets.i.e
if have generated say 10 alphabets then there should be li...
Am I looking too far to see something as simple as pick a number: 0 or 1?
Random rand = new Random();
if (rand.NextDouble() == 0)
{
lnkEvents.CssClass = "selected";
}
else
{
lnkNews.CssClass = "selected";
}
...
I need to be able to pull a random value out of my array, let's assume i have array with 100 values, how can i pull randomly 5 values out of this array?
...
I need to efficently insert a 5 character RANDOM string into a database while also ensuring that it is UNIQUE. Generating the random string is not the problem, but currently what I am doing is generating the string and then checking the DB if it exists already... if it does, I start over.
Is there a more efficient way to do this proces...
I have a need to generate a random SecretKey, in Java, which I will be able to regenerate at some future point. The idea is that this key is unique to the machine on which it is created and isn't stored anywhere. I'm attempting something like this:
KeyGenerator keyGen = KeyGenerator.getInstance("DESede");
String hostname = InetAddress....
thelist = ['a','b','c','d']
What's the best way to scramble them in Python?
...
How can I generate a random whole number between two specified variables in Javascript, e.g. x=4 and y=8 would output any of 4,5,6,7,8?
...
What's the best way to do this?
I need to generate a 5 digit length string where all the characters are numeric. However, I need to be able to do this 'x' amount of times (user variable) and store this random strings in a database. Furthermore, I can't generate the same string twice. Old strings will be removed after 6 months.
Pseud...
This is my list:
biglist = [ {'title':'U2','link':'u2.com'}, {'title':'beatles','link':'beatles.com'} ]
print random.shuffle(biglist)
that doesn't work! It returns none.
...
I need to generate random strings in vb.net, which must consist of (randomly chosen) letters A-Z (must be capitalized) and with random numbers interspersed. It needs to be able to generate them with a set length as well.
Thanks for the help, this is driving me crazy!
...
Hey guys, I'm trying to select random data from the database in Ruby on Rails. Unfortunately, sqlite and mysql use different names for the "random" function. Mysql uses rand(), sqlite use random(). I've been pretty happy using sqlite in my development environments so far, and I don't want to give it up for just this.
So I have a soluti...
Hello everyone!
I need to generate two numbers that are NOT equal in PHP.
I know that I use $random1 = (rand()%9); to generate random a number between 0-9. I need to add something to this I guess.
Thanks!
...
Hi
I have a DIV background which I want to change randomly on page load from a selection of 3 PNGs.
I searched around and found this code:
$(document).ready(function() {
var randomImages = ['img-restaurante-1','img-restaurante-2','img-restaurante-3'];
var rndNum = Math.floor(Math.random() * randomImages.length);
$("div.lacarta")...
My program draw 10 polygon triangles in random sizes (width and height). The coordinate (points) of the polygon were generated using Random generator = new Random(). Since the points of the triangle and the width and height were randomly generated, how can I control the number of sizes drawn? e.g. there are 10 polygon in total, but I wan...
Consider code like this (Python):
import random
for i in [1, 2, 3, 4]:
random.seed(i)
randNumbers = [random.rand() for i in range(100)] # initialize a list with 100 random numbers
doStuff(randNumbers)
I want to make sure that randNumbers differ significantly from one call to another. Do I need to make sure the seed number...
I'm trying to get a randomly picked background image (from a selection of 4 images) to appear as the background image for a asp.net panel.
The problem I have is that the code works when stepping through the code in debug mode. Once you run the code on the website without debugging, all the images are the same. Its almost as if the rando...
I have a project in the works, and I'll need to associate a passcode with an item.
The password should be completely non sequential or easily guessable, yet simple to remember.
I thought about doing something like this.
string rand = System.Guid.NewGuid().ToString();
rand.Substring(0,3);
Return the first 4 digits of a GUID.
I was wo...
I saw this code in a comment for the article "Never-ending Shuffled Sequence". I understand the basic premise, but I don't know how it works. The biggest explanation I need is of the first two lines of the while loop.
(Because it is written in MATLAB I can only guess at how this code functions.)
probabilities = [1 1 1 1 1 1];
unrandomn...
I'm attempting to create a simple dice roller, and I want it to create a random number between 1 and the number of sides the dice has. However, randint will not accept a variable. Is there a way to do what I'm trying to do?
code below:
import random
a=0
final=0
working=0
sides = input("How many dice do you want to roll?")
while a<=si...
Hello,
I am looking for a python library that would allow me to compute stochastic calculus stuff, like the (conditional) expectation of a random process I would define the diffusion. I had a look a at simpy (simpy.sourceforge.net), but it does not seem to cover my needs.
This is for quick prototyping and experimentation.
In java, I u...