OK here is the problem:
I have 4 interleaving loops like

n = 1
for a = 1 to 3
for b = a + 1 to 4
for c = b + 1 to 5
for d = c + 1 to 6
response.write(right("00" & CStr(n), 2) & ": " & a & "." & b & "." &
c & "." & d & "<br>")
n = n + 1
next
next
next
next

...providing the following output:

01: 1.2.3.4
02: 1.2.3.5
03: 1.2.3.6
04: 1.2.4.5
05: 1.2.4.6
06: 1.2.5.6
07: 1.3.4.5
08: 1.3.4.6
09: 1.3.5.6
10: 1.4.5.6
11: 2.3.4.5
12: 2.3.4.6
13: 2.3.5.6
14: 2.4.5.6
15: 3.4.5.6

I need an algorithm that would return the rank number (here from 1 to
15) if I enter any subsets of 4 numbers (from 1 to 6).
ex. if I enter r=rank(1, 3, 5, 6) then r=9

I need also the reverse function that would return the subset of 4
numbers for any rank given.
ex if I enter s=subset4(13) then s={2, 3, 5, 6}

The goal here is to get rid of the interleaving loops and that's why
both algorithms cannot be make by looping
and since all the values (here from 1 to 6 or 1 to 4 for the subsets)
can be increased significantly and would take too long to loop.

I have been working on that one for days now and I can't figure it
out...
I would REALLY appreciate some help!

Thank you in advance...

Cubik

Re: A hard one... by john6666

john6666
Wed Feb 11 16:10:45 CST 2004

Ohhh Nooo. Looks like a looping loop loopy thing to me.

cubik@yahoo.com (Cubik) wrote in message news:<6ffe9f65.0402101935.774b4d6a@posting.google.com>...
> OK here is the problem:
> I have 4 interleaving loops like
>
> n = 1
> for a = 1 to 3
> for b = a + 1 to 4
> for c = b + 1 to 5
> for d = c + 1 to 6
> response.write(right("00" & CStr(n), 2) & ": " & a & "." & b & "." &
> c & "." & d & "<br>")
> n = n + 1
> next
> next
> next
> next
>
> ...providing the following output:
>
> 01: 1.2.3.4
> 02: 1.2.3.5
> 03: 1.2.3.6
> 04: 1.2.4.5
> 05: 1.2.4.6
> 06: 1.2.5.6
> 07: 1.3.4.5
> 08: 1.3.4.6
> 09: 1.3.5.6
> 10: 1.4.5.6
> 11: 2.3.4.5
> 12: 2.3.4.6
> 13: 2.3.5.6
> 14: 2.4.5.6
> 15: 3.4.5.6
>
> I need an algorithm that would return the rank number (here from 1 to
> 15) if I enter any subsets of 4 numbers (from 1 to 6).
> ex. if I enter r=rank(1, 3, 5, 6) then r=9
>
> I need also the reverse function that would return the subset of 4
> numbers for any rank given.
> ex if I enter s=subset4(13) then s={2, 3, 5, 6}
>
> The goal here is to get rid of the interleaving loops and that's why
> both algorithms cannot be make by looping
> and since all the values (here from 1 to 6 or 1 to 4 for the subsets)
> can be increased significantly and would take too long to loop.
>
> I have been working on that one for days now and I can't figure it
> out...
> I would REALLY appreciate some help!
>
> Thank you in advance...
>
> Cubik