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

learn more… | top users | synonyms

6
votes
0answers
42 views

Shuffling an arbitrary list or sequence

After reading this question I wanted to write a short example of how a list or sequence could be shuffled in .net. The result turned out to not be very short: Program.cs ...
5
votes
4answers
81 views

Efficient random code generator

I made a 16 character code generator. It works like a charm now, but I was wondering if there's any way to do it more efficiently. ...
10
votes
2answers
118 views

Random walk with equal probability

This method randomly increments or decrements (with equal probability) until either -3 or 3 are reached. I'd like to maintain printing the value of pos on each ...
8
votes
5answers
585 views
6
votes
2answers
86 views

Simple dice class

I've built a simple dice class utility for rolling dice. It supports weighted rolling, and usage is fairly simple. Here's the code. ...
4
votes
1answer
40 views

Identicon Generator

I'm just playing with Python, trying to refamiliarize myself with it since I haven't used it in a few years. I'm using Python3, but as far as I know it could easily be Python2 with a change to the ...
5
votes
2answers
124 views

Password generator with Secure Random

I have a small program in Java with GUI, which is generating passwords using Secure Random. I am posting my code here because I want to correct myself in style and, eventually, in efficiency of ...
7
votes
1answer
60 views

Improving Terrain Generation Time in C#

I am working on making my code run smoother, since I will be using it a lot in a game in development, but I am stumped. Is there any way I could make this run faster? Improvements to the terrain ...
3
votes
1answer
57 views

Retrieve random element from array not contained in second array

I have a function, getUnusedName that returns a random name, but first checks if it's already used by any object within a second array. Observing how many times ...
13
votes
3answers
605 views

Slot Machine Constructor

This is a fun little program I made of a fruit machine gambler, aka "slot machine". What mistakes am I making? How can I make this better OOP programming, less spaghetti? ...
2
votes
2answers
45 views

Generating random XML documents

I'm trying to generate a fresh XML file using Perl XML::Mini::Document. The sample code i tried is the one below. It's working fine, but I don't know whether it's ...
8
votes
2answers
170 views

Approximate (250 over 100) permutation best fitting certain criteria

Given a list of 250 words of 4 letters each, what is the fastest way, in Python, to find a subsample of 100 words (drawn without replacement) so that the distribution of letters across the whole ...
4
votes
1answer
55 views

Poker Odds Calculation with Monte Carlo

I have created an Odds Calculator in Java. The program gives me the odds, but I want to make sure that they are correct. Maybe someone can tell me a calculator I can compare my results with or knows ...
3
votes
1answer
45 views

Generating realistic terrain data - Part 2

I've made a "heightmap" terrain generator similar to my previous one, except this one has some improvements, and some new features. The way this one works is similar to my last one, but slightly ...
6
votes
2answers
55 views

First dice roller

The part I'm really wondering about is in the "if, elif, else" part. I set the variable to bring up the raw input thing so it would stay there long enough to read instead of just printing a response ...
7
votes
3answers
347 views

n-digit Verification Code Generator

This is a verification code generator, which generates n-digit numeric strings. (code can be 0000, so I chose String as a return ...
5
votes
3answers
151 views

Random letter test

My first test (randomUpperCaseLetter) checks if the returned random letter is an uppercase ASCII one. The second one (...
2
votes
2answers
110 views

Artificial Stock Market Algorithm

I'm attempting to make a stock trading game in Javascript and I've been trying to find an algorithm to generate fake stock prices. Currently, each Stock object has ...
2
votes
1answer
29 views

Random date gen class. Returns a tuple of a start date and end date

Just interested in any comments about the way the code is written. I am very new to python and programming. I did think about a func with a generator, but thought this approach was better. ...
2
votes
1answer
135 views

Console random password generator

This program is a random password generator. It asks the user how many chars they want their password to be and how many passwords it should generate. I used the ...
4
votes
0answers
56 views

Von Neumann extractor to remove bias from pseudorandom array

Von Neumann extraction is a technique to remove bias from a source of entropy. You extract an unbiased array of bits from a biased one by comparing consecutive pairs of bits in the array and returning ...
2
votes
1answer
80 views

Generating realistic terrain data

I have some fascination with terrain generators, so I whipped up this generator in Python. The way it works is pretty simple, but I figure that I should give an explanation for those who don't want to ...
6
votes
1answer
73 views

Moody game characters

I've been doing some self-imposed exercises to get accustomed to Python and below is my code. ...
8
votes
2answers
220 views

D&D dice rolling app

This JavaScript object is part of a mobile application that rolls dice for our D&D games. Here are some example of possible inputs from the user: 2d4 2d4 + 3d6 2d4 + 3d6 + 12 ...
5
votes
1answer
49 views

Attempting a fluent API for creating random int arrays

I have attempted doing a fluent API for creating random int arrays, and the following is what I came up with: fluent_arrays.h: ...
4
votes
1answer
65 views

Modified Coupon Collector's Problem in Java

What is Coupon Collector's Problem? In probability theory, the coupon collector's problem describes the "collect all coupons and win" contests. It asks the following question: Suppose that there ...
3
votes
1answer
72 views

Pitting two Blackjack bots against each other

I'm taking part in this Daily Challenge on http://www.reddit.com/r/dailyprogrammer/comments/29zut0/772014_challenge_170_easy_blackjack_checker/ Basically, you have to develop a program that runs two ...
10
votes
3answers
408 views

Picking random lines out of text files

So I was doing something which creates an airplane with an actual airline code, number, airplane type and so on. The airline code and airplane type are stored in a txt file so I can add more later to ...
3
votes
1answer
54 views

Random Plinko path using functional programming style

In order to learn both scala and functional programming, I've been rewriting the projects from my introductory CS class in scala. One of the projects was a plinko game, where the user picks a slot to ...
0
votes
2answers
84 views

Shuffle Symfony entities

I've got an object $contest which is a Symfony entity that has some other entities assigned. I can get them by ...
9
votes
2answers
461 views

Random 5-character token generator

I have an Android app that uses randomly generated tokens to log in. They're 5 characters long, are sent to a user's email address, and have a short lifespan, so I don't think I need anything that's ...
10
votes
4answers
198 views

Get random direction based off of location and previous direction

I've recently implemented a Wilson's Algorithm for maze generation. This problem however could also be extended to things such as snake, or some other simple AIs. The problem is as follows: Blue ...
3
votes
2answers
100 views

Encrypt string using One Time Pad

I'm trying to make it so that a string generates n keys, and all of those are required to recover the original string. For this, I generate n-1 random strings, XOR them all together with the original ...
13
votes
7answers
1k views

Monty Hall Paradox in Java

I was wondering if this code looks neat, and if I should change anything. I was planning to implement Frames (or JFrame) tomorrow on it. Would it be a good idea to ...
6
votes
2answers
759 views

Random class in C++

I've very new to C++ and have been working through a tutorial and got as far as std::rand(). I was immediately horrified and rushed out to see if I could implement ...
6
votes
2answers
66 views

2D lattice random walk plots in functional style

To practice writing code in the functional programming style, I wrote a program to plot two-dimensional lattice random walks. I'd appreciate any feedback about how to improve its "functionaliness". ...
8
votes
4answers
395 views

Creating unique registration numbers using object factories

I'm learning about immutability and uniqueness in Java, particularly the use of defensive programming and object factories. I have been asked to create a class containing an object factory that when ...
1
vote
1answer
16 views

Equalized PRNG number distribution - Part 2

A few days ago, I've made a code to equaly distribute a set of numbers and retrieve them randomly. I've posted a question for the code to be reviewed. Today, I've rewritten the code (most of it, at ...
2
votes
1answer
65 views
2
votes
1answer
48 views

Equalized PRNG number distribution

The main idea behind this code is to distribute multiple random numbers, but guarantee that the probability of each coming is equal. The code is really basic: ...
2
votes
2answers
188 views

Generating a random number of progress bars

I have this JSFiddle that generates a random number of progress bars then assigns a random number and percent to them. I am wondering if you know how to better optimize this code to have better ...
3
votes
1answer
197 views

Drawing tarot cards

The goal is to draw random tarot cards from the suit, number of cards is determined by the amount of HTML elements with 'card-container' class on given page. The deck is structured as follows: ...
10
votes
4answers
221 views

Lottery number generator

...
6
votes
1answer
232 views

10-faced dice-rolling game

My code is for a 10-faced dice-rolling game. There are 2 players who start off with 50 points, then they both roll a dice and get a random score between 1-10. The player with the highest roll gets the ...
2
votes
0answers
50 views

Calculating all combinations to make sure a Random algorithm has done them all

I have done this, but it's pretty ugly and it feels like I may be missing something to shorten it: ...
1
vote
1answer
85 views

English phrases, prime numbers, pseudo random data and encryption source code check

This code uses a DCG and pairs phrases into near-English sentences. If anyone is familiar with Prolog, I'm wondering how I can use the code as an encryption method by hiding data and replacing it ...
3
votes
3answers
204 views

Generating a 64 bit unique integer in Java

I need to generate a 64 bit unique integer in Java. I need to make sure that there is very few or no collisions if possible. I came up with the below code which works fine: ...
6
votes
1answer
151 views

Generate random records for table in SQL

I'm doing a project in ms sql and I have to fill table with random records. Here is a definition of table: ...
8
votes
2answers
2k views

How much is 2 + 2?

I'm currently working on a kind of PHP Quiz about mathematical calculations. We show a mathematical equation, and user need to input his answer. Currently, this is what I have written: ...
3
votes
2answers
110 views

Displaying a random poem from a database

I'm new to web development, and I'm constantly torn between good code and bad code. I was wondering if you could help me improve my following code and see if I'm doing it right in terms of how I use ...