Most voted "random" questions
Use this tag for questions pertaining to random or pseudo-random numbers.
Learn more…236 questions
Sort by count of
-
1
votes1
answer79
viewsHow to make a Seed.Rb by randomly searching Sqlite data in Rails?
Since I already have a register of cities and states, which you can see below, my question is the following, how can I place within the function 10.times in the lines of address_city and…
-
1
votes1
answer320
viewsRandomization/Randomization C#
Boas. I’m trying to create a Snake game in c# and I have no idea how I can make a new fruit appear in a random place when the snake picks some fruit.
-
1
votes2
answers386
viewsAssign numbers to PHP phrases
Hello, I have a number of phrases, and I need that every time the user sent a certain form, appeared one of these phrases, using a random function, but I do not even know how to start, I have no…
-
1
votes3
answers2971
views -
1
votes2
answers775
viewsGenerate random numbers
I have the following problem: I need to generate a random number between 1 and 6 Assign to a array of numbers if this new number is not contained in array If contained, generate again. Do this…
-
1
votes2
answers94
viewsRefactoring generation of random datetime (Python)
accept suggestions to improve this code https://github.com/rg3915/django-orm/blob/master/fixtures/gen_random_values.py#L34-L45 import random import datetime def gen_timestamp(min_year=1915,…
-
1
votes1
answer52
viewsEnumerator Random
I’m having trouble making an enumerator tube. enum Notas {A=10, B=22, C=31, D=44, E=56}; There is this solution, but I need the values of the Enumerators and here it is returning the rest of the…
-
1
votes1
answer166
viewsPHP How to pick a random value like Rand($min, $max) but with a query?
For example, in a browser game I want when the user clicks attack to return another user who has +- the same battle power as him. $select = $mysqli->query("select * from data order by rand()");…
-
1
votes1
answer3898
viewsC file manipulation (skip lines)
Hello, I’m having a problem to skip lines in a file, I use fgets(), but it always prints the first line of my file. I also did some tests, and for some reason, there is only one iteration and x…
-
1
votes2
answers2820
viewsHow to generate an array using Random to assign values, but make it never repeat values?
I’m working on a Bingo in C# for a facul work and need to make a vector of so many values and make it never repeat this values, I am using the following procedure to generate the values of draw ↓…
-
1
votes2
answers74
viewsChoosing an index from a list
I have a list: l = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] I would like to choose a value between the indexes 6 and 14 of this list, but do this 5 times and store these values in another…
-
1
votes0
answers153
viewsSelecting and deleting random lines from csv in python
I need to make a small script in python that meets the following requirements: Open a csv file; Delete first row and first column from reading as it contains information that will not be needed in…
-
1
votes2
answers3516
viewsHow to generate random numbers at command prompt?
I have a file on .cmd and I need it to generate random numbers with 10 algorithms. Like for example 9006100001 and 1579970319 randomly generated. I currently have the following function generating…
-
1
votes1
answer1204
viewsRand() function does not return random numbers. C++
I have a function that needs to generate, in a specific part, a random number to do a certain task. But whenever the program enters this function, the generated number does not change, always being…
-
1
votes1
answer68
viewsProblem after applying a patch to generate random names in ffmpeg
I applied the following patch below, it works as expected, but occasionally transcoding for and in other cases(rare cases, depending on the compiled ffmpeg version) keeps running but instead of…
-
1
votes1
answer506
viewsCreate random classes and ids
How I create random classes and ids in HTML? A platform here with whom I work, she, every page update, a di in Footer updates its classes and ids, in a random mode. For example, now she’s like this:…
-
1
votes1
answer100
views -
1
votes2
answers50
viewsRandom on button with isEmpty();
Hello, I’m new in programming to studying Java and now some Android. I’m trying to use the Random to send random messages if nothing is typed. So, my code is like this: public class MainActivity…
-
1
votes2
answers438
viewsBubblesort random numbers
The numbers are generated randomly in the vector, but when I call the function Bublle to sort the result returns 0. Someone can help me???? using System; namespace BubbleSort_CSharp { class Program…
-
1
votes1
answer133
viewsRandom ads with view counter
I’m with the following script to put random ads on the site, besides simple and easy also works really well and fast with various ads. The problem is this: How many times each ad was chosen by this…
-
1
votes3
answers71
viewsCompiler accusing error I don’t know
#include<stdio.h> int sumofDie(int value1, int value2); int main( void ){ int die1[7]; int die2[7]; int i; srand(time(NULL)); printf("Rolling die 1 ..........\n"); for( i = 0; i < 6; i++){…
-
1
votes2
answers219
viewsLimit result to random
I use the query SELECT * FROM mpbbolao WHERE eTIME1>=2 LIMIT 1 for example. To receive a query result I use LIMIT 1. Is there any way I can randomize what that "1" result will be?…
-
1
votes1
answer100
viewsHow to use Random script
I have 3 Google Adsense scripts with 300 x 250 - 160 x 600 - 728 x 90 How I do for each time the page is loaded 1 of these scripts is shown? I would like each page Reload to be shown 1 script.…
-
1
votes0
answers55
viewsArray with random indices
I have a random array that returns several keys and I need to manipulate all the returned data, the problem is that they vary depending on the occasion, I want to display this organized information…
-
1
votes0
answers21
views -
1
votes3
answers210
viewsAudio aleatorio na pagina
I wish that whenever someone walks into a page some random mail is reproduced that is in a folder. I tried to use this <?php $dir_path = "data/"; $extensions_array = array('mp3');…
-
1
votes1
answer81
viewsStrange behaviour of Rand() function
By the definition in documentation echo rand() // Imprime algo completamente aleatório echo rand($min, $max) // Imprime algo em um range entre min e max In a code, inside a loop, I accidentally…
-
1
votes1
answer1306
viewsHow do I generate random numbers between 5 and 30 in Java?
I need to use the Random method and store it in a distance variable, then show the distance from city A to city B, and from city A to city D, that is, a different random number for each distance…
-
1
votes1
answer626
viewsHow to open a random image
I have a new doubt and this has been the best place to find answers, since. My problem and the next, I’m doing a school quiz for my son. And a simple thing, at least it should be. A question with 3…
-
1
votes2
answers282
viewsSum the random data
I have a code for a dice roller. Then the person will enter in the field the amount of data that will roll and after that the program will run the amount of data and add. So I made a array to…
-
1
votes0
answers267
viewsGenerate random numbers in R with Skew-Normal Bivariate distribution
I did the script below, but I doubt if it is correct, I need to generate a bivariate vector with medium skew-normal distribution mu=(mu1,mu2), matrix of variance and covariance…
-
1
votes1
answer2558
views -
1
votes1
answer312
viewsProblem generating random value using Random class
The program is generating a random value, but sometimes it pops the array, or simply displays nothing. Examples of the error: My code: import java.util.Scanner; import java.util.Random; public class…
-
1
votes1
answer1320
viewsJAVA - Generate a random & scrambled word
I intend to generate a randomized, scrambled word from a vector. It’s already generating a random word, but it’s not scrambled. I created a method called Scramble where the words will be shuffled…
-
1
votes1
answer276
viewsFloating rand in C matrix
Good afternoon, I am using the Rand function to generate random numbers in a C matrix, but I can only generate integers. I would like to generate floating numbers. I did not find anything of the…
-
1
votes2
answers529
viewsHow to make a minimum ceiling and a maximum ceiling in a random number?
I am developing an application in Java and in my controller I have a function that generates random numbers. Example: In my first column I want you to manage from 0 to 8, so far OK. In the second…
-
1
votes3
answers165
viewsError with Random function
This is the code I wrote in Python: from random import randint a = randint print(a) When using the function randint in this simple code, the console gives me the following error: <bound method…
-
1
votes4
answers2686
viewsCreate multiple lists containing random numbers
How can I create a code that generates 50 lists with 12 random elements? I’ve tried to use while to repeat a list generation function, but it did not work very well. import random def…
-
1
votes1
answer953
viewsRandom Numbers without repetition.(Javascript)
Good morning, I created a small lottery game, where is generated 06 numbers between 0-20, the user informs his guess of 06 numbers and the system returns how many numbers were hit and which numbers…
-
1
votes1
answer105
viewsfind least repeated value in list
I have to draw a thousand numbers between 0 and 100, and point out which numbers were more/less repeated and the highest and lowest value, but I could not find a way to show what was less drawn.…
-
1
votes2
answers2087
viewsHow to draw numbers from a list, randomly and without repetitions?
How do I draw 9 numbers in a list of 15, without repeating the numbers drawn? I use Python 3.8. import random for c in range (1, 16): n1 = str(input("Digite um nº: ")) l = [n1] random.shuffle(l)…
-
1
votes0
answers69
viewsDistribution addicted when using the Rand() function
Hello, how do I use the function rand() with the range Y [11, height+9] and X [11, width-1]. srand (time(NULL)); y=rand() % ((altura+9)-11) + 11; x=rand() % ((largura-1)-11) + 11; gotoXY(x, y);…
-
1
votes2
answers843
viewsRandom colors on buttons
I would like my buttons to change color every time the page is updated. I made some java code script that is not working and would like help to identify my mistake. <script> let r =…
-
1
votes1
answer43
viewsHow to identify the number that was drawn
I would like to know how to obtain the values of the variables nipeSorteado and faceSorteada to compare with displayed output. The output of row 9 will display the values corresponding to the…
-
1
votes1
answer85
viewsHow to create a good GCL to do Random function?
I know it’s rediscovering the wheel, but I want to know how I can implement in my own way a nice linear congruent generator to draw integer numbers from 0 to 2^B-1. How to choose constants, how many…
-
1
votes2
answers120
viewsBingo program does not identify who has won
Trying to make a bingo with matrix in C, however the verification of the drawn values does not identify correctly with the matrix. #include <stdlib.h> #include <stdio.h> #include…
-
1
votes1
answer2479
viewsGenerate even and odd random numbers with defined quantities
How to generate random numbers with Random and limiting the number of odd and odd pairs? Example: 50 numbers should be generated in total, being 20 pairs and 30 odd. public int GeraVetorParImpar() {…
-
1
votes1
answer1044
viewsHow to generate, encode and encrypt random string in Flutter
I need to generate a 32byte code and encode for Base64, then Sha256 and Base64 again But apparently this code has something wrong and I can’t understand what it is var _random = Random.secure(); var…
-
1
votes1
answer165
viewsChoose between two numbers in Java
I’m building a game in which I want an object with given coordinates on the ground to spread, creating more pixels of himself on the ground. Each pixel of which would be represented by number 4.…
-
1
votes1
answer100
viewsMultiple Rotate images on the same click
Good afternoon, I have a question. I intend that when we click on a button a random image of an 80-card deck will appear. Then if we click again on that same button, another card appears next to the…