cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

Lottery

MikeArmstrong
5-Regular Member

Lottery

Since we dream about winning the lottery i have decided to post a copy of one of my collegues Mathcad sheet which checks how many numbers he has in each row.

I am assuming this can be done a lot simpler, anybody got any ideas?

Regards

Mike
21 REPLIES 21

>...checks how many numbers he has in each row<<br> __________________________

I don't understand that part. If you start having random in each vectors, get simpler from ScrambleArray(M). I toke the times table to demonstrate the shuffling by pressing F9 on "ScrambleArray(M)". Get inspired, do more and be a winner. I tend not to read more than it is readable, on the simple ground that except for very new Mathcaders, there is so much coming down the collab, some don't collect and come back with perpetual questions already replied.

jmG
MikeArmstrong
5-Regular Member
(To:ptc-1368288)

The numbers indicated by the check are to be inputted by the user, these are then checked against the numbers indicated by rows which are the bought lottery tickets.


The sheet then goes on to calculate the number of matching numbers for each array.

I also don't understand how to use the extra function at the bottom, i understand you posted it to help.

Regards


Mike

>I also don't understand how to use the extra function at the bottom <<br> ________________________

Which sheet ?

You are replying to nobody. Most of the times visitors get several replies very quick/simultaneously and if you don't address your reply, the readers fly in the blue. Hope some collab can spare time in lottery, I don't. You can simply return the sheet you have problem and detail the problem in the sheet itself.

jmG
MikeArmstrong
5-Regular Member
(To:ptc-1368288)

I have nearly fixed the worksheet see attached, all i need to work on now is to make the program run for every row.

Regards

Mike

On 10/24/2009 1:15:59 PM, Armo wrote:
>All i
>need to work on now is to make
>the program run for every row.

You have a couple of options. One is to augment all the rows (which, rather confusingly, are column vectors) into a matrix and then loop through the columns. The other (I think easier) option is to change all the literal subscripts to vector subscripts so that you have a nested vector, then loop through the elements of the vector.

Richard


MikeArmstrong
5-Regular Member
(To:RichardJ)

Cheers Richard I'll try and work on looping through the vectors.
Regards

Mike

On 10/25/2009 3:31:45 AM, Armo wrote:
>Cheers Richard I'll try and work
>on looping >through the vectors.
>Regards
>
>Mike
___________________________________

I think, "Eureka" for THAT particular lottery.

jmG



On 10/24/2009 1:15:59 PM, Armo wrote:
>I have nearly fixed the
>worksheet see attached, all i
>need to work on now is to make
>the program run for every row.
>
>Regards
>
>Mike
_________________________________

Don't understand again :

You seem you want to subtract "check",
but subtract from what: the cols or the rows ?

jmG



MikeArmstrong
5-Regular Member
(To:ptc-1368288)

Yes that is correct, then the number of zeros in each coloumn is number which match to the check input.



Regards



Mike

Calculating the number of matches can be done with a simple function. To iterate through all the rows you need to put them all into a single data structure (Mathcad has no indirect addressing and so cannot loop through distinct names) as per Ricahrd's post.
__________________
� � � � Tom Gutman
MikeArmstrong
5-Regular Member
(To:TomGutman)

Cheers for the help guys, once i crack it i will post my worksheet.

Regards

Mike

Success.

Regards

Mike

On 10/25/2009 7:00:12 AM, Armo wrote:
>Success.
>
>Regards
>
>Mike
___________________________

Nothing works yet !
If you keep scrambling 'Q', you always get 4 match. Also you must be able to locate the matching numbers within Q. In the PTC library, if still there, you will find the "New Jersey lottery" by Steven Finch [Former Mathsoft mathematician].

jmG
MikeArmstrong
5-Regular Member
(To:ptc-1368288)

Why scramble Q, they are set numbers.



The numbers in the check vector will change.



Regards



Mike

On 10/25/2009 8:53:44 AM, Armo wrote:
>Why scramble Q, they are set
>numbers.

The numbers in the
>check vector will
>change.

Regards

Mike
____________________

You are very hard to read because too many empty lines. Then don't scramble Q, just scramble "check". You still have to extract the matching numbers.

jmG



There is no need to go to the trouble of converting the nested vector that you originally create to a matrix. The nested vector can be used directly, and is more flexible.

If you absolutely want a matrix (for whatever reason) I would suggest defining it that way originally by changing your rown's to row<n>'s (using the column select operator).
__________________
� � � � Tom Gutman
StuartBruff
23-Emerald II
(To:TomGutman)

On 10/25/2009 2:16:27 PM, Tom_Gutman wrote:
== There is no need to go to the trouble of
converting the nested vector that you originally
create to a matrix. The nested vector can be used
directly, and is more flexible.

It's also a good subject for cat skinning .. not so
much because the other ways are more efficient but
simply to play around with different ways of
operating on the data.

Stuart

On 10/25/2009 4:38:09 PM, stuartafbruff wrote:
>On 10/25/2009 2:16:27 PM, Tom_Gutman
>wrote:
>== There is no need to go to the trouble
>of
>converting the nested vector that you
>originally
>create to a matrix. The nested vector
>can be used
>directly, and is more flexible.
>
>It's also a good subject for cat
>skinning .. not so
>much because the other ways are more
>efficient but
>simply to play around with different
>ways of
>operating on the data.
>
>Stuart
_____________________________________

Simply that Tom didn't complete the project. Your XX(1542) is so messy and goes nowhere to interest either a Mathcader or an ordinary reader.



jmG

On 10/25/2009 9:23:26 PM, jmG wrote:
== Simply that Tom didn't complete the project.

I wasn't criticizing Tom's worksheet; I was simply
commenting that the subject offers a variety of
ways to look at solving a problem.

== Your XX(1542) is so messy and goes nowhere to
interest either a Mathcader or an ordinary reader.

I'm afraid I view this as the kind of remark that
may cause some people to think the Cirque Du
Mathcad is in town - it's just a negative remark
with no substance behind it.

Different styles of working appeal to different
people. You like using range variables and
creating functions that have a dependency on
previously defined range variable. I don't,
preferring a more functional approach that
minimizes dependencies; this may make my
worksheets longer-winded in some areas, but
compensates for it by more efficient re-usability
and compactness later in a worksheet.

An example is the 'Library' of functions embedded
within the Areas at the top of the worksheet. The
presence of these functions allowed me to quickly
drop in a general-purpose row/column summation function, and convert a nested vector into a
matrix, rather than rewrite the wheel. You may
not find such an approach to be useful, but I do.

In terms of content, you've gone for a
representation that lists the matches alone and
the count seperately, whereas I prefer to show
where the matches occur and return a composite
data structure showing both matches and count - as
stated, this can make it easier for subsequent
analysis or export. I also showed how to analyse
the results if the original data were in matrix
form, a distinct possibility if the data was
imported from, say, Excel.

Of course, one other area where I will deeply
offend you is that playing around with a problem
can often suggest some new feature or enhanced
capability. For example, I would have liked to
write out the results table with the non-matching
results still present but the matches and counts
highlighted.

I don't mind the fact that you think my worksheet
is messy and useless, Jean, but it would be nice
to have some positive criticism (ie, why you think
so) rather than empty statements.

The only point you have is about the location of the occurrence(s), for a loser in lottery ! The project could extend to the idea that Mike might want to design a "lottery". I'm sure he will benefit from the consolidated collaboration he was offered.

Thanks for reading/checking.

jmG
MikeArmstrong
5-Regular Member
(To:TomGutman)

Tom that looks miles better cheers.

Stuart & jmG thanks for taking the time to show the different ways that the results can be handled and displayed. Of course there a multiple ways a cat can be skinned.

Gives the user multiple options.


Regards

Mike
Top Tags