Algorithm, algorithms, formula, formulas, formulae, math, mathematics to calculate combination index, order, index, lexicographic, lexicographical.

Algorithm, software to calculate combination lexicographical order, rank, index

By Ion Saliu, Algorithmically At-Large


Math, mathematics: formula, formulas, formulae, lexicographic, lexicographical order.

Written by Ion Saliu on July 23, 2001.

• When you gotta do it, you'll do it. For your mind won't find peace until a goal is reached.
I presented earlier this month of July 2001 an algorithm to calculate the index, or rank, or lexicographical order, or combination sequence number (CSN). The algorithm was 100% precise. It had one problem, however. The speed of execution left much to be desired for monster-odds games, such as Keno (80/20, 70/20, even 70/10). The speed was acceptable for many other lotto games. Even a big game such as the 49/5/42 PowerBall required less than half a minute to determine the CSN. Nevertheless, running the algorithm for Keno games took an eternity!

I came back to the original “B.P. Buckles and M. Lybanon” algorithm (algorithm “ACM #515”). I was able to add to it the reverse task: calculate the CSN for any lotto game, but the PowerBall. Later, the PowerBall will be added to the procedure.
I recompiled NTHINDEX.EXE to SEQUENCE.EXE, the program that uses the new algorithm. The program is freeware at the software download site.

Here is the main algorithm. Listed is also my function that calculates the number of combinations 'N taken M at a time': Combine## (N, M). The program SEQUENCE.EXE was compiled with PowerBasic for DOS.

' *** the new 'combination index (rank)' algorithm
' V = the biggest number in the lotto game (e.g. 49, or 80, etc.)
' K = numbers per combination (e.g. 6, 10, 20, etc.)

REDIM C(K)
REDIM Num(K)    'the numbers in the combination

         LI## = 0
         CSN## = 0
         P1 = K - 1

 FOR I = 1 TO P1

        C(I) = 0
        If I <> 1 THEN C(I) = C(I - 1)
   2001 C(I) = C(I) + 1

   R## = Combine##(V - C(I), K - I)  'call the combination calculator

        LI## = LI## + R##

        IF C(I) < Num(I) THEN GOTO 2001  ' the key command

        LI## = LI## - R##

 NEXT I

        CSN## = LI## + Num(K) - Num(P1)  'combination sequence number


FUNCTION Combine##(N, M)

 REM *** This function calculates the total number of combinations ***
 REM *** 'N taken M' at a time

     FA## = 1
     FOR i = 1 TO M: FA## = FA## * i: NEXT i
     va## = 1
     FOR j = (N - M + 1) TO N: va## = va## * j: NEXT j
     Combine## = va## / FA##

END FUNCTION

I verified the algorithm with many cases. I believe the procedure is 100% accurate. But, if you think you discovered a miscalculation, please let me know. Document the error as detailed and as clearly as possible. I believe I can fix the errors – if any.

Ion Saliu

Algorithm, algorithms, formula, formulas, formulae for index, lexicographic, lexicographical order.

This is a comprehensive list of my writings on the topic of lexicographical order or indexing, including algorithms and software.

  • Lexicographic, lexicographical order, index, rank of permutations, exponential sets, combinations.
    This is the most intuitive, if not the best, introduction to the apparently difficult concept of lexicographic ordering (or indexing).

  • Lexicographical Order: Lotto, Powerball, Mega Millions, Euromillions.
    This is the most comprehensive and intuitive presentation of the concept of lexicographic ordering (or indexing), including the superior software to tackle the task.

  • Combination Lexicographic Order, Rank, Index: The Comprehensive and Fast Algorithm.
    I expanded the lexicographical index concept to two-in-one games, particularly the U.S. lotto game of Powerball (applicable to Mega Millions as well).

  • Calculate the combination lexicographic order of lotto data files.
    The introduction of DrawIndex.EXE, the software that calculates the lexicographic indexes for every combination (draw) in a lotto results file.

    The following are older and somehow outdated materials I wrote on lexicographical order subjects. Most of the older software is outdated. Nothing (in the whole world) can beat LexicographicSets.EXE or DrawIndex.EXE. Sentimentalism is good only to a close extent.

  • Index, rank lexicographic order lotto combination.
  • Software combination algorithm formula index ordering.
  • Combination sequence number or Lexicographic Order Debates.

    Of course, everybody loves to feast on great software, especially when it is free! My combinatorics software (and other categories) is absolutely free to run, for an unlimited period of time. However, only the registered members have a right to download the software. Membership requires a nominal fee — the most reasonable there is to connect to the greatest and most useful software ever created. No kidding! Read the conditions to becoming a registered member: Download Great Free Software: Paid Membership Required.

    • Download the free software from the download site:
      LexicographicSets.EXE, the universal permutations, arrangements and combinations lexicographic indexing (ranking);
      DrawIndex.EXE - highly automated lexicographical indexing for lotto draw files.
      NthIndex.EXE ~ lexicographic indexing superseded by LexicographicSets.EXE;
      SEQUENCE.EXE ~ lexicographic indexing superseded by LexicographicSets.EXE;
      COLORDER.EXE - lexicographical indexing for lotto and Powerball only;
      PermuteCombine.exe, the universal permutations, arrangements and combinations generator for any numbers and words;
      Combinations.exe, the universal combinations generator for any lotto, Keno, Powerball game: N numbers taken M at a time, in K steps;
      WRITER.EXE, random generator of letters to words, passwords, sentences.

    Lexicographic, lexicographical order: Algorithm, algorithms, formula, formulas, formulae, math, mathematics.

    Subject:

    Comments:





    Lexicographic order, software, mathematics.Socrates Home  Search Web on combinatorics lexicographical order.Search  Random combinations generator.Random Generator, Odds Calculator  Message board, forum: lexicographical order, formulas, permutations.New Writings, Pages  Links to lexicographic order, math, combinatorics.Sitemap, Content