Questions tagged [random]

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

Filter by
Sorted by
Tagged with
3
votes
2answers
102 views

Randomises capitalisation of letters like bird spongebob

A friend and I have an inside joke; well, not exactly inside if it is based off an existing meme. We would send messages in the 'retarded' form, as the meme 'Retarded Spongebob' does in the example "i ...
4
votes
1answer
63 views

Matching a randomly made colour using sliders

Below is a code which creates a random colour and shows it to the user in a 64 x 64 square. The user must then use the 3 sliders (R, G, B) to match the colour as closely as possible ...
4
votes
1answer
766 views

Java game that generates and compares random numbers, looking for matches

I have written some Java code for a school assignment. It is a game, and it works as follows: The game makes 4 random numbers, all different, as the users ticket. It then generates 4 other random ...
2
votes
0answers
598 views

Thread-safe rand for C

I have this very short program for dealing with thread-safety of C's rand. Is it a correct implementation? ...
10
votes
2answers
189 views

Discrete selector

Background I tried to make the underlying container resizable if the corresponding weights are provided. But then, I faced a problem: C++ doesn't have standard interface for ...
4
votes
1answer
149 views

Comparing three C++ data structures for discrete sampling with probability distributions

Introduction A probability distribution data structures receives pairs \$\langle e_i, w_i \rangle_{i = 1}^n\$, (\$e_i\$ is an element and \$w_i\$ is its respective positive weight) and provides a ...
4
votes
2answers
156 views

Random C++ STL-only password generator for education

This is some code I wrote five years ago and I'm now using it partially as instructional material. I think there are some things that are 'off' about it, namely the top of the main function being the ...
2
votes
2answers
158 views

Random Number Generator Followup: Choosing the Generator Algorithm and the Distribution

This question is a follow-up from my previous code review question. This question regards the ability to choose a predefined random number generator algorithm and also choose a generator distribution. ...
1
vote
2answers
841 views

Simple Lottery Game

I have written a program in C that tests how many attempts it would need to win a lottery. Now I wanted to try out Python and I have written a little game based on the 6 out of 49 lottery game. I ...
3
votes
1answer
103 views

Gradient noise class based on Simplex noise

Here's a seedable 2D and 3D gradient noise class in C# that I wrote based on Simplex noise. Seems to work properly (even though it's highly experimental). I'm looking for tips to improve the quality ...
10
votes
1answer
174 views

Random Number Generator with Loads of Useless(-ish) Features

For fun, and to refresh my memory on Boost's program_options library, I have written a program with the goal of randomly generating numbers with loads of useless(-ish) features. I have termed it ...
1
vote
0answers
81 views

A Simple Cluster Generator v0.32

This is a code revision of a previous post and works well. The purpose of this code is to produce a universe of points, randomly generated around predetermined centroids, provided from the user as ...
5
votes
2answers
350 views

Simple NBA Draft Order Generator

I wrote a simple program to create a random order for an NBA draft, prompt the user for input of draft picks, print the order of the draft and the results, and write the results to a text file. This ...
4
votes
3answers
526 views

Determine hour in other countries with generated random time

I hope the title is clear. The objective is as following: There are 4 clocks in a hotel in London. One is showing the time for London. The others for New York, Tokyo and Hong Kong. Generate ...
5
votes
1answer
120 views

A Simple Cluster Generator v0.31

[NOTE] This question can be depreciated in favor of version 0.32. This is a code revision of a previous post and works well. The purpose of this code is to produce a universe of points, randomly ...
24
votes
4answers
5k views

6 out of 49 Lottery

In Germany we have a lottery with the following rules: You have to guess 6 numbers. The numbers shall be less than 50 and greater then 0. A number occurs only one time in a game. So you can not guess ...
3
votes
1answer
121 views

A Simple Cluster Generator v0.3

[NOTE] This question can be depreciated in favor of version 0.31. This is a code revision of a previous post and works well. The purpose of this code is to produce a universe of points, randomly ...
2
votes
1answer
362 views

Random YouTube video player

I just finished making this quick and dirty random YouTube video player for fun and learning. Before I get started, by "random" I mean selecting a video from a list of videos using PHP RNG, not truly ...
5
votes
2answers
117 views

A Simple Cluster Generator v0.2

[NOTE] This question can be depreciated in favor of version 0.3. This is a code revision of a previous post and works well. Code has been reworked to be far more clear and concise, thanks to ...
6
votes
2answers
1k views

UEFA Champions League Draw Simulator

I'm new to Python and have written a UEFA Champions League draw simulator. It receives input for 32 teams from 14 countries, and then randomly distributes them into groups of 4, never putting two ...
5
votes
3answers
930 views

WV lottery tool in Python

I am self taught in python. I love to play the lottery and play with numbers. I put this program together as a hobby to learn python and build something that people can use. I used and reused code ...
1
vote
1answer
89 views

A Simple Cluster Generator v0.1

[NOTE] This question can be depreciated in favor of version 0.2. The purpose of this code is to produce a universe of points, randomly generated around predetermined centroids, provided as a vector ...
4
votes
1answer
83 views

Picking a random state from a set based on probabilities

I'm writing a Markov Chain implementation, and need to be able to pick a random state from a set of states, where each state has a different probability of being chosen. In my caffeine-high, I wrote ...
1
vote
1answer
46 views

Get special sequence of integer numbers

Task: Get array of random integer (less than 10) numbers and random sequence of mathematical operations (multiplication and addition) which, when applied, will give a even number Example: ...
1
vote
1answer
445 views

Coin flip simulator with GUI

...
3
votes
0answers
105 views

Recursive Blum Blum Shub

Since my last tattoo resulted in a syntax error I was thinking of getting it peer reviewed this time around, are there any errors or quirks with this recursive Blum Blum Shub implementation that I ...
9
votes
3answers
549 views

LINQ-ifying Colour Generation from Strings

Recently I was thinking about how Google, Microsoft Outlook on Windows Phone (and now many others) method of giving you a coloured icon with a letter in the centre of it works. Essentially, given ...
2
votes
0answers
123 views

Correctness of PRNG / DRBG from Fortuna - C#

I'm writing a C# implementation of Fortuna, and have implemented the core PRNG / DRBG which should produce a uniform distribution. I've run a variety of statistical random test suites over the output (...
7
votes
1answer
832 views

Python CS GO Case Simulator

I'm a beginner in Python, 1-2 months experience. Please assess my code. I used a dictionary to store cases. The cases_data is stored in another file. Is the structuring right? My code seems to have a ...
2
votes
1answer
644 views

Provably fair coin flip system in Laravel

I made a provably fair 1v1 coin flip game in Laravel and I want to be sure it's safe (cannot be hacked) and that the outcome is random (50/50). At first Player 1 starts the bet and the hash will be ...
2
votes
3answers
263 views

Generate die rolls using coin flips

Problem I've seen this basic interview question in a couple of places, but never implemented it. Create an algorithm to output a fair die roll (values between 1 ...
3
votes
1answer
2k views

Python - Faster random business date generation

I wrote a program that generates some synthetic data. Everything runs fine, but right now the program is so slow that I am only generating 1000 rows of data (and it still takes 3 or so minutes). ...
1
vote
0answers
296 views

Seeded array shuffle

This should be relatively simple, but I want to know if I've done the randomness bit correctly. ...
6
votes
3answers
616 views

Shuffler with generics for C#

This is something I am always asked by managers and clients : "make it random". More often than not, this isn't what they want. Comments like "I had the same element twice in a row !" and "I don't ...
2
votes
1answer
96 views

Small text-game for teaching basic math

This is code for an assignment. Is there extra code I could have avoided using? I'm currently learning C++, so I am limited to my resources, but I do feel like I gave myself extra work. Are there any ...
1
vote
2answers
289 views

Dice roll game that generates random number

I just want to know how efficient is my code and is there any better way to do the same program in C? Can the if statements are replaced with something else or can I merge the two loops together to ...
2
votes
1answer
117 views

Complementary multiply with carry in Rust

Background and motivation I'm a C++ developer with a passion for modern, multi-threaded and functional code. I came across Rust not so long ago and it sounded like everything I wanted my C++ code to ...
3
votes
2answers
2k views

A simple lotto game in Python

I have a simple task of creating a simple lotto game to practice python. I had some troubles with return of functions so i dropped few because of not understanding the scopes maybe. In my next ...
0
votes
1answer
2k views

Random name picker for a contest

I have an array of 4 names, and was wondering what the best best way to reliably pick 1 name for a contest would be. I've read online that javascripts Math.Random ...
5
votes
1answer
525 views

Choose random instants in a day with a low memory footprint

I'm looking for a way to plan a list of X events at the start of the day... What I did before: At 02:00 every day, choose X timestamps from "now" to 01:59 the next day. That worked well but I had to ...
6
votes
1answer
2k views

Monte Carlo simulation to approximate the value of PI

This is a C++ implementation of a simple Monte Carlo simulation to approximate the value of pi. The program uses the standard library Mersenne twister engine to generate two random numbers between -1....
15
votes
3answers
760 views

My images have secrets A.K.A. the making of aesthetic passwords

This is my implementation of a prng steganography tool written in Python. You can also find the code on GitHub. Steganography is the art of hiding messages in (images, videos or even audio) I've ...
10
votes
2answers
736 views

C++ <random> convenience functions

I have a set of functions in my program for conveniently generating random number in various distributions. I'm interested in the questions listed below, though other comments are also welcome. Am I ...
11
votes
4answers
1k views

random_iterator in C++

This is a small utility that permutes a C++ standard container without modifying the container being iterated: random_iterator.hpp ...
0
votes
1answer
921 views

Distributing points uniformly in a unit circle [closed]

I have been working on a code to distribute randomly generated points uniformly in a circle of radius 1 centered at origin. I have tried two variations of the code, yet they both yield one major ...
3
votes
2answers
778 views

Random Password Generator based on user input

This is my second program written in python. It basically creates a password made up of numbers, capital and lower case letters with the option to include special characters and dashes. I created a ...
27
votes
9answers
10k views

Generate a list of 10,000 numbers in random order

I am in the middle of an interview process with a company I am very excited about. The position is for a Junior Developer for C# applications. I have a year of experience at my current position as ...
2
votes
1answer
162 views

Palindromic game in Python

This is just a little palindromic game that searches all palindromic numbers in ur random generated list. Feel free to give me some advice. ...
4
votes
2answers
172 views

Generate a set of random values based on seed

I am a novice when it comes to Python. I am working stuff related to Flowshop scheduling and so to generate benchmarks I used one by Taillard (Link to his homepage). The details are in the technical ...
6
votes
2answers
289 views

Password generator class

I've written this class to generate a random password and was wondering if there's anything I could improve upon here and whether or not this a safe (most random) method of generating a password. ...