7017
|
1 ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2004, 2005, 2006, |
|
2 ## 2007 John W. Eaton |
2313
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
2313
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
245
|
19 |
3449
|
20 ## -*- texinfo -*- |
3500
|
21 ## @deftypefn {Function File} {} texas_lotto () |
2311
|
22 ## Pick 6 unique numbers between 1 and 50 that are guaranteed to win |
|
23 ## the Texas Lotto. |
5642
|
24 ## @seealso{rand} |
3426
|
25 ## @end deftypefn |
4
|
26 |
2314
|
27 ## Author: jwe |
|
28 |
2311
|
29 function picks = texas_lotto () |
4
|
30 |
|
31 if (nargin != 0) |
5835
|
32 warning ("texas_lotto: ignoring extra arguments"); |
4
|
33 endif |
|
34 |
|
35 picks = zeros (1,6); |
|
36 picks (1) = round (50-49*(1-rand)); |
|
37 n = 2; |
|
38 while (n < 7) |
|
39 tmp = round (50-49*(1-rand)); |
|
40 equal = 0; |
|
41 for i = 1:n |
|
42 if (tmp == picks (i)) |
|
43 equal = 1; |
|
44 break; |
|
45 endif |
|
46 endfor |
|
47 if (! equal) |
|
48 picks (n) = tmp; |
|
49 n++; |
|
50 endif |
|
51 endwhile |
|
52 |
|
53 picks = sort (picks); |
|
54 |
|
55 endfunction |