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

learn more… | top users | synonyms

2
votes
2answers
26 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
159 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
40 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
41 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
45 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
285 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
137 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
101 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
23 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
70 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 ...
3
votes
0answers
41 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 ...
1
vote
1answer
68 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
69 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
151 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
46 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: ...
3
votes
1answer
54 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
68 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
390 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
50 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
54 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
350 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
174 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
77 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
646 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
55 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
367 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
57 views
2
votes
1answer
47 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
156 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
130 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
193 views

Lottery number generator

...
6
votes
1answer
224 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
48 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
78 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
147 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
102 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
101 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 ...
1
vote
1answer
69 views

Random retrievable number based on day and month

I wrote a function to get a 2-digit random number for each day, but it should be retrievable. For example, today's random number is 72, but later I can provide "day and month" and get this 72 again. ...
8
votes
1answer
136 views

Simulate Random Risk Battle

For Prof. Yorgey's 2013 Haskell course, I'm working on a homework to simulate a Risk battle. ...
1
vote
2answers
188 views

Generate random unit vectors around circle

I'm trying to generate a bunch of uniformly distributed unit vectors around the unit circle. Here's my code, which is working, but unfortunately I have a for-loop. How do I get rid of this for-loop? ...
4
votes
3answers
533 views

Vertical Histogram

I've been been working on a vertical histogram that prints an asterisk in place of a number in a certain range (say 1-10... and so on). My code is working as required. Is there a better, simpler or ...
4
votes
1answer
181 views

Sudoku generator

I managed to create a Sudoku generator but I'll just go ahead and say that it generates 1 out of 500 tries on average. I'd say that's pretty inefficient and I'd like to ask you for advice on ...
8
votes
3answers
2k views

Completed Town Generator

I am a beginner, and I believe I made a simple and efficient program to do it in. I can add more methods for more detail for future updates, but it's a workable bit. ...
0
votes
4answers
43 views

Removing random repeated guesses from brute force program

I came here to ask if there is a way to prevent already guessed guesses from being guessed again in my brute-force Java program. Basically I used a rand.nextInt in ...
2
votes
2answers
2k views

Math equation generator program

I am building this program in Python to generate 10 random arithmetic questions of either multiplication, addition or subtraction and then saves users scores to a .txt file. I just wanted some help ...
7
votes
5answers
709 views

Interactive dice simulator

After finishing my course on CodeAcademy, I wanted to write a program. Please provide opinions. ...
11
votes
3answers
1k views

License and Registration, Sir

The following code will generate a number plate and then generate a random speed and see if it's speeding ...