Welcome Guest
You last visited January 23, 2017, 9:37 am
All times shown are
Eastern Time (GMT-5:00)

# Need help with a algorithm

Topic closed. 11 replies. Last post 10 months ago by RL-RANDOMLOGIC.

 Page 1 of 1

United States
Member #59354
March 13, 2008
4093 Posts
Offline
 Posted: March 29, 2016, 8:44 am - IP Logged

I am working on a tool to calculate the date for the next drawing.  I start with converting the last

7 games from Georgian to Julian format.  Next I subtract the second form the first then the third

from the second etc..  giving me the number of days between games.  These values are stored in

the string NBD\$.  This works well enough for most games but lets say that a game draws 5 days a

week MTWTF and skips Sat and Sun.  This would create a string something like "1111311"  where

when the 5th value in the string was a "3" then I would add three days to get the next date.  I

could just chart out all the possible combinations but think it can be done with a algorithm.

The algorithm needs to be able to calculate the number of days to the next drawing from the 7

digit string regardless of drawing day sequence.  Examples MWF,  STF, etc...

P.S.  It would be easy to store settings for each game but I don't want to go that route.  Any help

would be greatly appreciated.  I can increase the number of variables in the string if needed.

RL

Sample of what I don't want to use.

IF NBD\$="1111111" THEN julian# = julian# + 1  'EVERY DAY
IF NBD\$="7777777" THEN julian# = julian# + 7  'ONCE PER WEEK
IF NBD\$="3434343" THEN julian# = julian# + 4  'TWICE A WEEK
IF NBD\$="4343434" THEN julian# = julian# + 3  'TWICE A WEEK

Working on my Ph.D.  "University of hard Knocks"

I will consider the opinion that my winnings are a product of chance if you are willing to consider

they are not.  Many great discoveries come while searching for something else

Trump / 2016 & 2020

United States
Member #172977
February 11, 2016
515 Posts
Offline
 Posted: March 29, 2016, 10:28 am - IP Logged

I am working on a tool to calculate the date for the next drawing.  I start with converting the last

7 games from Georgian to Julian format.  Next I subtract the second form the first then the third

from the second etc..  giving me the number of days between games.  These values are stored in

the string NBD\$.  This works well enough for most games but lets say that a game draws 5 days a

week MTWTF and skips Sat and Sun.  This would create a string something like "1111311"  where

when the 5th value in the string was a "3" then I would add three days to get the next date.  I

could just chart out all the possible combinations but think it can be done with a algorithm.

The algorithm needs to be able to calculate the number of days to the next drawing from the 7

digit string regardless of drawing day sequence.  Examples MWF,  STF, etc...

P.S.  It would be easy to store settings for each game but I don't want to go that route.  Any help

would be greatly appreciated.  I can increase the number of variables in the string if needed.

RL

Sample of what I don't want to use.

IF NBD\$="1111111" THEN julian# = julian# + 1  'EVERY DAY
IF NBD\$="7777777" THEN julian# = julian# + 7  'ONCE PER WEEK
IF NBD\$="3434343" THEN julian# = julian# + 4  'TWICE A WEEK
IF NBD\$="4343434" THEN julian# = julian# + 3  'TWICE A WEEK

Maybe try a computer programming thread?

United States
Member #59354
March 13, 2008
4093 Posts
Offline
 Posted: March 29, 2016, 12:00 pm - IP Logged

Last time I looked LP does not have a programming board, sure there are plenty of programming sites

but asking for help with something lottery related won't get a reply unless it's full of negative remarks.

There are several here that have the skills and like working on these sort of problems.  What I ask here

falls well within the confines of the math forum.  May take a week or so for someone interested to take

a stab at it but I have plenty of time.  I write algorithms for this kind of stuff all the time but this one is

kicking my butt, not as simple as it looks, or maybe it is.   I may have it figured out already by reducing

or creating a second NBD\$ string to include just the different values instead of all 7 digits.  The sum of

the different values must be <= 7.  I am thinking two lines of code max and maybe it can be done with

one.

RL

Working on my Ph.D.  "University of hard Knocks"

I will consider the opinion that my winnings are a product of chance if you are willing to consider

they are not.  Many great discoveries come while searching for something else

Trump / 2016 & 2020

New Jersey
United States
Member #17843
June 28, 2005
51218 Posts
Offline
 Posted: March 29, 2016, 12:08 pm - IP Logged

Check the Date for the Day of the Week. If the Drawing are Mon & Thu: If it's Mon add 3 to the Date, If it's Thu add 4 to the Date.

A mind once stretched by a new idea never returns to its original dimensions!

United States
Member #59354
March 13, 2008
4093 Posts
Offline
 Posted: March 29, 2016, 12:11 pm - IP Logged

Raven

That works for games with two draws a week but I need something that will catch everything.

RL

Working on my Ph.D.  "University of hard Knocks"

I will consider the opinion that my winnings are a product of chance if you are willing to consider

they are not.  Many great discoveries come while searching for something else

Trump / 2016 & 2020

United States
Member #59354
March 13, 2008
4093 Posts
Offline
 Posted: March 29, 2016, 12:13 pm - IP Logged

I have a method if using days but in my newest program I cut the day of the week out of the database entries.

I do have a program that can calculate the day of the week from the Julian date, I guess that would solve my

problem but would like to use the new method.

RL

Working on my Ph.D.  "University of hard Knocks"

I will consider the opinion that my winnings are a product of chance if you are willing to consider

they are not.  Many great discoveries come while searching for something else

Trump / 2016 & 2020

United States
Member #59354
March 13, 2008
4093 Posts
Offline
 Posted: March 29, 2016, 12:22 pm - IP Logged

If I reduce the NBD\$ string to just show the different values then the code below will catch most games.

julian#=julian#+val(right\$(NBD\$,1))

This may work for them all,  I have to think about it some more.

RL

Working on my Ph.D.  "University of hard Knocks"

I will consider the opinion that my winnings are a product of chance if you are willing to consider

they are not.  Many great discoveries come while searching for something else

Trump / 2016 & 2020

Winner
South Carolina
United States
Member #155844
May 31, 2014
1926 Posts
Offline
 Posted: March 29, 2016, 1:36 pm - IP Logged

Add Dr. Miracle to title. It'll get a lot of views.  And comments.

my name Lil Darryl   you got some Milk

mid-Ohio
United States
Member #9
March 24, 2001
19903 Posts
Offline
 Posted: March 30, 2016, 12:59 pm - IP Logged

I used the following lines in a BASIC program to convert DATE\$ to a day, you should be able to covert any future DATE\$ into a day also with a few modifications.

1 DIM DAY\$(6), MONTH\$(12)
2 DATA "SATURDAY","SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"
3 FOR X = 0 TO 6: READ DAY\$(X): NEXT X
4 FOR X = 1 TO 12: READ MONTH\$(X): NEXT X
5 MO = VAL(LEFT\$(DATE\$, 2)): DA = VAL(MID\$(DATE\$, 4, 2)): YRS = VAL(RIGHT\$(DATE\$, 4)): A = INT((14 - MO) / 12): Y = YRS - A: M = MO + (12 * A) - 2: D = (DA + Y + INT(Y / 4) + INT(Y / 100) - INT(Y / 400) + INT((31 * M) / 12))
6 DD = D - 7: D = DD: IF DD >= 7 THEN 6 ELSE PRINT DAY\$(DD-1); " -  "; MONTH\$(MO); STR\$(DA); ","; YRS

* you don't need to buy more tickets, just buy a winning ticket *

Tanhauser Gates
Holy See (Vatican City State)
Member #139281
February 18, 2013
192 Posts
Offline
 Posted: March 30, 2016, 6:54 pm - IP Logged

Add Dr. Miracle to title. It'll get a lot of views.  And comments.

United States
Member #59354
March 13, 2008
4093 Posts
Offline
 Posted: March 31, 2016, 4:43 am - IP Logged

I used the following lines in a BASIC program to convert DATE\$ to a day, you should be able to covert any future DATE\$ into a day also with a few modifications.

1 DIM DAY\$(6), MONTH\$(12)
2 DATA "SATURDAY","SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY","JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE","JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"
3 FOR X = 0 TO 6: READ DAY\$(X): NEXT X
4 FOR X = 1 TO 12: READ MONTH\$(X): NEXT X
5 MO = VAL(LEFT\$(DATE\$, 2)): DA = VAL(MID\$(DATE\$, 4, 2)): YRS = VAL(RIGHT\$(DATE\$, 4)): A = INT((14 - MO) / 12): Y = YRS - A: M = MO + (12 * A) - 2: D = (DA + Y + INT(Y / 4) + INT(Y / 100) - INT(Y / 400) + INT((31 * M) / 12))
6 DD = D - 7: D = DD: IF DD >= 7 THEN 6 ELSE PRINT DAY\$(DD-1); " -  "; MONTH\$(MO); STR\$(DA); ","; YRS

RJ

I have something similar that I used in the past.  My new databases don't include the day of the week

but that's not a real problem as my Julian/Gregorian sub calculates them.  I spent quite a bit of time on

the sub for the purpose of speeding up the live update option as my new program includes both daily

and number games.  I think I have nine games loaded and the live updater takes several seconds to

update all 9 games.  There are several options I could use but want to make it as efficient as possible.

The little snippet of code julian#=julian#+val(right\$(NBD\$,1)) works well for the games I have loaded

but does not cover every possibility out there.

RL

Working on my Ph.D.  "University of hard Knocks"

I will consider the opinion that my winnings are a product of chance if you are willing to consider

they are not.  Many great discoveries come while searching for something else

Trump / 2016 & 2020

United States
Member #59354
March 13, 2008
4093 Posts
Offline
 Posted: April 1, 2016, 3:31 pm - IP Logged

Solved,  Since the sum of the days from one draw to the next will equal 7 in a weekly cycle all I had to

do was add a End IF statement when the sum equaled 7.  The value that brings the sum to 7 will be the

number of days to the next drawing.  It did not take a algorithm but I thought others might find this info

useful as it should work with any game day drawing format.

RL

Working on my Ph.D.  "University of hard Knocks"

I will consider the opinion that my winnings are a product of chance if you are willing to consider

they are not.  Many great discoveries come while searching for something else

Trump / 2016 & 2020

 Page 1 of 1