Generate random number
How to generate a random number in bash? ...
How to generate a random number in bash? ...
I searched the site but did not find exactly what I was looking for... I wanted to generate a discrete random number from normal distribution. For example, if I have a range from a minimum of 4 and a maximum of 10 and an average of 7. What code or function call ( Objective C preferred ) would I need to return a number in that range. ...
I want to generate unique random number sequence in QT, Using QDateTime::currentDateTime().toTime_t() as seed value, will qrand() generate unique random numbers? ...
srand(time(null)); printf("%d", rand()); Gives a high-range random number (0-32000ish), but I only need about 0-63 or 0-127, though I'm not sure how to go about it. Any help? ...
I need to generate a unique ID based on a random value. ...
I'd like to have a random number like this:(in C#) Random r = new Random(); r.next (0,10) BUT it's important to the random number be more near 8,(or it be usually big), I mean if we use a for: for (int i =0; i<...;i++) { write: r.next (0,10) } the result be like this; 8 7 6 9 1 0 5 3 2 2 3 8 9 7 7 6 2 3 8 8 9 7 2 8 2 8 4 3 ...
If you don't know, python turtle is an application for helping people learn python. You are given a python interpreter and an onscreen turtle that you can pass directions to using python. go(10) will cause the turtle to move 10 pixels turn(10) will cause it to turn 10 degrees clockwise now look at this code: import random while(1)...
I know how to select one random item from an array, but how about ten random items from an array of, say, twenty items? (In PHP.) What makes it a little more complicated is that each item actually has two parts: a filename, and a description. Basically, it's for a webpage that will display ten random images each time you reload. The act...
Hi all! I'd like to optimize my queries so i look into mysql-slow.log. Most of my slow queries contains ORDER BY RAND(). I cannot find a real solution to resolve this problem. Theres is a possible solution at MySQLPerformanceBlog but i don't think this is enough. On poorly optimized (or frequently updated, user managed) tables it doesn...
Hi, Assume I have an array/vector of numbers like 1,3,7,9 then I need to guess a number from this list randomly. Using Random class in Java it seems like not possible to do this. Could anyone kindly help me to tell a way to do this kind of thing. I have to change the list of numbers used to generate random number. I am trying to impleme...
cat /dev/urandom is always a fun way to create scrolling characters on your display but in that output, there is too many non character output. now i was thinking, is there an easy way to encode on the commandline it in such way that all of itś output are readable characters, base64 or uuencode for example. note that i prefer solutions...
I currently have a Python set of n size where n >= 0. Is there a quick 1 or 2 lines Python solution to do it? For example, the set will look like: fruits = set(['apple', 'orange', 'watermelon', 'grape']) The goal is to pick 2 random items from the above and it's possible that the above set can contain 0, 1 or more items. The only w...
I'm trying to make the Perlin noise algorithm described at http://freespace.virgin.net/hugo.elias/models/m_perlin.htm using Lua. However, it doesn't work properly since Lua doesn't support bitwise operators, which are necessary for the pseudorandom number function on that page. I tried messing around with randomseed() but everything I co...
As the title says, what's the most efficient way to get a random selection of x DataRows from a DataTable. Would it be to iteratively do something like the following until I have as many as I need? protected DataRow SelectRandomRow(DataTable dataTable, Random randomSelector) { return dataTable.Rows[randomSelector.Next(dataTable.Row...
If I had a text file with the following: Today (is|will be) a (great|good|nice) day. Is there a simple way I can generate a random output like: Today is a great day. Today will be a nice day. Using Perl or UNIX utils? ...
I'm working on a program to solve the n queens problem (the problem of putting n chess queens on an n x n chessboard such that none of them is able to capture any other using the standard chess queen's moves). I am using a heuristic algorithm, and it starts by placing one queen in each row and picking a column randomly out of the column...
I have a holder div on the page where I want to load small images in on random position as a collage with 10px padding on each. How can I make sure that images never overlap each other or holder div? Is there a plugin or function that I could use? My code so far: <script src="jquery-1.3.2.min.js" type="text/javascript"></script> <sc...
This question on getting random values from a finite set got me thinking... It's fairly common for people to want to retrieve X unique values from a set of Y values. For example, I may want to deal a hand from a deck of cards. I want 5 cards, and I want them to all be unique. Now, I can do this naively, by picking a random card 5 t...
Given a java.util.Collection what is the easiest way to create an endless java.util.Iterator which returns those elements such that they show up according to a given distribution (org.apache.commons.math.distribution)? ...
Why is it this sometimes returns 2? function pickServer(){ $varr = rand(1,4); if($varr==2){ pickServer(); } return $varr; } ...