C++ Algorithm Prediction, need to predict 3 numbers [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
let's go straight to the facts.
I am studying for my own interest an eventual prediction algorithm for some unexistent lottery.
Let's say they roll out 3 numbers every day.
And those numbers are in range from 0 to 50.
I am asking, what would be the best approach to try to predict next 3 numbers knowing
all previous historic ones?
1. What i have
I have a list of 3 numbers from a range of {0,50} (integers)
<x0,y0,z0>
<x1,y1,z1>
<x2,y2,z2>
<x3,y3,z3>
Those numbers represent winning values of lottery.
2. What i need
I need to predict next 3 lottery numbers(possible WINNERS) by taking previous numbers into consideration
The order of the predicted numbers doesn't mater. It might be 1,2,3 or 3,2,1.
3. Question
Which approach / algorithm should i choose and why?
Super thanks for any help!

If the numbers you roll out are random, there is no way to make a prediction, as the next numbers are not linked in any way to the previous one. The most you can do is a guessing algorithm.

Related

SPOJ : BANKROB STATEMENT NOT CLEAR [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have recently started practicing graph theory problems.
I recently encountered this problem : BANKROB
Even after having gone through the problem statement several times, I am unable to understand how the given output for the sample cases has been computed.
I will be grateful to you, if you can please explain the sample test cases.
I'll explain one.
The first line says the city has ten crossroads (nodes) and 14 roads (edges). This helps you set up the problem, but it's not really necessary because you can tell that from the remainder of the input.
The second line says the robbers' goal is to get from node 1 to node ten. (your goal is to stop them).
The third through 16th lines each represent one road (edge.) Note that there are 14 edges and ten nodes as predicted by line 1. This information lets you create a graph.
To capture the robbers you need block (delete) the fewest possible nodes to separate node one from node ten. As it turns out in this case deleting node five and six will do the trick, so the answer to the question is 2, the number of crossroads you need to delete.
Now how to compute this? Well that's what you are studying, right?
To understand the solutions, it helps to visualize the data that's depicted. (Of course, you'll have the computer program do this entirely differently.) Based on the input, the roads basically look like this:
2 - 5 - 7
/ / \ \
1 - 3 - 6 - 8 - 10
\ / \ /
4 9
To cut off all paths from 1-10, just remove the choke points at 5 and 6.
However, to cut off from 5-10 (assuming all the roads are bidirectional), you can't just remove 7 and 8 - the robbers can backtrack from 5-3-6-9-10. So you have to cut off 7, 8 and 9.
Thus, for the first example, there are 2 places to cut off, but in the second, there are 3.

Generating relative Prime number of a user defined prime number? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I'm creating a program in C and I need to use relative prime numbers in sequence using an algorithm so that the user can select the first number in the sequence.
So far I have managed to create a function that creates relative prime numbers based on one or more inputted by a user but not one that finds the next smallest relative prime.
Either that or a way to produce the smallest relative prime number to a user defined number would be ideal.
Any ideas?
Also, I cannot get gcd to work so I created my own. Do i have to include a specific library other than math.h and stdio.h?
If you want to find the next smallest relative prime, then I think you need to loop from the user's inputted number (e.g. if users input 3, then you need to loop from 4), and then check whether that number is relatively prime.
To check whether two numbers are relatively prime, you can use gcd, and one very famous algorithm to do this is to use Euclid's algorithm. You don't need to include a specific library, it's basically just looping and doing modulo. Take a look at this link.

Obtaining an algorithm [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Let's say I have a variable a and b. Now I want to find a value for c such that the fraction a / c is a positive integer, and where c is as close to b as possible.
For example: a = 100 and b = 30.
In this case I want c to be 25; because a / c is an integer, and c is as close as b for which this holds.
Any ideas how I can program a function in C++ which does exactly this?
Find the factors of a. (search web for methods)
Scan resulting list for minimum difference vs b.
Is this a homework assignment? Either way, think about how you would solve this problem without writing any code. A good algorithm comes from a good design. Break the problem down into pieces and walk through some more examples. For example, how would you solve the problem of determining whether the division results in an integer value? Hint: There is a different operator you could use as opposed to division to achieve this easily. Now, how would you solve the problem of determining what number to start at for c in the algorithm? Do not write any code until you have the pseudocode figured out.

find combinations of numbers stored in an array and store those combinations in another array [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have an array of n size and I want to find combinations of k size. I don't just want to print those combinations but want to store those combinations in other arrays or any container. I read this creating all possible k combinations of n items in C++ but couldn't succeed in storing the combinations in other arrays. It is because I want to perform operations on those combinations. I'm seeking for any hints regarding this.
Thanks in advance.
Lacking a specific reason to choose something else, you probably want to store the results in a vector.
You can pre-compute the number of results quite easily -- N items taken K at a time will produce N!/K!(N-K)! total combinations.
At the risk of sounding condescending (which I don't intend) I'll point out that N! grows very quickly, so if the difference between N and K is very large, the result may easily be quite a bit larger than most computers can reasonably store.

Generate prime factors of a number [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm trying to write a function that given an Int greater than one gives a non decreasing list made of the prime factors (with repetition) of that number
Example: n = 12, the output should be [2,2,3]
I don't know where to start.
There are of course well know algorithms for what you want to do, so simple google search would really solve that.
However, I'd like to show you a simple thinking process that might be helpful in the future.
Since the factors have to appear in the ascending order, you might:
Start with the lowest prime (2).
Check if the number can be divided by it. If it can, do it and go back to 1.
If not, replace 2 with a next prime and go back to 2.
Now, it's obvious that the biggest prime you will ever check is the number you've started with. However, the basic multiplication axiom states that if a number can be divided by a:
n / a = b
Then it can also be divided by b! You can use that fact to further narrow the checking range, but I'll leave it to you to figure (or google) the upper bound.
Actual implementation is of course a part of your homework and thus supplying code wouldn't be a wise idea here. However, I don't think that stuff such as next_prime will be hard for you.