Hi,
I've been messing with Haskell few days and stumbled into a problem.
I need a method that returns a random list of integers ( Rand [[Int]] ).
So, I defined a type: type Rand a = StdGen -> (a, StdGen).
I was able to produce Rand IO Integer and Rand [IO Integer] ( (returnR lst) :: StdGen -> ([IO Integer], StdGen) ) somehow. Any tip...
Hi all,
I'm working on a simple tutorial, and I'd like to randomly generate the positions of the red and green boxes in the accompanying images anywhere inside the dark gray area, but not in the white area. Are there any particularly elegant algorithms to do this? There are some hackish ideas I have that are really simple (continue to...
I'm in need of getting a random record from a table via ActiveRecord. I've followed the example from Jamis Buck from 2006.
However, I've also come across another way via a Google search (can't attribute with a link due to new user restrictions):
rand_id = rand(Model.count)
rand_record = Model.first(:conditions => [ "id >= ?", rand_id...
Hi,
How can I pick a random place from anywhere in the world (but not in sea obviously) using some Service like Yahoo Geo, YQL, Google maps or something like that??
Thanks!
...
Hi there. I've build a random string generator but I'm having a problem whereby if I call the function multiple times say in a Page_Load method, the function returns the same string twice.
here's the code
Public Class CustomStrings
''' <summary>'
''' Generates a Random String'
''' </summary>'
''' <param name="n">number...
I'm trying to generate a uuid for a filename, and I'm also using the multiprocessing module. Unpleasantly, all of my uuids end up exactly the same. Here is a small example:
import multiprocessing
import uuid
def get_uuid( a ):
## Doesn't help to cycle through a bunch.
#for i in xrange(10): uuid.uuid4()
## Doesn't help to...
So far i have this, which prints out every word in my list, but i am trying to print only one word at random. Any suggestions?
def main():
# open a file
wordsf = open('words.txt', 'r')
word=random.choice('wordsf')
words_count=0
for line in wordsf:
word= line.rstrip('\n')
print(word)
words_coun...
Hey everyone,
I'm having a strange problem here, and I can't manage to find a good explanation to it, so I thought of asking you guys :
Consider the following method :
int MathUtility::randomize(int Min, int Max)
{
qsrand(QTime::currentTime().msec());
if (Min > Max)
{
int Temp = Min;
Min = Max;
Max...
Theoretically does hashing a unique value yield a unique value?
Let's say I have a DB table with 2 columns: id and code. id is an auto-incrementing int and code is a varchar. If I do ...
$code = sha1($id);
... and then store $code into the same row as $id. Will my code column be unique as well?
What about if I append the current ...
Hi everyone,
In Linux. There is an srand() function, where you supply a seed and it will guarantee the same sequence of pseudorandom numbers in subsequent calls to the random() function afterwards.
Lets say, I want to store this pseudo random sequence by remembering this seed value.
Furthermore, let's say I want the 100 thousandth n...
There's a similar question, I know, but it confused me, so I thought it easier to ask in my way.
So I have an array of values, positive and negative. The higher they are, the more probability they have of being chosen.
I'm having trouble actually figuring out how to assign the probabilities and then randomly choose one. I'm guessing the...
I'm trying to create a fairly simple piece of JavaScript that displays a random image from an array each time the page loads. I need to figure out a way to get this running without adding code to the body tag. Is there a way to accomplish this without, say, an onload funtion placed in the body tag?
Here's what I have that relies on th...
So... I have never had a need to do a random SELECT on a MySQL DB until this project I'm working on. After researching it seems the general populous says that using RAND() is a bad idea. I found an article that explains how to do another type of random select. Basically, if I want to select 5 random elements, I should do the following (I...
I'm by no means a cryptography expert, I have been reading a few questions around Stack Overflow and on Wikipedia but nothing is really 'clear cut' in terms of defining an IV and it's usage.
Points I have discovered:
An IV is pre-pended to a plaintext message in order to strengthen the encryption
The IV is truely random
Each message h...
First, I am an engineer, not a computer scientist, so I apologize in advance for any misuse of nomenclature and general ignorance of CS background.
Here is the motivational background for my question:
I am contemplating writing a genetic algorithm optimizer to aid in designing a power divider network (also called a beam forming network,...
Hello,
I would like to generate a random filename in unix shell (say tcshell). The filename should consist of random 32 hex letters, e.g.:
c7fdfc8f409c548a10a0a89a791417c5
(to which I will add whatever is neccesary). The point is being able to do it only in shell without resorting to a program.
...
I'd like to generate completely random piece of html source, possibly from a grammar. I want to do this in python but I'm not sure how to proceed -- is there a library that takes a grammar and just randomly follows its rules, printing the path?
Ideas?
...
I need a random query, but I don't know what's the best way to do this in the view.
...
Edit: to clarify, the problem is with the second algorithm.
I have a bit of C++ code that samples cards from a 52 card deck, which works just fine:
void sample_allcards(int table[5], int holes[], int players) {
int temp[5 + 2 * players];
bool try_again;
int c, n, i;
for (i = 0; i < 5 + 2 * players; i++) {
try_a...
I've literally looked everywhere on the net and found very little
clarification on how to do this.
Pretty much, I have 8 sound files laid out in an array.xml file and I
need to play a randomly chosen file ONCE per or onClick or onShake.
First off, what technique should I use to achieve this? ARRAY->RANDOM-
STRING->PLAY? RANDOM...