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
votes2
answers112
viewsGenerating a txt with random numbers repeats the numbers
The program has to generate 10 letters and then skip a line with 10 different letters. I used the Random() and I was able to generate 10 random letters, only then just the lines repeat. Like, it…
-
1
votes1
answer40
viewsFast even random float within range
I did the following lcg (linear congruency generator) to draw unsigned int from 0x00000000 to 0xFFFFFFFF uniformly. Just for testing, I used the seed equal to zero and raffling the first five…
-
1
votes1
answer50
viewsWhen passed by class, numbers do not come out random
I’m creating a neural network, and now I’m doing the part that would create the population to be trained, but I’m not getting a randomness. I just don’t understand it and I don’t know how to get…
-
1
votes2
answers84
viewsRandom Doubt and Periodic Activities in Golang
Is there any way I can get one executed fmt.Printf(choosenCity) every 6 hours and, at each run, he chooses a different element of the Array? I even managed to get him to perform periodically after a…
-
0
votes2
answers171
viewsMake arc4random() not repeat last number
I created a app to generate random numbers. Only I wanted him not to repeat the last number he showed. Example: the result was 9 (run the method that generates the random number again) the result…
-
0
votes1
answer110
viewsHelp in comparison of randomized variable
I’m making a game of colors, in it I have a Random that randomizes buttons in a certain sequence. The value of these buttons are concatenated in the variavelX that sets my given sequence. ex: botão1…
-
0
votes1
answer263
viewsSet of 3 Java ports
I have to do an exercise in Java that consists in creating a matrix [3][3] and each line would be a phase of the game. The user should guess which door the prize is in. For this I need to make a…
-
0
votes1
answer158
viewsHow to create a Listview with Random items? (Android)
I’m having trouble with my Listview. I would like him to display his items in an Random way, but not to repeat the items, as is happening now. Here is the code: public class AdapterConteudo extends…
-
0
votes2
answers2710
viewsTake random value mysql
I would like to know some way to get some random value from Mysql without repeating, I am using this line: $query = mysql_query("SELECT * FROM users ORDER BY RAND()"); but it repeats quite a lot of…
-
0
votes1
answer344
viewsIs there any way to define a random order by an established order?
If the title of my question was confused, I explain: I want to sort a result of a certain query of MYSQL. Example: SELECT * FROM usuarios ORDER BY cidade = 'BH' DESC, cargo = 'Programador' DESC…
-
0
votes1
answer228
viewsAssign element to matrix only when there is space?
I have some vectors that should be assigned in a 20x20 matrix, but no vectors can override each other and not be printed in different lines, they should be assigned vertically or horizontally. For…
-
0
votes2
answers96
viewsPass random values to Matrix
I have a matrix with 30 fixed values, I wanted to know how to generate these same 30 values, but random, if possible with limit values between (2400, 400). How is the matrix currently: private…
-
0
votes1
answer272
viewsRuby on Rails - Randomize JSON variable and apply in Array
Guys, I’m having a problem that’s relatively simple, but it’s killing me. I have an array of JSON objects. This array of objects will compose another array of containing other n arrays. So far so…
-
0
votes1
answer345
viewsDrawing of predefined values
I have two Textbox (txtUM, txtDois), and would like to draw some pre-programmed date/string (Between dates: 07:55, 07:56, 07:57, 07:58, 07:59, 08:00, 08:01, 08:02, 08:03, 08:04, 08:05 ). The number…
-
0
votes1
answer154
viewsFind element that the ID is generated randomly
I have a situation that id, always updating randomly.. and without an apparent order making it possible for me to use find_element_by_id the component is as follows:: <table…
-
0
votes2
answers280
viewsList random objects
How could I generate random cars in the following model? it would be better to do this in controller? class Pessoa < ActiveRecord::Base has_many :carros end…
-
0
votes1
answer6742
viewsIs there any way to generate a random number between two numbers in Java?
How do you generate a random number in the specific java between min and max? Because with the nextInt function of the Random class you can only specify max.
-
0
votes1
answer66
viewsHow to select by the bank the value of the column using the Random() method
I made a project on Android that is a little hangman game, where I can record in the Sqlite database the word and a hint. In my Databasehelper class I created the normal database, and made some…
-
0
votes2
answers99
viewsGeneration of allele numbers
I have declared a method for generating random numbers, but the results are almost always the same, because? int geraAleatorio(int min, int max) { return ((rand() % (max - min)) + min) + 1; } Is…
-
0
votes1
answer100
viewsPython Random.getstate function
I need your help in the following situation: I have a loop that generates a random value from 0 to 400. I need my function to return at which time the loop generated the number X. (For example, loop…
-
0
votes1
answer270
viewsonload redirect aleatorio
I would like to create a function that loads a random page from a given address. Something like www.meusite.com/(numeros entre 0-100).html I think the function should create the tag A, then fill in…
-
0
votes1
answer442
viewsDraw between user-defined options
Hello, I am creating a Petri Net simulator (I considered it a challenge, since I am a beginner) and I would like to know if there is a way to create a draw between user-defined options. I would like…
-
0
votes1
answer123
viewsIn Bluej Class Random IDE, limit start and end values
As I have in the code gives me the error of void cannot be deferenced On the part of nextInt() in the last two lines and with so many attempts I’ve made I ended up like this. Latitude cannot be…
-
0
votes0
answers267
viewsRandom Python Monte Carlo function
I need to generate random numbers. An amount of numbers in the range of 10 5 and 10 6 random numbers. The randint function of the Random library seems to me that it does not have a good degree of…
-
0
votes3
answers3989
viewsHow to Generate random numbers without repeating in Random?
So far I have been able to generate random numbers and store, but I have no idea how not to generate repetition. So far it’s been like this: package curso1; import java.util.Random; public class…
-
0
votes2
answers774
viewsHow to randomize an Array in c++
There is a lot of material here about arrays ordering methods (quicksort, bubblesort, etc.) but I wanted to know if there is a "clutter" method of arrays, i.e., shuffling the elements of an array.…
-
0
votes1
answer212
viewsHow to invoke countdown every click on the button?
I want to develop something simple, but it’s making me frustrated. I will try to express myself in the best possible way. To simplify things around here, I’m only bringing as an example a randomized…
-
0
votes2
answers1013
viewsGenerate random numbers in java, store in a vector and sort them
I need to generate 100000 numbers, store them in an array and sort them using the Bubblesort algorithm, is appearing the error "Exception in thread "main" java.lang.Error: Unresolved Compilation…
-
0
votes2
answers2303
viewsRandom Choice in python
I’m a beginner and I’m creating a program to make tables, but I didn’t want the program to follow a growing order like "1x1, 1x2" and so on. So I used a "Random.Choice" function to show the tables…
-
0
votes1
answer1139
viewsPrinting of predefined phrases at random in C
Hello, I’m a beginner in programming and I’m learning to code in C. I want to do a show that has some sentences already defined. Ex c/ vectors: char vet1[100] = {"Hello World!"}; char vet2[100] =…
-
0
votes2
answers111
views -
0
votes1
answer103
viewsGenerate a random combination on each line
I made a number generator that looked like this: import random import math for i in range(10): c1 = (random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9])) c2 = (random.choice([1, 2, 3, 4, 5, 6, 7, 8, 9])) c3…
-
0
votes1
answer2628
viewsHow to generate random numbers but with some restrictions in python?
import random v=[1,7,15] x=random.choice(v) How do I generate more numbers "1" than "15"? At 10000 times, choose 1 number and at the end: number 1 must have left about 40%. number 7 must have left…
-
0
votes1
answer5595
viewsPair or odd through Random module (Python)
Recently I started learning programming language with python, I created a classic "game" to go learning with Random.randint for the user to try to guess which number was chosen by the machine. I…
-
0
votes1
answer684
viewsRandint does not generate random numbers the second time I use it
My randint when used the second time it does not generate new random numbers, it remains with the same generated numbers. I know that in C when this happens I can use the srand(time(NULL)); , but in…
-
0
votes0
answers39
viewsThe value change in the integer array in one index works in one case, and in another it doesn’t, why?
private void btnRodaLabirinto_Click(object sender, EventArgs e) { char[,] Lab = new char[10, 10]; int[,] Lab2 = new int[10, 10]; int I = 0, J = 0; Random NumerosRandomicos = new Random(); //abaixo,…
-
0
votes0
answers32
viewsHow can I shuffle a vector with structures? C
I need to shuffle domino pieces on a function, and I’m having trouble. void baralhar(int domino[]) { srand(time(NULL)); for (int i=1;i<=29;i++) { int r = rand() % 28; int aux = domino[i];…
-
0
votes0
answers49
viewsRand generating equal numbers
I have to do a program that generates random numbers for X1 and x2 and perform the operation F = X1*X1 + x2*x2; but I will repeat this 10 times and I will keep the lower value of F; then I will…
-
0
votes1
answer59
viewsMath.round() shows the 1675 result, but I wanted it to round to 1700
I’m having trouble with the Math.round() in Javascript, it shows the result 1675, but I wanted him to round up 1700. var altura = 170 var peso = 70 var idade = 30 var tmb tmb = 66.5 + (13.75 * peso)…
-
0
votes2
answers1557
viewsMaking a date set Random with pandas
I’m trying to extract 15O lines from a 500-line dataset. So I’d like to do it on Andom. My data objeto,cor,label cachorro,branco,animal manga,laranja,fruta calça,preta,roupa My script import pandas…
-
0
votes0
answers324
viewsUnique random function without repetition - C language
Guys, I’m doing a program in C language, and I need him to do some sweepstakes, but they can’t be repeated, the program controls the input of a lecture, and there will be a draw, in this draw the…
-
0
votes0
answers10
viewsHow to assign multiple pseudorandom numbers to a single tuple
I would like to know how to use the Random.randint() command to assign not only one, but several numbers to a tuple? wanted to assign 5 variables inside the tuple to then draw which one is the…
randomasked 3 years, 10 months ago Igor Gabriel 1 -
0
votes1
answer37
viewsGenerate key to access document
I need to generate a key that contains letters and numbers Ex: "AJ67G8". I am generating with Random from java.io.Serializable: public static String nomeAleatorio(int nCaracteres) { Random rand =…
-
0
votes1
answer1629
viewsGenerate random characters with the Random class
I was given the following code to help in the resolution of an exercise. Random gerador = new Random(); gerador.setSeed(4); System.out.println((char)(’a’ + (Math.abs(gerador.nextInt()) % 26))); I…
-
0
votes1
answer40
viewsHow do I guarantee unique numbers on a list of lists?
Good evening, I’m trying to make a 5x5 bingo card, using Andom to generate the values, however there can be no equal numbers. I tried to do it that way but it still comes up equal numbers: import…
-
0
votes0
answers14
viewsHow can we draw numbers on two Cells in Javascript and the numbers cannot be equal?
I’m like a doubt. I created two cells in html with a button and did Math.Random to draw numbers from 1 to 10 in these two cells, only I don’t want equal numbers to appear, there can never be equal…
-
0
votes3
answers358
viewsJS: store selected values in array
Good night. I am building a Javascript Bingo and want to store the numbers already drawn in an array to then consult it and avoid repetitions, but I don’t know how to do this. Can someone help,…
-
0
votes1
answer105
viewsCreating an object with a random internal datum (Random)
I am trying to create an object called "State", however I would like the DDD of each object, when creating, to be generated randomly. class Estado { public int Resultado { get; set; } public string…
-
0
votes1
answer110
viewsGenerate Unico Code in Sequence without Repeating MVC
I want to generate a registration code for each registered client. As ID I use the GUID, however, it is for ID(as it is extensive), I need a small code, not just a digit, for example: cód: 0001 , It…
-
0
votes1
answer138
viewsJO KEN PO’s game gone wrong
I’m trying to make a game of jokenpo but it’s gone wrong. from random import choice from time import sleep print('[1]PAPEL\n' '[2]TESOURA\n' '[3]PEDRA') escolha = input('Qual a sua escolha? ')…