I have a list of employee names, and I want to extract a random pair without picking the same names too frequently. I was thinking of complex ways to add a weight metric that increases for each time a name is picked but was hoping the fine folks here might have a better suggestion of how to do this?
jeudi 31 août 2023
How do I append a dictionary with random prices from original starting point
Imagine I start with 5 stocks
dict1 = {'BA':57.0, 'QQQ':545.5, 'AAPL':150, 'SPX':245.5, 'JPM':150, }
how can I increase the dictionary to hold say 500 random prices for each asset from the original starting point?
so I get; BA: 57.0, 58.2, 59.6, 59.9 .........
Many thanks
How to display a random photo from the gallery without picking it in flutter?
I want to create a flutter app that shows me a random photo from the phone gallery, I don't want to choose it like with the image picker, I would like a button that loads me a random image.
I've tried to create a list that contains every image from the phone but i can't make it work.
mercredi 30 août 2023
Blender make hair length vary in size, but keep "origin point" to be face of object
So in blender I am making a rug/carpet without thickness, so it's only one face, and when I add hair particles (and change some settings) it looks fine, however each hair is of a certain length like so:
I tried changing the random setting under Children -> Roughness, and although that does solve the same-length problem, it brings on a new one, the hairs can start from below my face.
To display random questions from selected exam
$query = mysqli_query($database, "select \* from questions where e_category='$\_SESSION\[categories\]' && question_no='$que_no' order by rand() ");
Here, the problem is that I want to display a random question from the selected exam.
Exams:-
(1) PHP (2) C language (3) Java
e.g. If the user selects PHP (exam), but cannot display random questions due to the above query, they will also verify e_category='$\_SESSION\[categories\]'
No Warring appears.
$query = mysqli_query($database, "select \* from questions where question_no='$que_no' order by rand() ");
The problem arises when e_category='$\_SESSION\[categories\]' is not used, as it displays all exam questions, not just a specific exam.
How do i detect the randomly generated number
i made code to randomly generate weighted numbers and whenever i tell it to break when it generates a certain number it doesnt do it code:
import random
while True:
numberList = [0, 100, 250, 500, 1000, 2000, 5000, 10000, 25000, 50000, 75000, 100000, 250000, 500000, 750000, 1000000, 5000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 10000000000000, 100000000000000, 1000000000000000]
tapped = (random.choices(numberList, weights=(1, 1/25, 1/250, 1/500, 1/1000, 1/2000, 1/5000, 1/10000, 1/25000, 1/50000, 1/75000, 1/100000, 1/250000, 1/500000, 1/750000, 1/1000000, 1/5000000, 1/10000000, 1/100000000, 1/1000000000, 1/10000000000, 1/100000000000, 1/1000000000000, 1/10000000000000, 1/100000000000000, 1/1000000000000000), k=100))
print(tapped)
if tapped == 500:
break
i tried adding a while true command, i tried using
if tapped = 500:
print('you got a 500')
and also
if tapped = 1/500
print('you got a 500')
and both dont work (1 being from the list and the other from the weights) so im not sure what else to try
mardi 29 août 2023
randomize contents of tableview cells
I what I have below is the code that loads string from core data named title. What I would like to do is have a func that randomizes the order of the way all the names are displayed on the tableview cell every time the button is pressed. If possible also save the new order.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let song = songs[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "songCell", for: indexPath) as UITableViewCell
cell.textLabel?.text = song.title
return cell
}

