This tag is for questions pertaining to random numbers, whether pseudo random or truly random.
1
vote
1answer
55 views
Random number guessing game in python
I just started learning Python this week and put this together for my first program (outside of a Hello World one). Does anyone have any feedback/suggestions for improvement for this? I've tried to ...
8
votes
4answers
1k views
Picking 10 distinct words 'randomly' from List of unique words
My goal is to pick 10 unique words randomly from a List containing 20 unique words.
I would remove the duplicate word from the List whenever a duplicate word is ...
4
votes
2answers
64 views
Random playlist builder is slow
I wrote a Python script to scan my music library, randomly select 50 songs, and play them in VLC media player. It works great, just a little slow (takes several seconds to launch).
I know that ...
3
votes
1answer
44 views
Unique random number generation in Swift
In the process of learning Swift, I'm building a lotto numbers generator that generates a random number and appends it into an array, if the number already exists then it should re-generate a random ...
4
votes
3answers
469 views
Testing a Random number generator
Firstly, would appreciate some code-review feedback, from a TDD and design perspective.
Secondly, what are your thoughts on implementing test case: ...
4
votes
3answers
125 views
Guess three random numbers in order
We were given a homework assignment to create a C++ program that generates 3 different random numbers each time and the user is supposed to guess the three of them AND in order. I already achieved ...
6
votes
1answer
149 views
How random can you get?
I work for a service desk and change A LOT of passwords. Most the time the end user is a complete fool that doesn't understand the requirements for the password they want to use. So I created a ...
5
votes
0answers
117 views
Approximating Pi, Monte Carlo integration
I wrote some code that uses Monte Carlo Integration to Approximate pi in Java and Akka. The tl;dr explanation is you can imagine throwing darts at a square with a circle inscribed inside of it. You ...
2
votes
1answer
45 views
Get better conclusions from a javascript randomizer
I have a simple javascript randomizer that compares two random numbers with values 1 to 6.
I want to get a good estimate about the probability of the first been greater than the second. I could do it ...
0
votes
1answer
106 views
Guessing a random number [closed]
The program asks for a user to set the max number of the range. That number is used to set the max range of a randomly generated number. The program keeps track of the number of guesses. I have taken ...
1
vote
1answer
54 views
Playing the game of Chaos
According to Rosetta Code:
The Chaos Game is a method of generating the attractor of an iterated
function system (IFS). One of the best-known and simplest examples
creates a fractal, using a ...
3
votes
1answer
88 views
Generating a random coordinate (x, y) inside of a given polygon/area
I'm creating a virtual mapping software that essentially breaks coordinates into Areas. An Area is comprised of a defined list of boundary coordinates (coordinates ...
2
votes
2answers
73 views
Printing random lines from a file in Python
Is this the most efficient solution or can the performance be improved? Just opens a file and prints random words (lines with newlines stripped out).
...
1
vote
0answers
30 views
How do I generate a list of n numbers of random combinations in Python? [closed]
How can I alter this code to produce n numbers of random combinations instead of all combinations?
...
3
votes
1answer
48 views
Infinite Monkey Theorem Python Comparison
I wrote code to demonstrate the Infinite Monkey Theorem which states that if a monkey types at a keyboard for an infinite amount of time it will almost surely type a given text such as William ...
6
votes
0answers
50 views
A Version 4 UUID Implementation
I've been toying around with writing a decentralized, P2P application in REBOL 2, and one of the things I need to do is generate a universally unique identifier for users. I have written a function ...
2
votes
0answers
34 views
Random quote machine with jQuery
I've done a random quote machine in jQuery. Could you look at the code and propose some improvements (especially jQuery code)?
Here's the working app.
...
6
votes
1answer
674 views
XKCD Password Generator
I'd like to verify that the security of this JavaScript code is correctly doing what I believe it's doing. Its intended purpose is to generate xkcd-style passwords randomly in the visitor's browser.
...
2
votes
2answers
45 views
Basic 3 Round Card Game
Feel free to critique my code and offer suggestions on how to clean it up and make it more presentable. I have been working on this for a few days, and learning as I go.
...
2
votes
1answer
44 views
Random value generation for uncertainty analysis
I am a beginner in coding, writing my first bigger C++ project (aircraft initial sizing program). This code should be able to analyze the design in a probabilistic manner by using Monte Carlo ...
2
votes
2answers
148 views
Creating a random code and saving if it does not exist
I have created a script to generate 5 random codes, check if any one of them exists in the database, and if not, insert the record. The script will throw an exception if a single code could not be ...
2
votes
1answer
71 views
Preventing multiple copies within function using static
I've a function to generate random characters from a set of alphabets. This function would be called multiple times and thus I'm trying to make it use same set of variables, i.e. have same seed so ...
6
votes
2answers
71 views
Random name generation in ruby
I created this program as an exercise for me to learn ruby. It is a random name generator with a set of rules defined to generate pretty decent and usually pronouncable names. Ruby isn't exactly my ...
2
votes
1answer
60 views
Generate a random discrete signal
I currently have this code to generate a discrete signal with random amplitudes, but a fixed frequency:
...
8
votes
1answer
111 views
Monty Hall Optimization in Python 3.5
This is for homework but the deadline is over and I know the implementation is correct because it concurs with the math. At this point I just want to check my implementation for potential ...
1
vote
0answers
48 views
Einstein's Riddle via simulated annealing in Rebol
This solves Einstein's Riddle via simulated annealing. Rebol translation of Python example by Anojh Gnanachandran at his blog.
It gives the correct answer when it doesn't time out, in about same ...
2
votes
3answers
163 views
Simple random password generator
I decided to write a console program that can generate a random alphanumerical password in the C language. It's quite useful for when I'm making a new account and need to make up a quick password on ...
1
vote
2answers
96 views
Displaying random elements for a quiz app
I'm a teacher and I built a one-page web app to display random question sets for quizzes and tests. The script I wrote selects one question from a set (array) of questions.
The script works fine, ...
2
votes
1answer
48 views
Simple Random TicTacToe Generator
I just finished building a simple random Tic Tac Toe generator. The program will display 3 rows of a random numbers 0-1 and will print a message when 3 of the same numbers align. The program works ...
4
votes
1answer
91 views
Simple chatbot written in Python
I wrote a simple chatbot in Python a while ago, and I'd like to know how it could be improved. Here's the code:
...
2
votes
2answers
120 views
Generating random numbers and decks of cards
So I have some code here:
First a simple random # generator and a array-choosing function:
...
1
vote
2answers
45 views
Function for getting strings consisting of random characters
I've made this function for to be used while testing.
...
5
votes
3answers
76 views
Statistical Analysis of X-Wing Game Dice
I was in a discussion about mechanics of the X-Wing miniatures game where we were discussing a couple of the ways to improve attacks and I put together this small C# console application to determine ...
2
votes
2answers
171 views
4
votes
1answer
58 views
Generate dictionary of points on n-sphere
This is a long-shot, but my question is to simply optimize this particular function in some code I have written:
...
1
vote
1answer
76 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 password ...
3
votes
1answer
49 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
145 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
<...
0
votes
1answer
113 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
72 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
2k 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
43 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
48 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
59 views
Find the largest area polygon built from a given list of vertices
This is 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
135 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
917 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
87 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
56 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
182 views