Post Reply 
Powerball Generator!
05-23-2024, 09:42 PM
Post: #1
Powerball Generator!
...who doesn't need a handy Powerball generator every now and then? Tongue

Picks 1st five numbers between 1-69, no-dupes, then picks the lucky Powerball number between 1-26! Uses the Alpha Register to format the output, a 1x6 array, and the fancy [FIND] function to keep duplicates in check!

00 { 127-Byte Prgm }
01 LBL "PBALL"
02 CLA
03 CLD
04 6
05 1
06 DIM "PBALL"
07 INDEX "PBALL"
08 1.00501
09 STO "CNT"
10 LBL 01
11 RCL "CNT"
12 1
13 STOIJ
14 RAN
15 100
16 ×
17 IP
18 STO 10
19 69
20 X<>Y
21 X>Y?
22 GTO 01
23 X≤0?
24 GTO 01
25 [FIND]
26 GTO 01
27 STOEL
28 ├" "
29 AIP
30 ISG "CNT"
31 GTO 01
32 LBL 02
33 6
34 1
35 STOIJ
36 RAN
37 100
38 ×
39 IP
40 STO 10
41 26
42 X<>Y
43 X>Y?
44 GTO 02
45 X≤0?
46 GTO 02
47 STOEL
48 ├" PB: "
49 AIP
50 AVIEW
51 END
Find all posts by this user
Quote this message in a reply
05-24-2024, 12:36 PM
Post: #2
RE: Powerball Generator!
If I run this program and win, do I have to split the winnings? Smile
Find all posts by this user
Quote this message in a reply
05-24-2024, 04:18 PM
Post: #3
RE: Powerball Generator!
Winner's choice! Tongue

(05-24-2024 12:36 PM)carey Wrote:  If I run this program and win, do I have to split the winnings? Smile
Find all posts by this user
Quote this message in a reply
09-13-2024, 04:11 AM
Post: #4
RE: Powerball Generator!
If I run this program will (Underlined), I win?
Fingers Crossed
Find all posts by this user
Quote this message in a reply
09-13-2024, 07:18 AM (This post was last modified: 09-13-2024 10:25 AM by Thomas Klemm.)
Post: #5
RE: Powerball Generator!
A bit shorter:
Code:
00 { 95-Byte Prgm }
01▸LBL "PBALL"
02 CLA
03 6
04 1
05 DIM "PBALL"
06 INDEX "PBALL"
07 1.005
08 STO 00
09▸LBL 01
10 RCL 00
11 1
12 STOIJ
13 69
14 XEQ 00
15 [FIND]
16 GTO 01
17 STOEL
18 ├" "
19 AIP
20 ISG 00
21 GTO 01
22 6
23 1
24 STOIJ
25 26
26 XEQ 00
27 STOEL
28 ├" PB: "
29 AIP
30 AVIEW
31 RTN
32▸LBL 00
33 RAN
34 ×
35 IP
36 1
37 +
38 END

Changes

The subroutine at LBL 00 generates a random number from 1 to X.
This makes the checks at the boundaries unnecessary.
I also use the register 00 instead of the global variable "CNT".
But that's more a matter of taste.
There's no obvious reason to store a result in the register 10 since it's never used.
So I removed it.
I also removed CLD since I don't think it's needed.
If the increment of a loop control number is 1, it can be omitted as it is the default.
Find all posts by this user
Quote this message in a reply
09-13-2024, 07:37 AM (This post was last modified: 09-13-2024 09:58 PM by Thomas Klemm.)
Post: #6
RE: Powerball Generator!
If the result in "PBALL" is no longer needed, it can be converted into a [ 5×1 matrix ] and the storage of the Powerball lucky number is no longer necessary:
Code:
00 { 81-Byte Prgm }
01▸LBL "PBALL"
02 CLA
03 5
04 STO 00
05 1
06 DIM "PBALL"
07 INDEX "PBALL"
08▸LBL 01
09 RCL 00
10 1
11 STOIJ
12 69
13 XEQ 00
14 [FIND]
15 GTO 01
16 STOEL
17 ├" "
18 AIP
19 DSE 00
20 GTO 01
21 26
22 XEQ 00
23 ├" PB: "
24 AIP
25 AVIEW
26 RTN
27▸LBL 00
28 RAN
29 ×
30 IP
31 1
32 +
33 END
I also replaced ISG with DSE.
Find all posts by this user
Quote this message in a reply
09-13-2024, 08:26 PM
Post: #7
RE: Powerball Generator!
My Texas Lottery HP 42S program:

LBL “LOT”
RAN
54
*
1
+
IP
STOP
GTO “LOT”
RTN

I like generating 1 number at a time for filling out my single ticket purchase each week. R/S for each additional number, R/S if I get a repeated number. On my HP 50, I programmed it to only present a non reapeating 1 row matrix of 6 numbers.

I would have the same chance of a win if I simply chose 1,2,3,4,5,6 !
Find all posts by this user
Quote this message in a reply
09-13-2024, 10:20 PM
Post: #8
RE: Powerball Generator!
(09-13-2024 08:26 PM)lrdheat Wrote:  On my HP 50, I programmed it to only present a non reapeating 1 row matrix of 6 numbers.

We can adapt the existing program very easily:
Code:
00 { 53-Byte Prgm }
01▸LBL "LOT"
02 6
03 STO 00
04 1
05 DIM "LOT"
06 INDEX "LOT"
07▸LBL 01
08 RCL 00
09 1
10 STOIJ
11 54
12 RAN
13 ×
14 IP
15 1
16 +
17 [FIND]
18 GTO 01
19 STOEL
20 DSE 00
21 GTO 01
22 RCL "LOT"
23 END
Find all posts by this user
Quote this message in a reply
09-14-2024, 11:27 AM
Post: #9
RE: Powerball Generator!
(09-13-2024 08:26 PM)lrdheat Wrote:  ... On my HP 50, I programmed it to only present a non repeating 1 row matrix of 6 numbers.

I would have the same chance of a win if I simply chose 1,2,3,4,5,6 !

Indeed the chance of winning is minuscule but at least we get some entertainment by programming our HP's Smile

This is my Powerball program for the HP 50 using ListExt and LSORT. It returns a list of 5 numbers in the range 1..69 on level 2 and a number in the range 1..26 on level 1. For MegaMillions (the other US multi-state lottery) replace the 69 with 70 and replace the 26 with 25.

Code:

\<< 69 LSEQ             @ List of numbers 1..69
    LSHUF               @ Shuffle list
    5 LTAKE LSORT       @ Take first 5 numbers and sort
    RAND 26. * IP 1. +  @ Random integer in range 1..26
    R\->I               @ Convert to exact integer for display
\>>
Find all posts by this user
Quote this message in a reply
09-14-2024, 12:41 PM
Post: #10
RE: Powerball Generator!
Now if someone could just come up with a program that generates the winning numbers Smile

A1

HP-15C (2234A02xxx), HP-16C (2403A02xxx), HP-15C CE (9CJ323-03xxx), HP-20S (2844A16xxx), HP-12C+ (9CJ251)

Find all posts by this user
Quote this message in a reply
09-14-2024, 03:13 PM (This post was last modified: 09-14-2024 03:14 PM by C.Ret.)
Post: #11
RE: Powerball Generator!
(09-14-2024 12:41 PM)AnnoyedOne Wrote:  Now if someone could just come up with a program that generates the winning numbers

It is possible, but it requires a lot more calculations than what I see in the codes above.

But if by chance you have an HP-41C (or something perfectly compatible), then there is still time to play the Power Balls that this program displays:

[Image: attachment.php?aid=13947]

P.S.: Know that I will only take a tiny fraction of the winnings, but for all the players who win by using my code.


Attached File(s) Thumbnail(s)
   
Find all posts by this user
Quote this message in a reply
09-14-2024, 03:45 PM
Post: #12
RE: Powerball Generator!
(09-14-2024 03:13 PM)C.Ret Wrote:  P.S.: Know that I will only take a tiny fraction of the winnings...

Would 10% be enough? Smile With payment after I receive the winnings!

A1

HP-15C (2234A02xxx), HP-16C (2403A02xxx), HP-15C CE (9CJ323-03xxx), HP-20S (2844A16xxx), HP-12C+ (9CJ251)

Find all posts by this user
Quote this message in a reply
09-14-2024, 04:43 PM
Post: #13
RE: Powerball Generator!
(09-14-2024 03:13 PM)C.Ret Wrote:  But if by chance you have an HP-41C (or something perfectly compatible), then there is still time to play the Power Balls that this program displays:

A bit shorter:
Code:
01▸LBL "SEPT14"
02 "11,27,31,36,67:"
03 "├11"
04 AVIEW
05 END
Find all posts by this user
Quote this message in a reply
09-14-2024, 06:40 PM
Post: #14
RE: Powerball Generator!
(09-13-2024 08:26 PM)lrdheat Wrote:  I would have the same chance of a win if I simply chose 1,2,3,4,5,6 !

Back when I was a teenager, I said this same thing to an uncle of mine in upstate New York, when they had a state lottery and I wanted to buy a ticket. My uncle had been around (horses, poker, other types of gambling), and he said that I was incorrect in my assertion (NOT the words he used). I didn’t believe him. Many years later, I did some research on conditional probabilities (conditional because you are choosing a set of numbers based on what you have already chosen, in order for them to be so close to each other). Turns out he was correct: some sets of lottery numbers are less likely to occur than others.

The lessons: always listen to your elders, because you might learn something. Also, math is interesting.

DGM
HP25, HP55, HP27S, HP18C, HP19C, HP16C, HP67, HP28, HP41, HP75, HP71, HP48C, HP49G, HP30B, HP50G, HP Prime (not necessarily in that order)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)