Most voted "random" questions
Use this tag for questions pertaining to random or pseudo-random numbers.
Learn more…236 questions
Sort by count of
-
0
votes1
answer144
viewsHow to draw a draw for an element of an array within a specific range?
I have a Python code, where I have an array (g) of 10,000 elements. After performing a draw using Andom.Choice(g) that draws any of these 10000 elements. However, I would like my final value to be…
-
0
votes1
answer262
viewsI need help creating a game like 21
I am working on a game type 21, and I am struggling to create a logic so that the values that the user receives through a draw with random.choice are stored in a list and soon after I display the…
-
0
votes2
answers106
viewsHow to order questions randomly?
I’m finishing a project of Quiz Unity game in C#, let me try to explain what I need, I already ask the random questions, but I want the answers to be displayed at random as well. I have a list of 5…
-
0
votes1
answer35
viewsRandomly generate values from a repeatless vector in C
I have the following scenario, which is a vector of questions that should be asked to the user randomly. The problem is that after I enter the first input value the array is iterated right after…
-
0
votes1
answer70
viewsPython: Problem with random numbers within while
I would like to know how to solve a small problem I am facing in this and other codes. When testing the example you will realize that it will use the same atk always, that is if he chooses the atk…
-
0
votes1
answer131
viewsPython Kick Game. Does anyone have any hints how to reduce or improve this code without using functions?
from random import randint from time import sleep valor = randint(1, 20) tentativa = 0 chute = 0 print() while chute != valor: chute = int(input('\nChute um número:…
-
0
votes1
answer137
viewsGenerate random emails
I’m doing an exercise that I’m cracking head, I have to create random emails from object array with fictitious client data, using a part of the nome and of cpf and I’m not getting it, someone could…
-
0
votes1
answer112
viewsHow to shuffle all letters of words within a file . txt
I am creating a program that shuffles all the letters of the words inside a file . txt in which each line there is only one word. Example of a . txt (which I called Wordlist.txt): batata limonada…
-
0
votes0
answers19
viewsHow to make a number with reset Random when restarting the program in python?
I created this system to generate a random number but I cannot reset the generated number every time the user selects play again, what would be the easiest way to solve this? import random…
-
0
votes0
answers25
viewsHow to simulate a result based on a given probability (e.g.: 8%) in javascript
I am mounting a result simulator of football game from some variables. The logic is as follows: Every minute both teams have a chance to score a goal. This probability is calculated using some…
-
0
votes1
answer23
viewsHow to compare a typed Jtextfield String with a randomized Imageicon in a package?
At the level of Random in a package of Imageicon of flags of countries how to compare if it was typed right the name of the flag of the country in a Jtextfield by the user? To randomize the images…
-
-1
votes3
answers3735
viewsGenerate random number between two numbers with Math.Random
I need to generate a random number between 1000 and 9999, found the following formula: (int) (min + Math.random() * (max+1)) Code: int numeroAleatorio = (int) (1000 + Math.Random() * 10000);…
-
-1
votes1
answer180
viewsRand() returning the same value even with the inclusion of srand((unsigned)time(NULL)
Why the function scrolled below always returns the same values when called multiple times, although Seed srand((unsigned)time(NULL)) has been initialized? #include <time.h> #include…
-
-1
votes1
answer124
viewsRandom Boolean Matrix in C++
good afternoon. I need to develop a Boolean matrix (almost a graph) random in C++, but I confess I used a lot of python, so I’m having a hard time getting started. But the focus of the question is,…
-
-1
votes1
answer68
viewsHow to perform a draw in python following a certain distribution, such as Gaussian or Maxwell-Boltzmann distributions?
My problem is to draw velocity values for a hydrogen molecule according to a Maxwell-Boltzmann distribution that will collide with an electron (with well-defined energy) and will split into two…
-
-1
votes1
answer136
viewsHow can I generate an Integer number in python using Random
I have the following code and I need the result to be an integer type number, but it is returning a random value (number or None) with random type (int or nonetype) from random import randint def…
-
-1
votes1
answer38
viewsHow do I open this function url in new tab in random link option
links = new Array("<www.google.com","https://www.youtube.com/","portal.trademap.com.br"); tamanho = links.length; nRand = Math.floor((Math.random() * tamanho…
-
-1
votes2
answers543
viewsHow to generate random numbers without rethinking in Java?
Something similar to the code below. Numbers in the Random range that do not repeat public void sorteiaCartelaB() { for (int i=0; i < b.length; i++) { b[i] = (int)(Math.random() * 60 + 1); for…
-
-1
votes1
answer243
viewsNameerror: name is not defined for initialized vector, how to tidy?
I’m making a program to calculate a certain time, with a probability of something happening and going wrong, but I’m getting Nameerror: name 'tempo_ida' is not defined variable h is defined as 0.…
-
-1
votes1
answer272
viewsHow to generate random value pairs
I wanted to generate 6 random values in 2 pairs for example 1 1, 2 2, 3 3 My code #include <stdio.h> #include <time.h> #include <stdlib.h> int vezes(int vetor[], int tamanho, int…
-
-1
votes1
answer1570
viewsRandom numbers within a vector in C
Hello would like to know what would be the ideal method to generate random numbers within a vector in C using the function Rand(), I get an error when I try to run the code below. follows the code:…
-
-1
votes2
answers1499
viewsBingo booklet in c
I was solving a college exercise on matrices and I ended up crashing. Ex: Build a program to automatically generate numbers between 0 and 99 from a bingo card. Knowing that each card should contain…
-
-1
votes1
answer52
viewsLinear split #python random_state Seed recognition failed
If random_state is not working, whenever I run into jupyter, it comes with a different precision.. Can anyone tell me the error? thanks in advance :D # estimador de aprovaçao baseado nas notas das…
-
-1
votes1
answer45
views -
-1
votes1
answer28
viewsI can’t change backgroundcolor using javascript to generate random colors
// randomColor() funcionando perfeitamente, gerando codigos hex entre "" function randomColor() { const hex = (Math.random()*0xFFFFFF<<0).toString(16); return `"#${hex}"`; } /* Em teoria…
-
-2
votes1
answer43
viewsFunction that makes the direct $foo[array_rand($foo)]
There is a native PHP function that does this without using array_rand in the array key? Although it is working well and is a simple stretch, it follows a simplified example of doubt: //Declarando…
-
-2
votes1
answer126
viewsDrawing of positions of a matrix
I need to create a function to draw within a matrix full of 0 with size n x n, four positions to modify the value only of these drawn positions.
-
-2
votes1
answer79
viewsInsert n points of a vector randomly into any matrix in java
I’m beginner in java, I was wondering if there is any function that would facilitate my life so that: having a vector of n positions filled with (pre-defined) numbers, distribute these numbers at…
-
-2
votes1
answer269
viewsPHP RANDOM NUMBERS EXCLUDING A NUMBER FROM THE LIST
Good afternoon, I need for a school work do a search of 7 numbers from 1 to 20, excluding a number from the list. Example: 7 Random numbers from 1 to 20, excluding the number 5 in the list. Return 7…
-
-2
votes1
answer60
viewsFirebase cloud firestore random query with specific user ID (Flutter)
I’m trying to randomly pull my data from the firestore cloud but I’m not getting it, does anyone know how to do it using ID? getQustoes(String simuladoId) async{ return await…
-
-2
votes1
answer64
viewsHow to calculate item price from random quantity of items sold?
I’m solving a problem, and one of the parts of it is calculating the price of an item based on the random amount of this same item sold. For example: 4 items were sold, so the method should…
-
-2
votes1
answer178
viewsProblem when deleting a number from a list!
After drawing a number from a list, I need to delete this number from my list. but the message "list index out of range" appears. My error is in the if line. or is there a better way to delete that…
-
-2
votes3
answers72
viewsHow to manipulate cells from a vector?
I created a program that fills a 10-position vector with random numbers between 0 and 20. Now I need to show a new manipulated vector, where each cell is the sum of itself and the previous cells.…
-
-3
votes1
answer136
viewsFunction within a Python dictionary
I am trying to perform an exercise where when creating a log file dictionary whose key is returned a random number between 100 and 9999 as enrollment as follows from datetime import date, time,…
-
-3
votes1
answer45
viewsShow result of a random array!
Good evening! I’m new to Javascript. I did a study of the word memorization type where I pick a certain number of words within an Array. The words are random and shown one by one. But I would like…
-
-4
votes2
answers556
viewsCreate a function that returns random number in C
Good afternoon, I have a project in language c to deliver, and it’s almost all ready, but the teacher said q we have to use a function that returns random number, but the random function I have to…