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

learn more… | top users | synonyms

1
vote
1answer
24 views

Password validator using regular expressions

I wanted to learn some regex, but learning regex is super boring so I decided to write a password validator that will validate a password with regular expressions. How it works: You enter a ...
3
votes
1answer
30 views

Quicksort using uniform_int_distribution to select the pivot

I have not used C++ for a while. Could you please tell me if my usage of the <random> module is correct? I am not sure if I need to be creating a new instance ...
2
votes
3answers
124 views

Generic Roulette class

I'm looking for some improvements for my generic Roulette class. More information on how the class works is better described, here: https://en.m.wikipedia.org/wiki/Fitness_proportionate_selection <...
-1
votes
0answers
21 views

Random password generator for my iOS app using Objective-C [on hold]

I am trying to make a random password generator for my ios app using Objective-C and I was wondering if i was doing it correctly. I want to run this in Xcode. ...
0
votes
1answer
98 views

Random number generator in C#

I don't know if it is any good. I've never done this, thus, I noticed it is kinda slow. Can you suggest improvements? I may use it in actual software in the future. ...
0
votes
1answer
52 views

Python random number generator between 1 and 9

I created this code and it works fine, but I think it's ugly. Could you show me a better way to create a list of three different random numbers from 1 to 9? ...
10
votes
7answers
1k views

Generate random binary arrays

I am fairly new to C++ programming and I, so far, love it. I just have been trying to make sure what I am doing is fast, unique, readable, and efficient. Is there anyway I can improve this code, or is ...
1
vote
1answer
36 views

Log collisions in generating unique random strings

I've created a small class to generate unique random strings. It works fine. I also want to log the collisions of the generated strings. I check if the generated string is in the array for uniquness: ...
2
votes
1answer
43 views

Output stream-based pseudorandom number generator

I finished an output stream-based pseudorandom number generator, that works based on the current time and output data. Here is the header's code (entrostream.hpp): ...
3
votes
1answer
42 views

Find the largest area polygon built from a given list of vertices

This is a code that gets a list of polygon vertices, non ordered, and finds the order in which they should be arranged in order to create the polygon with the largest area. There are two key elements ...
3
votes
1answer
40 views

A Blum Blum Shub pseudorandom RNG implementation in JavaScript

I made a Blum Blum Shub pseudorandom number generator implementation in JavaScript. Blum Blum Shub (B.B.S.) is a pseudorandom number generator proposed in 1986 by Lenore Blum, Manuel Blum and ...
11
votes
7answers
2k views

French animal generator

I'm learning Python. I'm making a random animal generator, from 5 txt files. Each file is a list of words for respectively the specie of the animal, an adjective, an origin, and a bodypart with a ...
11
votes
1answer
912 views

Solving for Bananas

This code creates a problem for the user to solve (very simple problem) it will then check if the user has got it right and will say so. ...
5
votes
0answers
67 views

ASCII dungeon generator [closed]

I've written a simple ASCII dungeon generator. What are your thoughts on the code and coding style? Algorithm: Choose random point on "canvas" (two-dimensional array of chars with user defined size)...
2
votes
2answers
41 views

Random distribution in Ruby

Below is a Ruby implementation of a random statistical event, based on a hash with the actual observed counts of outcomes. I'd be interested in feedback in particular on what techniques I might use ...
6
votes
2answers
140 views

Python Lottery Game

How could I improve this code or make it more efficient? ...
4
votes
2answers
59 views

Cython: Weighted Random Choice

I have a Cython function the takes a list of weights/probabilities (double) and returns a random index into the list. For example ...
4
votes
1answer
73 views

Comparing three data structures for dealing with probability distributions in Java

Introduction Suppose you are given three elements \$a, b, c\$ with respective weights \$1, 1, 3\$. Now, a probability distribution data structures will return upon request \$a\$ with probability 20%, ...
9
votes
4answers
1k views

Create a list of random numbers with sum = n

I want to create a list of random integers in the range [0, 9], that sums up to 100 in Excel, using VBA. The list should be printed in a single column. The routine I've written is as follows: ...
1
vote
2answers
152 views

Random iteration over an array using divide and conquer

I have created a utility class which allows random iteration over an array. The idea is pretty much a divide and conquer approach. ...
2
votes
1answer
59 views

Galaxy generator

I'm currently working on a galaxy generator, and I was in need of getting the next that a random would use, for continuing the generation without using a blank generation (re-run previous generation). ...
4
votes
1answer
67 views

Virtual Lotto Task

I had the task to write a Lotto simulator. My program works as follows: To start, the user can type in 6 numbers. Then the winning numbers are randomly chosen. The program then shows the winning ...
4
votes
1answer
93 views

C++ template to randomly choose from N elements with uniform distribution

There is a nice algorithm to randomly choose an element from a list in a single pass: Pass through the list keeping the element chosen so far (X) and the number of elements processed (N). When ...
4
votes
1answer
69 views

A little advanced mouse clicker in Bash for Linux

My today's goal was to create a little advanced mouse clicker in Bash for Linux powered by xdotool. This clicker implements 15 pixel random range in which it clicks ...
2
votes
1answer
110 views

csvshuf: a tool to shuffle CSV columns written in Python

Edit: After reading Gareth's answer I have pushed an updated version of the code to github. I needed to shuffle cells from specific columns in several CSV files. One of the requirements was to be ...
2
votes
0answers
33 views

Generate sample of permuted sequences with non-repeating elements

I have a very long sequence of letters (>20000 elements long). I want to permute them so that I have another sequence using the same letters but in a different order but still with the property of no ...
3
votes
2answers
93 views

Assembling edges of a graph

I'm making a neural network that comprises five populations of feature-selective neurons and one population of non-selective neurons. Each neuron in this network receives connections from c * f * ...
5
votes
3answers
94 views

Command line password generator

I built a random password generator in Java which is meant to be run from the command line. It accepts options for: Length Upper case letters Lower case letters Special characters Numbers The ...
-2
votes
3answers
125 views

Generating a very long random string of letters

I was trying to fill a file with about ten million random characters (a-z,A-Z,' '). To my surprise the code is extremely slow. I inserted this print ...
3
votes
2answers
74 views

Simple 'Evolution of Text' app

I'm a complete beginner to Python, and wanted to get some feedback on my first app. I tried to make a clone of the 'evolution of text' app found on the Using Python website. Enter some text, and ...
5
votes
2answers
94 views

Monte Carlo simulation of amoeba population

I wrote a simple Python simulation to answer the "Amoeba" population question posed here: A population of amoebas starts with 1. After 1 period that amoeba can divide into 1, 2, 3, or 0 (it can ...
1
vote
0answers
22 views

Password Entropy in Lazarus (Delphi-like)

My today's goal was to create a function, which would evaluate the entropy of a given string password. It's mostly about how random the password is. This little code is based on the C# code from Jeff ...
1
vote
2answers
100 views

Select random row using PDO

What do you think of this way to generate a random number from the total rows in a table? I would like to create a page that random.php precisely generates a random ID and shows it. ...
2
votes
0answers
56 views

PHP Lottery Simulator

I have a lottery simulator on my website that simulates you playing the lottery every week until your death and tells you how much you would have won or lost. It can take a custom number of balls and ...
3
votes
1answer
78 views

Sleeping barber problem in Erlang

I'm learning Erlang. It's my first time with a non-imperative programming language. I've written a code and I want some thoughts about it: Is my logic easy to understand? Is my code idiomatic? Is ...
2
votes
1answer
145 views

C# console roulette game

I made a C# console roulette game. Check it out and give opinions on how to improve or ideas for some other features? It's not finished yet so it has lots of room for improvement. I am very new so ...
3
votes
2answers
72 views

Cryptographically Secure Pin Generator using RNGCryptoServiceProvider

In my system I have a SMS authentication. Users input their user-id and get sent an SMS with a 5 digit pin number they input in a website to log in. The pin has a lifetime of a few minutes. This pin ...
-1
votes
2answers
73 views

Maths quiz with difficulty levels and a score database

How can I make the saving to the dictionaries more efficient as well as making my overall code more efficient? ...
-2
votes
1answer
148 views

On Finding Coin Jams

The problem can be found here and is essentially asking us to generate J many numbers containing N many digits, where these digits have to be either 0 or 1. The catch is that the these numbers that we ...
6
votes
1answer
45 views

Randomly selecting an adjective and noun, combining them into a message

This is my first Rust program. I have previously written a lot of Python, and some C. I would like some advice on whether I am doing things idiomatically, and any improvements I could make! I also ...
5
votes
2answers
74 views

Determine playing card

I would like a code review on the coding I did for my assignment. The reason I have asked here is because my lecturer has no intention of going through (Don't ask me why, I asked before and he said no....
1
vote
3answers
114 views

Distributing cards to players in C++

I have written this program to deal 7 cards to one player. ...
3
votes
1answer
86 views

Generate 6 random numbers for lottery in PHP

This program generates 6 random numbers between 0 and 45 and the numbers cannot be reapeated. Can this code be improved? ...
3
votes
6answers
523 views

Creating an array of random numbers with no duplicates

I only need three random numbers within the range of 1-54 (deck of cards) and none of the three numbers can be a duplicate. I cannot use an ArrayList; I must use a ...
1
vote
1answer
32 views

Using semaphore in C

This is my first time using semaphores and I was wondering if I implemented them to the best of their abilities in my code.... ...
5
votes
1answer
116 views

Generating XKCD passwords

Obviously, everyone should use a password manager to generate and store long unique random strings of characters for the vast majority of their passwords. However, one still needs to memorize a master ...
0
votes
2answers
86 views

Random Walk simulator seems slow, are there ways to optimize my code?

I'm trying to write a short random walk simulator in which an agent has a 50% chance on each "round" to either move toward x or back to its initial position. If the agent is already at its initial ...
3
votes
2answers
170 views

Heightmap generation using midpoint displacement

I am writing a program to generate a height map following the midpoint displacement algorithm (somewhat similar to diamond-square). I'm at the point where I have a recursive program that paints the ...
3
votes
2answers
226 views

“Guess my Number” game in Python (2.7.9)

First time posting to Code Review. Just looking to get some advice on how I can write better code. I found the following exercise for a "Guess my Number" game on DaniWeb, but the linked source code ...
3
votes
1answer
66 views

Portably generate uniformly random floats from mt19937 output

My goal is to generate a sequence of random float from a seeded random generator. The sequence should be the same on any machine / any compiler -- this rules out ...