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

learn more… | top users | synonyms

4
votes
4answers
78 views

Random 6 to 10 digits number

I am generating a random numerical 6-10 digit password. I need some important reviews of yours. Is it OK or are there some needed modifications? ...
3
votes
1answer
17 views

Implementing `randoms`

Learn You a Haskell presents the randoms function. I implemented it as follows: ...
8
votes
1answer
57 views

Random Coin Toss in Haskell

Learn You a Haskell gives an exercise to implement the following function: ...
2
votes
1answer
30 views

Ensuring client IDs are unique

I'm writing a node.js application that involves handling clients based on their ID without any real way of confirming that the ID a client says it has is its actual ID. That is, it's possible for a ...
8
votes
4answers
464 views

std::vector composition with self populating super-powers

I have written a deliberately pretty simple class that wraps a std::vector to basically make it capable of self-populate itself with random generated numbers, ...
1
vote
1answer
26 views

v2 - Adding a duplicate entry randomly into a list in haskell using random monad

Next version of Adding a duplicate entry randomly into a list in haskell using random monad I wrote this trying to set up a Haskell testcase. The aim is to take a list and add a single duplicate from ...
4
votes
1answer
18 views

Adding a duplicate entry randomly into a list in haskell using random monad

There's a new version of this as v2 - Adding a duplicate entry randomly into a list in haskell using random monad I wrote this trying to set up a Haskell testcase. The aim is to take a list and add ...
2
votes
2answers
42 views

Simple evolutionary string matching

This is based on a very similar question I asked, found here. The intent of this program is to start with a set number of random strings of zeros and ones, and eventually evolve them to find one ...
5
votes
2answers
77 views

Change random list of numbers into all 5's using simple evolution simulation

This is supposed to be an evolutionary algorithmic program, and I'm not sure if it does what it's supposed to do. It is supposed to take a random list of numbers (containing at least one 5), and over ...
7
votes
2answers
508 views

How random is this password-generating algorithm?

This code's sole purpose is to create a very random password, using letters and numbers. I think that it fulfills its purpose, but I wonder, could it be done better? I'm not talking about ...
5
votes
2answers
93 views

Python script for generating random C code

I'm writing a Python script to randomly generate C functions. This is my first time using classes in Python and I'm basically doing my best to pretend I'm using Java. I'm looking for a review of my ...
1
vote
1answer
31 views

Seeding a PRNG - Custom Setter

I have a PRNG-Class called Generator. Now, after creating a new instance of it: var g:Generator = new Generator(); Custom ...
3
votes
2answers
134 views

Generating a random string of characters and symbols

After coding this, I was wondering if there are any ways in which I can improve upon it. It generates a random string of characters and symbols the same length as what is entered by the user. It uses ...
3
votes
1answer
78 views
7
votes
4answers
573 views

Read from a file and pick a random line

I've been learning Java lately and had some great feedback from the previous threads (hangman and guess a number games). I was challenged by a user to try to get this code done, so I'm posting it here ...
2
votes
1answer
72 views

Optimized solution for a rolling dice code puzzle

I was asked to provide the solution of this rolling dice problem in an interview. When I showed him my solution, he said that there is another way to find the solution. I am looking for answer in PHP ...
6
votes
3answers
204 views

Initial starting player

I'm making a game battle system, where there are 2 players. Every player can have multiple units to control, but only one at a time. Every unit has an ...
7
votes
3answers
381 views

Better way to create a string of random characters

I'm generating domains with random names but I'm pretty new to Python. I used the map function because it packages the results into a list which I can then join() ...
4
votes
1answer
99 views

Generating random and secure CSRF tokens

I googled around for secure random number generation and random string generation, combining them with some user data. Is this good or am I totally off-base? I don't know much about cryptography but ...
3
votes
2answers
134 views

Random Name Generator

I've had ideas for something like this in the past but I've finally implemented one and I could definitely use some code review for it. Obviously the quality of the names generated will depend on ...
4
votes
1answer
77 views

Random quote generator

I just began learning programming and I'm learning Objective-C. I'm taking an online course and in that course we were doing a magic crystal ball app. Then I decided to use what I learned and make my ...
9
votes
2answers
515 views

Dice-rolling simulator

I know there is a better way to store data. What is the most concise way to simplify this script? ...
3
votes
0answers
37 views

Is there a simpler or more efficient way to display random “ads” from an XML document?

I have an xml document that contains "ads" and includes information about the department name, image name, link to URL, and alt text. I have a ...
9
votes
2answers
519 views

Card shuffling with Fisher-Yates method

The code below takes a specified number of card decks, and shuffles them according to the Fisher-Yates method. Does this implementation have any bias? ...
6
votes
3answers
835 views

Random number guessing game

I'm working on a random number guessing game. I'm done with the code and it's working, but there is a part that I want to make better. I declared an instance of a ...
5
votes
3answers
335 views
9
votes
1answer
88 views

Produce bitcoin private key from 31 playing cards

I've written some Python code to generate a random hexadecimal string using 31 playing cards drawn without replacement (so no card appears more than once). This is sufficient to provide more than 160 ...
9
votes
2answers
117 views

Can this secure, random generator be improved?

This random generator uses cryptographically secure numbers/chars instead of Math.random(). The Javascript code with jQuery works well but I affect clean code ;) It ...
4
votes
1answer
234 views

Dice game in Python

I was wondering if this script in Python could be shortened? ...
19
votes
1answer
377 views

Random clothes generator

UPDATED, original code can be found here. Also, my main goal is to not only improve the style of my coding, but also to improve the logic in finding random combinations. As of now it seems way too ...
2
votes
1answer
131 views

Dice notation roller in JavaScript

I have the following function, intended to take standard dice notation (XdY+Z) and return a (sort of) random number based on the input. Are there any bugs/bad ideas/optimizable sections I am missing? ...
14
votes
5answers
3k views
1
vote
1answer
142 views

Reservoir sampling

Reservoir sampling implementation. Reservoir sampling is a family of randomized algorithms for randomly choosing a sample of k items from a list S containing n items, where n is either a very large or ...
4
votes
3answers
115 views

Weighted probabilistic sampling

Problem description. Returns strings with probability determined by the frequency of each of the strings. eg: if "foo" has weight of 50% and "bar" has weight of another 50% then both foo and bar ...
5
votes
3answers
128 views

Could random unique selection using while cause an infinite loop?

I recently came across code that looked something like this (generates 4 random numbers in an array, this is not the actual code, I just wrote this up now, so it's untested): ...
19
votes
6answers
5k views

Guessing a unique 4 random digits number

I've created a simple game, in which the user needs to guess 4 digits number between 0-9, generated randomly using Random() Each of the 4 digits are different from ...
21
votes
9answers
4k views

Generating Even Random Numbers

I have this class which is used as part of a game. It needs to generate Random Even values, which is done by generating random numbers until the result is even. Is there a better way to do this? ...
6
votes
6answers
1k views

Random number game

I have created a small 'game' which basically asks the user for the row number and column number and then picks a random number and if that number is above 11, out of 15, the user wins. When the user ...
5
votes
2answers
460 views

Generating random numbers

I'm trying to refactor the following code and could use some suggestions. Basically, three functions generating random numbers in different ways are called: ...
6
votes
2answers
260 views

Generating random HTML color grid

This is a Python script that generates a grid of random HTML colors. It works by reading random data from /dev/urandom and then encoding it as a hexadecimal ...
4
votes
2answers
496 views

Roll a die according to the number of sides that the user enters

I have created a program which rolls a die according to the number of sides that the user enters: ...
2
votes
2answers
391 views

rand number generator with limits in ruby

I have an array of 1000 numbers, randomly generated. 10 of those numbers must be between 0-9 (including 0 and 9), and 10 of those numbers must be between 991 and 1000 (including 991 and 1000). This is ...
4
votes
1answer
260 views

Function to produce unique random numbers

I've been learning Haskell for a few weeks after coming from a C# background. I've written a function to return a number of unique Ints from a specified range: ...
6
votes
4answers
175 views

Valid and safe use of SpinLock in Singleton?

Is this a valid and safe use of .NET's System.Threading.SpinLock? Why am I doing this? Random's public methods are not ...
-3
votes
1answer
189 views

trivia questions with 10 random questions from 24 but without repeating the questions

I have a big problem with my project 4-5, I'm trying to have random 10 questions of 25 and not repeating the same questions but I really don't know how to do it. Do you have any hints for me? this is ...
8
votes
2answers
488 views

Guess a random number between a selected interval

My project for my class is to create a Java-based game where the user must enter a number between 1-20 and a number between 250 and 300. The computer randomly chooses a number between those 2 numbers. ...
12
votes
5answers
629 views

Optimize random number generator

I have a method that generates a 10 digit random number where each digit occurs only once. eg: 0123456789 3645720918 Is there any way this method could be ...
2
votes
3answers
303 views

Modeling a pair of dice using composition in C++. Am I doing it right?

I've written a program all by myself, but I just want to make sure I did it right and if anybody has any suggestions on improving it in any way. Define and implement the Die class depicted by the ...
2
votes
1answer
481 views

How to improve efficiency of my roulette game?

Well, I'm kind of new to C++ and was just wondering if anyone could give me tips on how I could make my code more efficient (I added some comments to the code to help you understand it better). Is it ...