Full Wheel Guarantee ... Calculations for any full wheel

thornc

Member
Here's a simple python script to calculate/display any full wheel/system!


Code:
#!/usr/bin/env python
# Generates combinations
import sys, time

def totalCombs(maxnum,numline):
	fact = lambda n:n-1 + abs(n-1) and fact(n-1)*long(n) or 1
	return ( fact(maxnum)/(fact(numline)*fact(maxnum-numline)) )

def xuniqueCombinations(items, n):
    if n==0: yield []
    else:
        for i in xrange(len(items)):
            for cc in xuniqueCombinations(items[i+1:],n-1):
                yield [items[i]]+cc

def genCombs(maxnum,numline):
	rg = range(1,maxnum+1)
	for line in xuniqueCombinations(rg,numline):
		print StringSequence(line)


def StringSequence(seq):
	size = len(seq)
	outText = ""
	if size == 0:
		pass
	elif size == 1:
		outText = str( seq[0] )
	else:
		outText = str( seq[0] )
		for item in seq[1:]:
			outText += " " + str( item )
	return outText
    
def Usage(name):
	print \
"""Generates combinations.
%s <Maximum Number> <Numbers per line> <output file>
Example:
%s 10 3 outfile.txt
"""%(name,name)

def Start(combs):
	print "Starting for %d combinations"%(combs,)

def RunTime(total):
	print "ENDED! Total runtime was %04d seconds."%(total,)

if __name__=='__main__':
	if len(sys.argv) >= 1 and len(sys.argv)<3:
		Usage(sys.argv[0])
	elif len(sys.argv) == 3:
		Start(totalCombs(int(sys.argv[1]),int(sys.argv[2])))
		tstart = time.time()
		genCombs(int(sys.argv[1]),int(sys.argv[2]))
		RunTime( time.time() - tstart )
	elif len(sys.argv) == 4:
		Start(totalCombs(int(sys.argv[1]),int(sys.argv[2])))
		try:
			file1 = file(sys.argv[3],"wt")
		except:
			print "Impossible to open file"
		else:
			sys.stdout = file1
			tstart = time.time()
			genCombs(int(sys.argv[1]),int(sys.argv[2]))
			ttotal = time.time() - tstart
			sys.stdout = sys.__stdout__
			file1.close()
			RunTime(ttotal)
	else:
		Usage(sys.argv[0])


Note that this is just a quick hack code with no performance considerations.
Instructions for use follow....
 
Last edited:

thornc

Member
Paste this into a file named something like genCombs.py note that the spaces/tabs count in python source code.
Get python (link to exe installer !) and run in a command window something like:
genCombs.py 49 6 649.txt

On my P4 2GHz, this took around 7minutes to run and created a file of 238.67MB.
Note that it uses around 640KB of memory to run....
 
Last edited:

PAB

Member
Hi thornc,

Have you got a Comparable Code in Visual Basic ( VB6 ) Please.
I know Nothing about Python Programming, and Try to Avoid Downloading things if I can Possible Help it.

All the Best.
PAB
:wavey:
 

thornc

Member
Re: Hi thornc,

PAB said:
Have you got a Comparable Code in Visual Basic ( VB6 ) Please.
No, I don't even have VB (any version)... and I doubt that I would be as proficient in it as I am in C/C++ and Pyhton!


I know Nothing about Python Programming, and Try to Avoid Downloading things if I can Possible Help it.
Well Python is very simple to learn, if you like classical programming languages... there are plenty of tutorials around.
As for downling things you have the correct approach, but one has to select the good ones to download and where to download it from!

Sorry I can't be of help... I can however try to compile it to a win32 exe... note that this will be quite large!
 

PAB

Member
Hi thornc,

Thanks for the Reply, I was Just Curious. Don't go to Any Trouble on my Account. Maybe Someone Else here will be Able to come up with Something in VB.

All the Best.
PAB
:wavey:
 

gsobier

Member
...yikes, on my PIII 538Mz machine with 512M RAM would take much:bawl: longer to run your code compared to you:eek:... ...running is on Windows XP:rolleyes: instead of Linux would also mean more of a delay...
thornc said:
Past this into a file named something like genCombs.py, get python (link to exe installer !) and run in a command window something like:
genCombs.py 49 6 649.txt

On my P4 2GHz, this took around 7minutes to run and created a file of 238.67MB.
Note that it uses around 640KB of memory to run....
 

gsobier

Member
...here is a real editor:agree: for you to try The Hessling Editor... ...anyone installing it will need some help from me...

...any kind of "so called editor":rolleyes: like notepad in Windows is a joke:lol:...

...you guys make me laugh, (in a small way)... ...write records out into several file chunks instead of one monster:eek:...

BushHappy said:
I used the LottoGenius Full Wheels Generator ( which can be downloaded for free from http://www.lottogenius.com/Download/default ) to create the Full Wheel in 3 hours. The program worked in the background and did not slow any other processes down.

The size of the text file created was 410Mb - zips down to 68Mb (Still too big to send to anyone). The text file includes the line number - if the programmer had not included this the file would have been much smaller.

It took about 2 minutes to open the file using the text editor - 'Programmer's File Editor'

Cheers,
BushHappy
 
Last edited:

gsobier

Member
Re: Hi thornc,

...VB is a low as you can go... ...VB is what a beginner would attempt to use writing code... ...VB will work if you don't mind the poor performance, there are better choices... ...the problem is a very steep learning curve if you use something better, don't slip:eek: while climbing the mountain...

...when I was in school, they taught Basic on VAX/VMS (yes, I've dated myself) to students who were not in a formal programming curriculum but needed a taste of what programming is all about... ...something like FORTRAN was where the real stuff started...

PAB said:
Thanks for the Reply, I was Just Curious. Don't go to Any Trouble on my Account. Maybe Someone Else here will be Able to come up with Something in VB.

All the Best.
PAB
:wavey:
 

thornc

Member
Nice to see you again George...

gsobier said:
...yikes, on my PIII 538Mz machine with 512M RAM would take much:bawl: longer to run your code compared to you:eek:...
I will give a test run on my laptop later to see how it fares... Note the most amount of time is spent on I/O... writting those 14 millions lines to disk takes time!


...running is on Windows XP:rolleyes: instead of Linux would also mean more of a delay...
The time I supplied was for a P4@2GHZ with 512MB of ram, running XPsp1 and Python 2.3.5!
I doubt it would be any faster in Linux in the same machine.
 

gsobier

Member
...once in a while you might see me... ...yes, I/O is by far the slowest operation:agree:... ...7200 RPM don't help either... ...I try to bash Windows:sick: every change I can get:)... ...Linux would be faster if you can count micro seconds:lol:...
thornc said:
Nice to see you again George...


I will give a test run on my laptop later to see how it fares... Note the most amount of time is spent on I/O... writting those 14 millions lines to disk takes time!


The time I supplied was for a P4@2GHZ with 512MB of ram, running XPsp1 and Python 2.3.5!
I doubt it would be any faster in Linux in the same machine.
 
Last edited:

thornc

Member
Ok, here's a link to a zip file containning a win32 version of the code....size 760KB.
This was converted using py2exe so don't expected any performance increase....

Unzip the file into an empty directory and run the exe with something like:
genCombs 49 6 output.txt
 

gsobier

Member
...I ran 25 numbers as 6 number combos...

11:19:03.18 D:\thornc genCombs.exe 25 6 sets.txt
Starting for 177100 combinations
ENDED! Total runtime was 0021 seconds.

11:20:09.43 D:\thornc _


...the programs says 21 seconds and the actual time to complete was 1:06 or 66 seconds... ...why:notme:?...

...I also am wondering why you don't use leading zeros to make the numbers line up nice like mine...

yours
1 9 22 23 24 25
1 10 11 12 13 14

mine
01 09 22 23 24 25
01 10 11 12 13 14

thornc said:
Ok, here's a link to a zip file containning a win32 version of the code....size 760KB.
This was converted using py2exe so don't expected any performance increase....

Unzip the file into an empty directory and run the exe with something like:
genCombs 49 6 output.txt
 

thornc

Member
gsobier said:
...the programs says 21 seconds and the actual time to complete was 1:06 or 66 seconds... ...why:notme:?...
Strange, I just double checked for a simpler algorihtm and time.time(), time.clock() and my stopwatch return exactly the same result...
Do you have any running application playing with the clock??



...I also am wondering why you don't use leading zeros to make the numbers line up nice like mine...

yours
1 9 22 23 24 25
1 10 11 12 13 14

mine
01 09 22 23 24 25
01 10 11 12 13 14
Simple those leading zeros cost 1byte (2 in Unicode files) each time they appear... so I am trading readability for space!
 

gsobier

Member
...no, none I'm aware of... ...I've got Windows XP SP1... ...there is one thing to check which I've done before to produce crazy results...

...in Rexx, you code time('RESET') and then elapsed = time('ELAPSED')... ...if you have time('RESET') somewhere by mistake this will cause a discrepancy... ...is this what is going on?:notme:... ...if this is what is doing it, I was just lucky to think of it... ...on the other hand, when something like this happens in my code, this is the first thing I look for...

thornc said:
Strange, I just double checked for a simpler algorihtm and time.time(), time.clock() and my stopwatch return exactly the same result...
Do you have any running application playing with the clock??



Simple those leading zeros cost 1byte (2 in Unicode files) each time they appear... so I am trading readability for space!
 

gsobier

Member
...here are all the processes I've got running... ...anyone paying attention will notice Explorer.exe is NOT running... ...this is correct because I stop it and use the keyboard for everything like a real programmer would...

Code:
[b]18:33:52.03 D:\ tasklist

Image Name                   PID Session Name     Session#    Mem Usage
========================= ====== ================ ======== ============
System Idle Process            0 Console                 0         16 K
System                         4 Console                 0        228 K
smss.exe                     392 Console                 0        460 K
csrss.exe                    452 Console                 0      1,368 K
winlogon.exe                 496 Console                 0      1,260 K
services.exe                 540 Console                 0      3,296 K
lsass.exe                    552 Console                 0      1,412 K
svchost.exe                  712 Console                 0      3,736 K
svchost.exe                  760 Console                 0     19,968 K
svchost.exe                  912 Console                 0      2,376 K
svchost.exe                  960 Console                 0      5,332 K
spoolsv.exe                 1164 Console                 0      5,660 K
wdfmgr.exe                  1448 Console                 0      1,732 K
cmd.exe                     1944 Console                 0         36 K
cmd.exe                     1008 Console                 0        888 K
cmd.exe                      248 Console                 0         72 K
Netscp.exe                   384 Console                 0     33,808 K
wmiprvse.exe                1212 Console                 0      4,636 K
tasklist.exe                 416 Console                 0      3,244 K

18:33:55.12 D:\[/b]
 

thornc

Member
Sorry guys it seems we took over this thread....

George, in Python at least with the current implementation there is not need to do like you do in Rexx! Still have no explanation for the problem...


That's one clean task list you have there.... ever thought of running cygwin on as the windows shell instead of explorer??
I also note that you are using Netscape, anything against firefox or mozilla??

---------------------------------------------------

All others, if someone needs the genCombs.exe you can find it at link above. If someone wants it after the link expires I can post it again....
 
The easiest way to run a CommandLine program
is to create a *.bat file like:

genCombs.exe 49 3 output.txt

Save the above with the extention *.bat

Then, with a TXT editor can easily modify the parameters
and run it by clicking on the file name...


i
 

thornc

Member
True Nick,
But you can also create a .cmd file or even a link(.lnk)..... many options!

The best being that I take some time and make a simple gui for the user to input parameters.....

PS: just remebered that you can even use .pif.... :heul:
PS2: and you don't need to include the .exe in the call to the program in batch and command files....
 
All true but the BEST advandage of the
*.bat file is that
we can run multiple queries in sequence
by adding a 2nd..3rd.. request
on the same *.bat file


genCombs 49 3 FD49-3.txt
genCombs 49 4 FD49-4.txt
genCombs 22 5 FD22-5.txt
 

gsobier

Member
...either Rexx or Python is not really the issue... ...I could have written it in C++... ...I'm using the leading zeros so the sets can be sorted... ...the trade off is more disk space... ...you decided not to use leading zeros because of what you've planned to do with the data... ...one thing I really like about Rexx is I don't need to bother with a compiler:D...

...I've installed FireFox and its the default browser... ...I'm still using Netscape for e-Mail... ...I'm in Netscape when I'm posting here because I've clicked on the hyperLink in the e-Mail to get here... ...one of these days, I'll figure out how to get directly into Firefox from a Netscape e-Mail... ...its just a "nice to have" so its low priority, do you have any ideas?...

..I do all my work in cmd.exe... ...I could run cygwin, just never bothered to go the AIX extreme...

...my Windows XP is pretty much barebones so CPU is available for my:burnt: use... ...I've got things like Norton Utilities and even Norton AntiVirus installed... ...I run them when I need/want to... ...a little bit of regedit:lol: took care of the other place in Windows XP where program startups are hidden... ...the stupid autoupdater for Real Player is was also hidden there...

...things like defrag and WindowsUpdate are performed as needed... ...when something appears odd in performance, it is invesigated and resolved ASAP... ...I'm sure I don't need to explain to you the consequences of failing to act quickly when something needs attention... ...all those who suffer with spyware make me laugh:lol:...

...its always nice exchange ideas with someone who knows what the hell they are doing for a change:agree::agree2:... ...most users who know nothing more beyond moving a mouse around tend to do nothing more than waste my time:rolleyes:...

...same here... ...sorry guys for going into a technical discussion...

thornc said:
Sorry guys it seems we took over this thread....

George, in Python at least with the current implementation there is not need to do like you do in Rexx! Still have no explanation for the problem...


That's one clean task list you have there.... ever thought of running cygwin on as the windows shell instead of explorer??
I also note that you are using Netscape, anything against firefox or mozilla??

---------------------------------------------------

All others, if someone needs the genCombs.exe you can find it at link above. If someone wants it after the link expires I can post it again....
 

Sidebar

Top