Problem 1713. Can you beat the lottery?
Well this one you may not get every time, but it is a lottery! Here is the code that generates the lottery numbers (you can try to use it to your advantage if you can):
check = 1;
while check == 1
D1 = round(rand(1,1)*5+1);
D2 = round(rand(1,1)*5+1);
D3 = round(rand(1,1)*5+1);
draw = sort([D1 D2 D3]);
if size(unique(fn), 2) == 3
check = 0;
end
endSo "draw" is the draw that is made. It is made up of 3 numbers between 1 and 5. Note that the numbers do not repeat. SO an example of an input is:
lottery = [4 3 5];
Now the odds are 1 in 10 (or at least that is the total combinations that can occur), so if you get it exactly you win! (you win the correct answer...)
Good luck, and please play responsibly...
Solution Stats
Problem Comments
-
2 Comments
You need to test with more than one number. Many attempt (and succeed) with a static vector solution until they are lucky.
When i run the program it says fn is undefined. Please explain
Solution Comments
Show commentsProblem Recent Solvers48
Suggested Problems
-
Return the largest number that is adjacent to a zero
5508 Solvers
-
Back to basics 8 - Matrix Diagonals
960 Solvers
-
Convert a numerical matrix into a cell array of strings
2365 Solvers
-
Create a matrix X, where each column is a shifted copy of the vector v
221 Solvers
-
Find Index of maximum Value and maximum Value of a vector
167 Solvers
More from this Author17
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!