<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/">
	<channel>
		<title>Combinatorial Index</title>
		<link>https://blogs.lotterypost.com/jadelottery/2010/9/combinatorial-index.htm</link>
		<atom:link href="https://www.lotterypost.com/rss/blogcomments/45769" rel="self" type="application/rss+xml" />
		<description>JADELottery's Blog: Combinatorial Index</description>
		<dc:language>en-us</dc:language>
		<generator>Lottery Post RSS Generator</generator>
		<item>
			<title>Original Blog Entry: Combinatorial Index</title>
			<link>https://blogs.lotterypost.com/jadelottery/2010/9/combinatorial-index.htm</link>
			<guid isPermaLink="true">https://blogs.lotterypost.com/jadelottery/2010/9/combinatorial-index.htm</guid>
			<pubDate>Sun, 05 Sep 2010 02:39:20 GMT</pubDate>
			<dc:creator>JADELottery</dc:creator>
			<description><![CDATA[<p>We posted this in the topic Excel help need Combination FROM Lexicographix number in the Mathematics Forum.<br /><br />Adjust the Data Types on different programming platforms.<br /><br />The functions may error out on very large Combinatorial Sets.<br /><br />_______________________________________________________<br /><br />Ok, Here It Is.<br /><br />You can download the Excel file at ftp://www.jadexcode.com/excel<br /><br />The file name is CombinatorialIndex.xls<br /><br />The VB Macro Source Code is shown below<br /><br />Function Fact(N As Integer) As Double<br /><br />If (N 1) Then<br /><br />Fact = 1<br /><br />Else<br /><br />Fact = N * Fact(N - 1)<br /><br />End If<br /><br />End Function<br /><br />Function Perm(N As Integer, R As Integer) As Double<br /><br />If (N R) Then<br /><br />Perm = 0<br /><br />Else<br /><br />Perm = Fact(N) / Fact(N - R)<br /><br />End If<br /><br />End Function<br /><br />Function Comb(N As Integer, R As Integer) As Long<br /><br />If (N R) Then<br /><br />Comb = 0<br /><br />Else<br /><br />Comb = Perm(N, R) / Fact(R)<br /><br />End If<br /><br />End Function<br /><br />Function Cdist(N As Integer, R As Integer, C As Integer, Z As Integer) As Long<br /><br />If (Z C) Or (Z (N - R + C)) Or (Z N) Or (C R) Or (N 1) Or (R 1) Or (C 1) Or (Z 1) Then<br /><br />Cdist = 0<br /><br />Else<br /><br />Cdist = Comb(Z - 1, C - 1) * Comb(N - Z, R - C)<br /><br />End If<br /><br />End Function<br /><br />Function fColumnSum(N As Integer, R As Integer, Z As Integer) As Long<br /><br />Dim a As Integer<br /><br />If Z 1 Then<br /><br />fColumnSum = 0<br /><br />ElseIf (Z = 1) And (Z N - R + 1) Then<br /><br />col_sum = 0<br /><br />For a = 1 To Z<br /><br />col_sum = col_sum + Cdist(N, R, 1, a)<br /><br />Next a<br /><br />fColumnSum = col_sum<br /><br />ElseIf Z = N - R + 1 Then<br /><br />fColumnSum = Comb(N, R)<br /><br />End If<br /><br />End Function<br /><br />Function Index2Combin(N As Integer, R As Integer, I As Double) As String<br /><br />Dim Combination(), Z As Integer<br /><br />ReDim Combination(R)<br /><br />Dim tmpString As String<br /><br />Dim NumberFound As Boolean<br /><br />tmpString =<br /><br />I = I - 1<br /><br />Z = 0<br /><br />For a = 1 To R<br /><br />If I = Comb(N, R) Then<br /><br />If a = 1 Then<br /><br />Combination(a) = 1<br /><br />Else<br /><br />Combination(a) = Combination(a - 1) + 1<br /><br />End If<br /><br />NumberFound = False<br /><br />Do<br /><br />Select Case (I - fColumnSum(N - Z, R - (a - 1), Combination(a) - Z - 1))<br /><br />Case Is 0<br /><br />Combination(a) = Combination(a) - 1<br /><br />NumberFound = True<br /><br />Case Is = 0<br /><br />NumberFound = True<br /><br />Case Is 0<br /><br />Combination(a) = Combination(a) + 1<br /><br />End Select<br /><br />Loop Until NumberFound<br /><br />I = I - fColumnSum(N - Z, R - (a - 1), Combination(a) - Z - 1)<br /><br />Z = Combination(a)<br /><br />Else<br /><br />Combination(a) = 0<br /><br />End If<br /><br />tmpString = tmpString Format(Combination(a), 00 )<br /><br />If a R Then tmpString = tmpString<br /><br />Next a<br /><br />Index2Combin = tmpString<br /><br />End Function<br /><br />Function Combin2Index(N As Integer, R As Integer, theRange As Range) As Long<br /><br />Dim a As Integer<br /><br />Dim fSum As Double<br /><br />Dim NotInAscendingOrder, NotInPool As Boolean<br /><br />NotInAscendingOrder = False<br /><br />NotInPool = False<br /><br />If (theRange.Rows.Count 1) Or (theRange.Columns.Count R) Then<br /><br />Combin2Index = -1<br /><br />Exit Function<br /><br />End If<br /><br />For a = 1 To R<br /><br />If a R Then<br /><br />If theRange.Cells(1, a) = theRange.Cells(1, a + 1) Then<br /><br />NotInAscendingOrder = True<br /><br />End If<br /><br />End If<br /><br />If (theRange.Cells(1, a) 1) Or (theRange.Cells(1, a) N) Then<br /><br />NotInPool = True<br /><br />End If<br /><br />Next a<br /><br />If NotInAscendingOrder Or NotInPool Then<br /><br />Combin2Index = -1<br /><br />Exit Function<br /><br />End If<br /><br />fSum = fColumnSum(N, R, theRange.Cells(1, 1) - 1) + 1<br /><br />For a = 2 To R<br /><br />fSum = fSum + fColumnSum(N - theRange.Cells(1, a - 1), R - a + 1, theRange.Cells(1, a) - theRange.Cells(1, a - 1) - 1)<br /><br />Next a<br /><br />Combin2Index = fSum<br /><br />End Function<br /><br />... &#x5b;&#xa0;<a href="https://blogs.lotterypost.com/jadelottery/2010/9/combinatorial-index.htm">More</a>&#xa0;&#x5d;</p>]]></description>
			<category>Blog Entry</category>
			<category>JADELottery</category>
			<wfw:comment>https://www.lotterypost.com/blogentry/45769</wfw:comment>
		</item>
	</channel>
</rss>

