Tagged Questions

This tag is for questions pertaining to random numbers, whether pseudo random or truly random.

learn more… | top users | synonyms

1
vote
0answers
13 views

integer constant is too large for “long” type [migrated]

I am creating random integers with the following algorithm: int random; int i; for (i = 0; i < RANDOM_COUNT; i++) { random = (((int) rand() << 0) & 0x0000FFFFd) | ...
7
votes
1answer
78 views

Creating random maze in Go

/* Create a random maze */ package main import ( "fmt" "math/rand" "time" ) const ( mazewidth = 15 mazeheight = 15 ) type room struct { x, y int } func (r room) ...
4
votes
2answers
121 views

Could you review whether or not my code is already the most efficient and effective in C#?

I want to randomly permutate a finite list in the most effective and efficient way in C#. My attempt is as follows. /*===================================* * Compile it to produce Shuffle.exe * * ...
0
votes
4answers
65 views

Random “month & day” with JS ( jQuery )

setInterval(function() { var days_array = [31,29,31,30,31,30,31,31,30,31,30,31]; var m = randNum(12); var m_limit = days_array[m-1]; var d = randNum(m_limit); $("code").html("day = ...
2
votes
1answer
121 views

Objective-C CF Random Name Generator

Based on a python name generator grammar I found here I've decided to write my own in objective-C. The idea is I can load the grammar from a plist file and generate random names from it. I'm looking ...
2
votes
0answers
70 views

Would someone please critique this mips program?

I've done some programming in the past, but I'm new to MIPS, which I'm trying to learn on my own. This program lists the first five perfect numbers. It uses the Lucas-Lehmer and Miller-Rabin primality ...
2
votes
3answers
143 views

Need advice regarding Style and Flow in C++ (Simple randomization program)

I come here humbly asking for advice from those with more experience than I. I believe this is a novice question but I hope it is useful to others. I'm a few months into learning C++ programming and I ...
1
vote
2answers
71 views

Haskell: rndFile and [Char] vs IO String error

import System.Environment (getArgs) import Random main = do args <- getArgs let len = length args let n = if len < 1 then 10000 else read (args !! 0) :: Int let fileName = if len < ...
1
vote
3answers
393 views

Randomize a jQuery object list

Well this was a simplest code competition at my work. I tried a couple things, they accepted but none of them is I wanted. Because both are always giving same result. I tried to randomize like this ...
1
vote
1answer
113 views

randrename — insert random nums in filenames

I have an old mp3 player with a broken screen. Consequently, it's a real pain to turn shuffle mode on and off; however, there are a few albums that I wanted to mix together and have shuffled for when ...
3
votes
2answers
273 views

Algorithm to convert random bytes to integers

I'm trying to convert from random bytes to integers within a range. Basically converting as such: byte[] GetRandomBytes(int count) -> int NextInteger(int min, int max) Another way to think about ...
2
votes
2answers
396 views

Random string + encrypt/decrypt

Are there any security flaws in what I plan to do? I need to store in my DB the following: a random string to act as a salt for encrypting a password the encrypted password that used the salt in #1 ...
9
votes
8answers
3k views

Random string generation

I'm using this C# function, to generate random coupons for a system. How can I improve it? public static string GenerateCoupon(int length) { string result = string.Empty; Random random = new ...
2
votes
1answer
315 views

JavaScript: Weighted Random Generator

I'm attempting to create a function that will give me a "fish" at random, though a bias random depending on the weight value for the "fish". var FISH = { "level1": [ //["name", xp, ...
1
vote
2answers
269 views

Random Topic Generator

I've written a python module that randomly generates a list of ideas that can be used as the premises for furthur research. For instance, it would be useful in situations where a new thesis topic is ...

1 2
15 30 50 per page