i didn't read your codes through. I wrote a py script, to do the combination calculation (5 from 50). you can change the two numbers. of course some validation was not implemented, e.g m(5) should be smaller than n(50) etc.
I saved the results in a list (result), didn't print it out or save into a file. the output of my codes was just the total possibilities. (2118760). it took 2min and 50 secs to calculate C 50 5.
here are the python script:
PHP Code:
#!/usr/bin/python def getCombinations(n,m): allNum = range(1,n+1) idx = [0]*n # index matrix idxMatrix = [] result = []
for i in range(m): idx[i]=1 idxMatrix.append(idx) while(getIdxMatrix(idxMatrix,m)): pass for l in idxMatrix: #print l result.append([x for x in allNum if l[allNum.index(x)]]) print len(result)
def getIdxMatrix(idxMatrix,m): last = idxMatrix[-1] newline = list(last) for i in range(len(newline)): if i!=len(newline)-1 and newline[i]==1 and newline[i+1]==0: su = sum(last[:i]) newline[i],newline[i+1] = 0,1 for j in range(i): newline[j]=1 if j<su else 0 idxMatrix.append(newline) return True return False
Hi :-)
i have a dump of a backupdisk (~540GB / ext3). The Backups have some 100 millions of hardlinks (backups are created with storeBackup). The OS is linux.
A restore of a directory ended after some days with the errormessage "no memory to extend symbol table"
The restore of the complete... (0 Replies)
Hi All,
My requirement is like this.
I want to generate records of 1 million lines. If I say lines it means one line will contain some string or numbers like
AA,3,4,45,+223424234,Tets,Ghdj,+33434,345453434,........................ upto length lets say 41. ( 41 comma sepearted aplha numneric... (2 Replies)
Hi guys,
I have an issue processing a large amount of files. I have around 5 million files (some of them are actually directories) in a server.
I am unable to find out the exact number of files since it's taking "forever" to finish (See this thread for more on the issue).
Anyway, now I... (6 Replies)
Hello,
I just saw that on my vps (centOS) my oscommerce with a seo script
has created millions of tmp files inside the /html/cache/ directory.
I would need to remove all those files (millions), I tried via shell but the vps
loads goes to very high and it hangs, is there some way to do a... (7 Replies)
Hi,
I have an XML file with around 1 billion rows in it and i am trying to find the number of times a particular tag occurs in it. The solution i am using works but takes a lot of time (~1 hr) .Please help me with an efficient way to do this.
Lets say the input file is
<Root>
... (13 Replies)
I wanna create a millions of record using shell scripts..
the scenario is somehow like this,,,i want to create the record for these fields in my database..id,name,addrs,sales.
So can you please give a overall idea for how to achieve it? (9 Replies)
I want to create a file contains millions of lines. The line format like this:
acnum$$123456$$+$$Tom$$111$$
fields separated by $$, field 1 and field 3 have only two options:acnum or crenum; + or -. field 4 can be any name or any letters. Other fields can be any fixed length digits. So, I want to... (9 Replies)
In a python script I have 2 files printing side by side on the same line. I want to have 1 of the files to be already displayed at once while the other file print down the list in the file and it still will produce new lines. I want to do it like that to reduce printing a lot of lines and... (0 Replies)