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

learn more… | top users | synonyms

0
votes
1answer
34 views

Brute-force word cracking program using /dev/urandom

I've been having fun with this program and trying to use different methods and such to achieve the fastest possible word cracking program I can come up with. I'm pretty happy with my current program ...
4
votes
1answer
66 views

Using random to generate strings

I have code that reads from files of surnames, female and male names and randomly generates a name in the following format: lastname, male/female name. The files are in the following format: ...
0
votes
0answers
24 views

RNG in Java being evenly distributed [closed]

We all know that RNG's aren't perfect. However, I found this test particularly interesting: Basically what I have is a simple program that computes the frequency of numbers in a standard dice roll in ...
3
votes
2answers
81 views

Math quiz for teachers & students

I have been programming a maths quiz that can be used for teachers and I have have been trying to make the code as short as possible so it is easier to understand. If there is any way I could make it ...
-1
votes
0answers
17 views

How to create a random number in an oval [closed]

I need to help to find a way to generate a random number in the circle under the variable random_number. I'm new to this, so can you please make this understandable to a rookie? ...
6
votes
3answers
94 views

Slot Machine in Python

I have made this little program which allows you to play a slot machine: ...
7
votes
1answer
58 views

Poker probabilities finder

This code finds the probabilities of the various scores in Poker. It uses a Monte Carlo approach, in which, two million (\$2 \times 10^{6}\$) hands are simulated and evaluated, not an exhaustive ...
5
votes
2answers
117 views

Russian Roulette in Java using JFrame

A while ago I got bored and being the beginner programmer I am I made a Russian Roulette game in Java using JFrame. The first few windows are JOptionPanes that are a welcoming screen, an update log ...
2
votes
1answer
100 views

Bogosort vs bogobogosort [closed]

A question on Stack Overflow had me look up the article on bogosort on Wikipedia. There they describe the bogosort algorithm and the bogobogosort algorithm. They say, about this last algorithm, that: ...
5
votes
2answers
220 views

Alien Name Generator (using blocks of consonants and vowels)

This is my first script in Python, and I am looking for tips and constructive criticism about code style, whether there are more efficient ways of doing things, etc. (not as interested in tips about ...
10
votes
3answers
820 views

App for generating passwords

I wrote a simple JS app to generate passwords. I read up on some of the commenting standards for JS, and started reading the book Clean Code. I am not sure if I am writing the ...
8
votes
4answers
116 views

Buffon's Needle experiment

I was working on a program that simulates the Buffon's Needle experiment. If anyone is not familiar with it, a Wiki link is provided - Buffons's Needle The point of Buffon's experiment is to find ...
7
votes
4answers
137 views

Matrix struct with random values allocation and deallocation

I've written this code in 2013 or 2014, I think. I've rediscovered it today in one of my folders, made some changes and now I'm left (and my 2013/2014 me as well) wondering how good it looks for other ...
1
vote
2answers
160 views

Lotto/lucky draw

The following script draws 6 numbers at random. I input another 6 numbers and compare with random numbers generated, if they're the same, you win. ...
1
vote
4answers
185 views

Generating random numbers from thread timing in C++

I have the following code blocks that generate apparently random numbers by using thread timing variations. I am looking for a general code review, and a specific focus on whether the results are ...
7
votes
2answers
236 views

Random value excluding both limits

The javascript method Math.random() returns a (pseudo-)random float between 0 (inclusive) and 1 (exclusive). In some use cases, I need both limits to be excluded, ...
6
votes
1answer
79 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 ...
6
votes
3answers
109 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
126 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
655 views

Generating new random items from a list

...
6
votes
2answers
92 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
49 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
163 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
61 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
58 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
636 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
51 views

Generating random XML documents

I'm trying to generate a fresh XML file using Perl XML::Mini::Document. It's working fine, but I don't know whether it's the right way to do it. Performance is the ...
8
votes
2answers
173 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
65 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
47 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
58 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
417 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
155 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
115 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
37 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
192 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
1answer
72 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 pairs of consecutive bits in the array and returning ...
2
votes
1answer
91 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
74 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
293 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
52 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
68 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
76 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
422 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
56 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
103 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
565 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
210 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
118 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 ...