Choosing random event with different probabilities [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need help creating a general function or pseudocode that chooses a single event from a group events who all have different probabilities.
Ex.
event 1 = 45%
event 2 = 15%
event 3 = 50%
event 4 = 35%
event 5 = 50%

The simplest solution would be to sum and normalize the ranges (as an example, the sum of the values is 195, your first event would get the range [0, 45/195=0.23[, the second one [0.23, 0.23+0.076=0.31], and so on), then extract a number from [0,1[ and look to what range it belongs.

Related

Regex: Is the input date within the next two weeks? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 days ago.
Improve this question
The input is a person's date of birth (e.g. 22/Feb/78).
Using a regular expression, I want to find out if the person has their birthday within the next two weeks from now.
So I want to know if February 22nd (the year needs to be ignored, of course) is within the next 14 days from now. Today is February 13th, so the correct result would be: yes.
Is there a way to do this?
I tried ChatGPT but it was not available for me due to capacity reasons.
So I tried https://www.autoregex.xyz/ and entered "Is the date (mm.dd.) within the next two weeks?".
Result:
\d{2}\.\d{2}\.\s*(?:[0-9]|1[0-9]|2[0-9]|3[0-1])\s*(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s*(?:19|20)\d{2}
But it did not work.

Stepfunction map with condition [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Is there is any possibility to run the was step function map Iterator based on the condition Am going to invoke the lambda and based on the result I have to choose the input item of the iteration meaning if there is an array of 0-3 items once the first item executes with lambda then based on the result it should execute 1st index or 2nd index item.
The other option is to create a while loop like this:
Set a variable to track your index (pos = 0)
Do whatever you want to do inside your iteration also you could use some condition, if you want to process each item conditionally
increase your index ( pos++)
If your index is less that your items count go to step1.
This way you have access to the result of previous iteration, so you can fine tune your condition.

How to find which word contained within sentence [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a list of suppliers in a column (column A) in Google Sheets, and I have transactions list from my bank. Each item description (column B) in bank transactions list is a mess of the supplier name and numbers. For each item description I want to find a matching supplier name from the suppliers list. How can I do this?
try:
=ARRAYFORMULA(IFNA(REGEXEXTRACT(LOWER(B2:B),
LOWER(TEXTJOIN("|", 1, SORT(A2:A, 1, 1))))))

Creating a program that will tell a user what month it will be x months from now ( C++) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am completely stuck / lost. I need to write a program that will tell a user what month it will be in x amount of months from March. I need a point in the right direction to start me off.
I am still learning c++, so I'm trying to keep it as basic as possible. Any help will be a lifesaver !!
Example:
User enters 6, the result would display September.
User enters 239, the result would be February.
Just get the input % 12 and add it to March . For example in case of 239 :
239 % 12 = 11 ---> 11 months after march is february.
Logic : there are 12 months in an year. So march will again come in a cycle of 12.
Now so n/12 years will pass as it is. So after n/12 years you will be again at march. After that only n%12 months remain. So you can add them up directly to get your answer.

What can I use as data structure for Ranking in C++? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have data-set with these attributes:
UserID (int)
Group (int)
Score (int)
I want to evaluate ranking:
All Ranking by score
Group ranking in user's group by score
What should I do?
Use a linear array of structure which contains the data set and an array of size equal to the number of groups.
Sort the structure array based on score to get overall rank and use the second array to keep count of the number of structures of each group to assign group rank to each data set.
struct user
{
int userID , group , score;
int totalRank , groupRank;
}
Take arrays as:
user list[100];
int groupCount[10]; //Assuming there will be maximum 10 groups