Hash Table ( Data Structure ) [closed] - c++

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 6 years ago.
Improve this question
Use the following data when building tables.
32, 64, 8, 23, 60, 47, 62, 59, 15, 29
Ans:
32-2
64-4
8-8
23-8
60-0
47-2
62-2
59-14
15-0
29-14
I understand the answers up to 23 because I can figure out how the answer is 8. My question is, how is 23%10 = 8? This also goes for the answers of 47, 59, and 29.

If it is even, calculate % 10
If it is odd, calculate % 15
This is the pattern that you should follow. Next time clarify and explain clearly to get better responses.

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.

Clojure adding up keys in map [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 2 years ago.
Improve this question
Hey guys I'm playing around with a personal project I'm making as I'm new to clojure, its measuring football players performance.
This is the a partial example of the data I am using
:Performance 2019, :Day 1, :CR7 43, :Messi -2,
:Performance 2019, :Day 2, :CR7 12, :Messi 6,
:Performance 2019, :Day 3, :CR7 -11, :Messi 4,
:Performance 2019, :Day 4, :CR7 4, :Messi 32,
:Performance 2019, :Day 5, :CR7 21, :Messi -48,
The years in the data that I'm using go back to around 2010 and the days go upto 31, It would have been to much to put here so I included a sample. The numbers next to the players CR7 and Messi are personal performance indicators that I have given them. There's less players for now but over time I will add more.
Ive stored the data in a zipmap like so
(zipmap [:Performance :Day :CR7 :Messi
My question is how would you add up all the ratings for each player from the 31 days and work out their highest performing year, bare in mind the years go back to 2010-2020
You can make the problem more tractable by re-shaping the data to avoid mixing program-logic keys (:Performance and :Day) with data ("CR7" and "Messi" for now).
For example, you could state the database as a list of assertions:
[{:performance 2019 :day 3 :player "CR7" :rating -11}
{:performance 2019 :day 3 :player "Messi" :rating 4}
...]
Conveniently, you could source that data from a CSV file, making it easy to add facts about more players without revising the column structure of the data.
Computationally, you face two challenges. 1) For each player, for each year, sum the ratings. 2) For each player, harvest the year of the highest rating.
The result of challenge No.1 is probably a map of player to (map of year to sum of ratings). Like this:
{"CR7" {2018 44, 2019 73, 2020 81}
"Messi" {2018 32, 2019 11, 2020 6}}
To get there, you need to transform a list (of assertions) to a single thing (a map of player to years' ratings). A Clojure standard-library function that transforms a list to a single thing is reduce. With each input record (one year, one day, one player, one rating) you update the reduction by adding the rating to one counter. The standard-library function update-in will be just the ticket.
For challenge No.2, you want the year with the highest rating. The standard-library function max-key could be helpful there.

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.

Choosing random event with different probabilities [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 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.