Questions tagged [random]

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

Filter by
Sorted by
Tagged with
2 votes
1 answer
74 views

Casino Number Guessing Game

I have created a casino number guessing game in C++: ...
kit.kat.code's user avatar
4 votes
1 answer
333 views

Porting xoroshiro1024** from C to C#, and seeding it

I require a PRNG which: Has repeatable results from a given state. Is both seeded from and has a state containing a sufficiently large amount of data (somewhere in the region of 700 bits or more) to ...
Pikanchion's user avatar
4 votes
2 answers
318 views

Making a dice game as my first Python project!

I just started my programming lessons in school today and I decided to start learning more at home. This is my first day and I know the basics of if conditions, <...
Ekwa's user avatar
  • 41
4 votes
4 answers
895 views

Lottery Analysis (Python Crash Course, exercise 9-15)

I was working on Python Crash Course, exercise 9-15: 'Lottery Analysis'. It took me a very long time to get it to work. The reason it took that long is I wanted to use my existing class from the ...
snapieee's user avatar
2 votes
0 answers
129 views

Truly cryptographically secure password generator in Python, version 2

Following suggestions from answers from my previous question, I have completely rewrote my script, to make it more concise and Pythonic, truly cryptographically secure, and added more functionality. ...
Ξένη Γήινος's user avatar
10 votes
3 answers
2k views

Python command-line program that generates passwords

I took my code from this answer by me, I found it useful, so I developed it further, and here is the result. This script generates cryptographically secure passwords. The characters used by the ...
Ξένη Γήινος's user avatar
10 votes
3 answers
3k views

Python \ random password generation code

I have written a python program for random password generation and as a newbie I would like my code to be reviewed by professionals and if they have any suggestions to improve it. ...
M.alizadeh's user avatar
3 votes
1 answer
122 views

JavaScript seedable Math.random

I made an implementation of xoshiro256** in JavaScript, using BigInts. It's designed to mimic Math.random. Any feedback on the code quality? ...
rfl890's user avatar
  • 101
9 votes
2 answers
777 views

Simulation of hero vs monster

I fairly started coding no more than 2 weeks now; not even for long, and a thread inspired me to make a random back-to-forth game between a Hero and a Monster where it randomly choose a certain number ...
doobiebob's user avatar
0 votes
1 answer
368 views

Random Name Selection from a "Hat" in Python

Background/context: This program randomly selects predefined items ("Names" as strings) according to 2 rules: #Rule 1: Each name/item in the list can only be selected once. #Rule 2: Single ...
Christian R's user avatar
2 votes
2 answers
82 views

Return a random integer with a probability progression

A function random_int_with_probability that returns a random number within a range, where the chance to get a bigger value decreases linearly towards the maxima. In ...
Edenia's user avatar
  • 1,548
1 vote
2 answers
68 views

Create a random list of values with corresponding tokens

I have this code that uses loops and random generators to create a random list of values (operators, strings, integers, floats, and new lines) and a corresponding list of the correct tokens to test a ...
Finn E's user avatar
  • 111
2 votes
1 answer
145 views

Rolling my own PRNG in Java

I have this pseudorandom number generator: ...
coderodde's user avatar
  • 27k
12 votes
2 answers
6k views

Laughably tiny random engine

I devised a tiny pseudo-random engine and I wondered if it would be considered decent or even good. It is based on a SHA256 implementation and uses a single 32-bytes state variable. On seeding, the ...
PinkTurtle's user avatar
4 votes
1 answer
71 views

Piece-wise radial uniformly random distribution of points around a reference point

I have been learning Asymptote, which is a vector graphics programming language. In addition to its nice integration with LaTeX and friends, it is capable of generating 3D rendered artworks. For a ...
user avatar
2 votes
1 answer
215 views

Pick two random cards from a standard deck

I wrote this code as a refactor of code I saw on Programiz. I thought about this refactor before going to bed and implemented it successfully in code. ...
dylanm's user avatar
  • 23
5 votes
1 answer
230 views

blackjack dealer hand generator

I wrote a piece of blackjack code - for dealer dealing cards to himself (python). My question is how can I make it more efficient, faster and neater. I ran it for 1.000.000 iterations and it took 14.7 ...
Edward Henry Brenner's user avatar
4 votes
2 answers
721 views

generate lottery numbers to store in a text file

I scripted a program in python to generate lottery numbers for user. There are two playing methods: Lotto6aus49: User can choose any 6 numbers out of 49. Eurojackpot: User can choose 5 numbers out of ...
Stephan Koenig's user avatar
2 votes
3 answers
548 views

Create different groups of students for a number of assignments [closed]

How can I make the code easy? The function which was developed contains the following inputs: students: a list with names of students events: an integer specifying how many group assignments should ...
Festim Besim's user avatar
4 votes
1 answer
60 views

Generating a randomized JSON for testing RabbitMQ

The following code will be used to generate a random json object to be used as a RabbitMQ message body. The code works but I'm sure it can be improved in ways that I am not seeing, as I am a novice. ...
Johnny's user avatar
  • 41
17 votes
4 answers
4k views

Python program to scramble MP3 audio

I'm super new to coding. I had a random idea in the car to make this application in order dive head first into learning to code. This is an app to take an MP3 file, "shred it" into pieces (...
Andrew Worley's user avatar
2 votes
1 answer
257 views

Simple ID Generator

Task Write a program that can generate and manage collections of IDs. The user should determine how long the IDs have to be and what symbols they are composed of. Design choices made by me The ...
Dexter Thorn's user avatar
  • 2,154
1 vote
1 answer
327 views

Generate random int based on a 32 characters long string seed

I want to generate a random seed based on a string value (which is ~32 characters long). I don't want to use string.GetHashCode() since I may later will need a ...
DoubleVoid's user avatar
0 votes
3 answers
112 views

A more elegant way to uniformly sample from non-negative integers with a fixed sum

Given a positive integer n, I would like to randomly output n non negative integers that sum to ...
Simd's user avatar
  • 191
2 votes
2 answers
90 views

Sampling from k circles with different radii

Description: I would like to sample n_points points from k circles whose radii and centers are given as lists. Note: This is my ...
ThePortakal's user avatar
1 vote
2 answers
91 views

Generating random integers in one of three ranges

I have a function returns a random integer number. This function only accepts these three numbers 1,2 and 3(there's another function in my code which is make sure of this otherwise that function will ...
Ahmed's user avatar
  • 13
8 votes
5 answers
3k views

Simple Python code that makes a random string of letters and numbers

My code basically picks random letters and numbers from three lists and makes a random combination with them. I decided to write this code just for fun, however I feel like the code can be made ...
Jea's user avatar
  • 83
3 votes
2 answers
234 views

Cryptographically secure version of the core array_rand() function

I want a cryptographically secure version of array_rand(). Is this it? ...
hanshenrik's user avatar
5 votes
2 answers
667 views

Truth or dare program in java

I wrote this code in Java as a "Truth or Dare" game where if you type "truth" or "dare", it will pick a random number from the switch and then output the truth question ...
Harpsickle's user avatar
3 votes
1 answer
184 views

Randomly set styles with JavaScript

I have created a function which randomly sets styles using CSS selectors. Right now it returns a random item from an array. The program also works with shorthand properties (such as ...
Gibberish's user avatar
  • 109
5 votes
4 answers
2k views

Coin flip streaks in Python

Below is the wording from the problem in Automate the Boring Stuff book. The bold text leads me to believe that I should be checking for a streak and not multiple streaks within each experiment of 100 ...
a-rizzo's user avatar
  • 51
-1 votes
1 answer
66 views

Quantum Random Generator outputs pieces of PI [closed]

This is a curiosity as a follow up from Purely Random Numbers Generator ...
Pinchi's user avatar
  • 23
0 votes
2 answers
123 views

Purely Random Numbers Generator

I think the best Random Number on the Planet is PI. I wrote a code that generates a list of pseudo-random numbers in Python. Then it treats this list as positions of digits in Pi and then outputs ...
Pinchi's user avatar
  • 23
3 votes
0 answers
50 views

Idiomatic PRNG in Scheme

For reasons that are too dreary to detail, I need to reproduce several pseudo random number generators in different languages. It mostly involves translating ancient C and FORTRAN code. No problems ...
clartaq's user avatar
  • 257
-2 votes
1 answer
5k views

Choose a word randomly from input, without storage [closed]

It is a practice assignment (optional). The question is asking to "Write a program RandomWord.java that reads a sequence of words from standard input and prints one of those words uniformly at ...
DGKang's user avatar
  • 105
8 votes
3 answers
852 views

Finding the perfect statline for a roleplaying game using Python

I made a program for fun that tries to roll a perfect statline, i.e a statline with two groups of only 18s, for a role-playing game. I'm still a newbie in python so mainly trying to learn how to make ...
HighestPie's user avatar
0 votes
1 answer
146 views

Python - Efficiently pick random data from an array, generate random UUIDs and save it all in an Excel table

I wrote the following prototype: ...
Munchkin's user avatar
  • 195
5 votes
4 answers
7k views

Get random time between two time inputs

This code takes two times as input and then calculates a random time between the two inputs. ...
DumbMathBoy's user avatar
2 votes
1 answer
369 views

Robotic swarm simulation: aggregation

This program simulates the phenomenon of aggregation of a swarm of robots with no cooperation between each other and each robot following a very simple rule: The velocity of this robot has a random ...
Caridorc's user avatar
  • 27.4k
4 votes
1 answer
224 views

Let's get random, extending Python's base random class

So Python's base random class uses the Mersenne Twister as its base for seeded random number generation. If available, it can use /urandom/, but that is beside the ...
N3buchadnezzar's user avatar
1 vote
1 answer
332 views

C# PRNG class based on xoshiro256**

Background I'm creating a (probably bad) map-generation utility in C# to generate fractal terrain and similar. Nothing I do probably needs special treatment, but I thought it best to start with a good ...
MichaelS's user avatar
  • 176
2 votes
1 answer
104 views

Any issue with this as a password generator?

Was trying to create a password generator like the one Bitwarden has... Curious if anyone sees any issues with this? (wordlist shortened for readability) There perhaps there's a more efficient way I'...
meowsoftly's user avatar
2 votes
0 answers
52 views

Python: Random forest code optimization

I've been working on random forest algorithm for classification with roulette selection to find best splits. I came up with this homebrew based on this article https://machinelearningmastery.com/...
Doombino's user avatar
1 vote
0 answers
54 views

simulation of updating a dataset from real time data

In this code (reproducible example) I want to generate a dataframe composed by random dates in the first col, and by random numbers (in reality they will be generate from a socket) in the second ...
Carlo's user avatar
  • 111
5 votes
1 answer
650 views

Monte-carlo simulation code - simple exercise

I created a quick monte-carlo simulation which seems to do what I want (simple version below). The code basically simulates a Poisson distribution, say this results in a simulation of ...
lmkir99's user avatar
  • 53
2 votes
1 answer
251 views

Generating a random ipaddress in C

I was looking to receive some feedback on the function I wrote to generate a random ip address. The code is pretty messy and just wanted some feedback regarding optimizations, memory leaks and best ...
snowwindmir's user avatar
1 vote
2 answers
85 views

Optimal random integer function

What I have Header file: int randomInt(int start, int end); Implementation file: ...
Reid Moffat's user avatar
2 votes
1 answer
2k views

React app that uses hooks and shows a random image every two seconds

React beginner here. I'm practicing state and hooks, and I wanted to create a small app that every two seconds fetches an image URL from a service (that returns random images) and shows the returned ...
sekmo's user avatar
  • 145
3 votes
1 answer
113 views

Improving performance of 'Prioritized left shuffle algorithm'

I wrote a prioritized left shuffle algorithm (the code is copied from my open source C# project Fluent Random Picker). That means: You've got some values and each of them has a priority (a number). ...
hardfork's user avatar
  • 227
2 votes
1 answer
64 views

Python Library for Random Collections

I created a small library Python library to randomly create primitive types and collections. The primitive types are int, float, and string. The collections are tuples of 2, tuples of 3, a list, a 2d ...
Akash Patel's user avatar

1
2 3 4 5
16