Create a random string or number in Qt4
Is there any function or something like that by which I can create totally random strings or numbers? ...
Is there any function or something like that by which I can create totally random strings or numbers? ...
I'm trying to just make an activity that simply loads a random image when it's loaded. It compiles fine and loads fine. But simply doesn't work. Any ideas what i'm doing wrong? It's making my eyes bleed. ------------Here my RandomImage Class -------------------------------------- package com.package.name; import java.util.Random; im...
How would one go about choosing a random element from a tree? Is it necessary to know the depth/size of the tree beforehand? ...
I want to develop an app that gives a random quote every time you change the page. And I want to put like 1000 quotes in the database. How is the best way I can get a Random Quote? arc4random? ...
i have made a function which works just fine with 32-bit dates (acceptable with strtotime), but that is not scalable. i need to randomly generate peoples dates of birth, so i must use DateTime (and only <=5.2.13, to make it even more difficult) functions to generate them. here is what i had: public static function randomDate($start_dat...
What i'm trying to do is just simply have the button load an image at random. However, the button doesn't seem to be working. When i first load the activity there it works fine and there is a random image....But when i press the button it's not loading another like i need it to. Any idea what i have wrong here? It looks fine to me :/ ...
I'm not sure what's wrong here, all i want to do is randomly grab an item from my array. Which is just like a random sentence. Then generate another once the button is pressed. All my code looks good to me but it's causing a crash when i hit the button. any ideas? package com.my.package; import java.util.Random; import android.app.Ac...
Ok, I've just picked up a hardware RNG and it contains some simple functions as below, GetRandomBytes(UInt Length,out object Array) GetRandomDoubles(UInt Length,out object Array) The functions seem to explain themselves pretty well, how would one use these functions effectivly to generate a number between a certain range? More info f...
I have some random string with unknown content, what is known is that the content is alphanumeric and in lower case. I am looking for a simple method to upper case a random number of the alpha characters in that string. The higher the randomness the better. I can think of a few ways to do this, but none of them seem very optimal. alri...
Hi guys! I'm working with an API that wants me to generate opaque "reference IDs" for transactions with their API, in other words, unique references that users can't guess or infer in any way. (is 'infer' proper english?) This is what I've hacked together currently: randomRef = randint(0, 99999999999999) while Transaction.objects.filt...
This code #include <stdio.h> #include <stdlib.h> #include <time.h> int main () { printf ("First number: %d\n", rand() % 100); srand ( time(NULL) ); printf ("Random number: %d\n", rand() % 100); srand ( 1 ); printf ("Again the first number: %d\n", rand() %100); return 0; } has the following output: First numb...
This is more of a maths/general programming question, but I am programming with PHP is that makes a difference. I think the easiest way to explain is with an example. If the range is between 1 and 10. I want to generate a number that is between 1 an 10 but is more likely lower than high. The only way I can think is generate an array ...
I am considering this random string generator in perl: sub generate_random_string { my $length = 12; my @chars = qw/2 3 4 5 6 7 8 9 A B C D E F G H J K M N P Q R S T U V W X Y Z/; my $str = ''; $str .= $chars[int rand @chars] for 1..$length; return $str; } How many unique strings will this generate? If I extend th...
I faced a following problem: generate N unique alphanumeric strings from a restricted alphabet. Here's my solution in C#: string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; Random generator = new Random(); const int ToGenerate = 10000; const int CharactersCount = 4; ArrayList generatedStrings = new ArrayList(); while( generatedSt...
Let's say that I have a list of data: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} where n = 10 elements I'd like to randomly choose k elements of this set to form a sublist, say k = 5. In that case, I could end up with a sublist that looks like {9, 3, 5, 2, 7} I could accomplish this by: Randomly determining an offset within the list, between 0 a...
Using RAND() in MySQL to get a single random row out of a huge table is very slow: SELECT quote FROM quotes ORDER BY RAND() LIMIT 1 Here is an article about this issue and why this is the case. Their solution is to use two queries: SELECT COUNT(*) AS cnt FROM quotes - Use result to generate a number between 0 and COUNT(*) SELECT q...
This is for the purpose of having a nice short URL which refers to an md5 hash in a database. I would like to convert something like this: a7d2cd9e0e09bebb6a520af48205ced1 into something like this: hW9lM5f27 Those both contain about the same amount of information. The method doesn't have to be direct and reversible but that w...
Possible Duplicate: Java: generating random number in a range I want to generate a random int in a logical range. So, say for example, I'm writing a program to "roll" a dice with a specified number of sides. public int rollDice() { Random generator = new Random(); return generator.nextInt(sides); } Now the problem ...
I have a list of X items. I want the first 10 to be randomized. Then, the 2nd 10 items to be randomized. Then the 3rd. What's the most efficient way to do this? ...
How do I make an HTML button’s onclick event trigger one of two different functions at random? I’m using PHP on the server, and jQuery on the client. Using this code when i click the button image nothing happens... function a(){ alert('A got called!'); } function b(){ alert('B got called!'); } $('#button').bind('click...