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

learn more… | top users | synonyms

2
votes
1answer
50 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
34 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
46 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
68 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
112 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
45 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
47 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
65 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
377 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
44 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
0answers
25 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
317 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
160 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
61 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 ...
2
votes
0answers
46 views

Implementing common random numbers in a simulation [closed]

I originally posted this on stackoverflow, but the came across this site which I think the question is better suited for. I am building a small simulation in Python and I would like to use Common ...
6
votes
2answers
591 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
52 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
331 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
50 views
2
votes
1answer
46 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
117 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 ...
2
votes
0answers
87 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
175 views

Lottery number generator

...
5
votes
1answer
205 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
45 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
70 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
123 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
80 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
93 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
62 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. ...
6
votes
1answer
120 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
152 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
420 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 ...
-3
votes
1answer
66 views

Simple betting game in python not working [closed]

So the problem I am having with this code is that when I run the code, there are no issues, however when it gets to the result of the dice roll, it does not subtract money if the person lost the bet, ...
4
votes
1answer
161 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
34 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
693 views

Interactive dice simulator

After finishing my course on CodeAcademy, I wanted to write a program. Please provide opinions. ...
11
votes
3answers
940 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 ...
13
votes
2answers
460 views

Pi by Monte-Carlo

I was inspired by this SO post to investigate a good Java8 way to calculate Pi based on simulation. I used a similar task to learn about parallel programming on both CUDA, and Intel Xeon Phi ...
10
votes
3answers
449 views

Souped-up random walk terrain generator

I started learning Python a couple of weeks ago, and to test my new knowledge of Python, I decided to use Pygame to code a random walk terrain generator. ...
5
votes
3answers
981 views

Random walk in Python + turtle

I decided to implement a random walk. The rules The rules are easy, an object is moved in the direction dictated by random or pseudo-random numbers. If you want to read more about it, see the ...
2
votes
2answers
44 views

Randomly pick a host from a list, subject to an uptime requirement

I have a POJO as shown below which will have hostname and other attributes. ...
11
votes
3answers
518 views

Predicting the next pseudorandom value

The archived material for the Stanford University course on cryptography at coursera.org includes a problem where you have to predict the next output of a weak PRG. It can be briefly restated as ...
3
votes
1answer
196 views

Generate Random String and Writing to File

my task is to generate random strings and store in a file till the size of file is less than 10MB. My approach towards this problem is as follows. ...
2
votes
0answers
76 views

Generate a random numbers class - follow-up

Previous question: Generate a random numbers class I have come up with three different ways to define type of mUniformDistribution. All of them work fine in VC++ ...