Product algorithm problem

Asked 2 years ago, Updated 2 years ago, 49 views

With a 0.006% chance, The 2nd place with 0.03% chance The 3rd place with a 0.2% chance The rest is blank

I don't know how to implement this product when there is a product like this.

Also, how can I implement it to reduce the margin of error without errors?

Please give me a hint, search keyword, reference link, or blog.

algorithm

2022-09-22 21:44

2 Answers

Place numbers from 1 to 100000 in the list or DB. The randomly selected values are then thrown to the user one by one, and the selected numbers are displayed as used numbers. If you use the list, you can take it off the list, and if you use the DB, you can mark it in the column. There must be many ways.

And

Wouldn't this work?


2022-09-22 21:44

Put 1 in an array of 100000, 6 in 2, 30 in 3, 200 in a row, and mix the rest with the default value of 0, shuffle function, etc. If a random number is selected from 1 to 100000 and the number is selected as the key value of the array, it is 1st place, 2nd place on 2nd place... I've implemented it in this way and used it for events, but there was not much error.


2022-09-22 21:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.