Skip to main content
Changed the question to a more obvious question and edited the topic.
Source Link

How to getpredict the length and relative offset, given of the overall offsetsequence in and array?

I have a list of hashes and I need to find the length and offset of the subsets in the list.

Here is an example:

There is an array of values, like the following array:

[A][B][C][D][E]

We have a Maximum Length and ainput string similar to Minimum LengthABCDEFGHIJK from which a loop generates 1 hash per a subsetseries of the original array, moving the offset from 1 until the point which the subset still fits in the original array.

Assuming the Maximum Length as 3 and the Minimum Length as 1, the output will be:

1) [A][B][C]
2) [B][C][D]
3) [C][D][E]
4) [A][B]
5) [B][C]
6) [C][D]
7) [D][E]
8) [A]
9) [B]
10)[C]
11)[D]
12)[E]

For each subset, a hash will besequences has been generated which seats in the same index as the hash list like this:

1) Hash#1  ([A][B][C])
2) Hash#2  ([B][C][D])
3) Hash#3  ([C][D][E])
4) Hash#4  ([A][B])
5) Hash#5  ([B][C])
6) Hash#6  ([C][D])
7) Hash#7  ([D][E])
8) Hash#8  ([A])
9) Hash#9  ([B])
10)Hash#10 ([C])
11)Hash#11 ([D])
12)Hash#12 ([E])

Is it possible to get the subset length and offset using an offset from the hash list, maximum length, minimum length and original array's length?

Update:

Following I have provided a sample code in Javascript to be easily tested.

Assuming the code below:

var sourceData = "ABCDEFGHIJK";

var subs = [];

var dataLength = sourceData.length;

var maxLength = 8;

var minLength = 1;

var length = maxLength;

while (length >= minLength) {
  
    var index = 0;

    while (index + length <= dataLength) {
      
        var sub = sourceData.substring(index, index + length);

        subs.push(sub);

        index++;
    }

    length--;
}

If you run the code provided above,into an array will be generated this looks like thisas following:

0: 'ABCDEFGH'
1: 'BCDEFGHI'
2: 'CDEFGHIJ'
3: 'DEFGHIJK'
4: 'ABCDEFG'
5: 'BCDEFGH'
6: 'CDEFGHI'
7: 'DEFGHIJ'
8: 'EFGHIJK'
9: 'ABCDEF'
10: 'BCDEFG'
11: 'CDEFGH'
12: 'DEFGHI'
13: 'EFGHIJ'
14: 'FGHIJK'
15: 'ABCDE'
16: 'BCDEF'
17: 'CDEFG'
18: 'DEFGH'
19: 'EFGHI'
20: 'FGHIJ'
21: 'GHIJK'
2200: 'ABCD'
2301: 'BCDE'
2402: 'CDEF'
2503: 'DEFG'
2604: 'EFGH'
2705: 'FGHI'
2806: 'GHIJ'
2907: 'HIJK'
3008: 'ABC'
3109: 'BCD'
3210: 'CDE'
3311: 'DEF'
3412: 'EFG'
3513: 'FGH'
3614: 'GHI'
3715: 'HIJ'
3816: 'IJK'
3917: 'AB'
4018: 'BC'
4119: 'CD'
4220: 'DE'
4321: 'EF'
4422: 'FG'
4523: 'GH'
4624: 'HI'
4725: 'IJ'
4826: 'JK'
4927: 'A'
5028: 'B'
5129: 'C'
5230: 'D'
5331: 'E'
5432: 'F'
5533: 'G'
5634: 'H'
5735: 'I'
5836: 'J'
5937: 'K'

ConsideringThe sequences in the out array, if we take above has been generated by following these steps:

  1. Set length to 4
  2. Set offset to 0
  3. Pick a sequence of length long characters from "ABCDEFGHIJK" (Input string)
  4. Put the sequence at the bottom of output array
  5. Increase offset by 1
  6. If offset + length <= 11 (Input string's length) then goto 3
  7. Decrease length by 1
  8. If length >= 1 then goto 2
  9. Exit

By looking at the index number 17output array, sequences in the item length isarray have a length which starts at 4 and it has started ongradually goes down to 1, and also an offset which is where in the index 2 ofinput string the initial input data (which I call offset of 2)sequence has begun.

What I'm trying to findachieve is a formula or algorithm which allows me to figure"predict" both the lengthlength and offsetthe offset of any itema sequence at a given index in the output arrayoutput array, only by having its indexthe input string's length and index in the output array.

I'm preferably looking for a formula, without having access tohowever an algorithm which doesn't involve simulating the actual output array will work as well.

How to get length and relative offset, given the overall offset?

I have a list of hashes and I need to find the length and offset of the subsets in the list.

Here is an example:

There is an array of values, like the following array:

[A][B][C][D][E]

We have a Maximum Length and a Minimum Length from which a loop generates 1 hash per a subset of the original array, moving the offset from 1 until the point which the subset still fits in the original array.

Assuming the Maximum Length as 3 and the Minimum Length as 1, the output will be:

1) [A][B][C]
2) [B][C][D]
3) [C][D][E]
4) [A][B]
5) [B][C]
6) [C][D]
7) [D][E]
8) [A]
9) [B]
10)[C]
11)[D]
12)[E]

For each subset, a hash will be generated which seats in the same index as the hash list like this:

1) Hash#1  ([A][B][C])
2) Hash#2  ([B][C][D])
3) Hash#3  ([C][D][E])
4) Hash#4  ([A][B])
5) Hash#5  ([B][C])
6) Hash#6  ([C][D])
7) Hash#7  ([D][E])
8) Hash#8  ([A])
9) Hash#9  ([B])
10)Hash#10 ([C])
11)Hash#11 ([D])
12)Hash#12 ([E])

Is it possible to get the subset length and offset using an offset from the hash list, maximum length, minimum length and original array's length?

Update:

Following I have provided a sample code in Javascript to be easily tested.

Assuming the code below:

var sourceData = "ABCDEFGHIJK";

var subs = [];

var dataLength = sourceData.length;

var maxLength = 8;

var minLength = 1;

var length = maxLength;

while (length >= minLength) {
  
    var index = 0;

    while (index + length <= dataLength) {
      
        var sub = sourceData.substring(index, index + length);

        subs.push(sub);

        index++;
    }

    length--;
}

If you run the code provided above, an array will be generated this looks like this:

0: 'ABCDEFGH'
1: 'BCDEFGHI'
2: 'CDEFGHIJ'
3: 'DEFGHIJK'
4: 'ABCDEFG'
5: 'BCDEFGH'
6: 'CDEFGHI'
7: 'DEFGHIJ'
8: 'EFGHIJK'
9: 'ABCDEF'
10: 'BCDEFG'
11: 'CDEFGH'
12: 'DEFGHI'
13: 'EFGHIJ'
14: 'FGHIJK'
15: 'ABCDE'
16: 'BCDEF'
17: 'CDEFG'
18: 'DEFGH'
19: 'EFGHI'
20: 'FGHIJ'
21: 'GHIJK'
22: 'ABCD'
23: 'BCDE'
24: 'CDEF'
25: 'DEFG'
26: 'EFGH'
27: 'FGHI'
28: 'GHIJ'
29: 'HIJK'
30: 'ABC'
31: 'BCD'
32: 'CDE'
33: 'DEF'
34: 'EFG'
35: 'FGH'
36: 'GHI'
37: 'HIJ'
38: 'IJK'
39: 'AB'
40: 'BC'
41: 'CD'
42: 'DE'
43: 'EF'
44: 'FG'
45: 'GH'
46: 'HI'
47: 'IJ'
48: 'JK'
49: 'A'
50: 'B'
51: 'C'
52: 'D'
53: 'E'
54: 'F'
55: 'G'
56: 'H'
57: 'I'
58: 'J'
59: 'K'

Considering the out array, if we take the index number 17, the item length is 4 and it has started on the index 2 of the initial input data (which I call offset of 2).

What I'm trying to find is a formula or algorithm which allows me to figure the length and offset of any item in the output array only by having its index, without having access to the actual output array.

How to predict the length and offset of the sequence in and array?

I have an input string similar to ABCDEFGHIJK from which a series of sequences has been generated into an array as following:

00: 'ABCD'
01: 'BCDE'
02: 'CDEF'
03: 'DEFG'
04: 'EFGH'
05: 'FGHI'
06: 'GHIJ'
07: 'HIJK'
08: 'ABC'
09: 'BCD'
10: 'CDE'
11: 'DEF'
12: 'EFG'
13: 'FGH'
14: 'GHI'
15: 'HIJ'
16: 'IJK'
17: 'AB'
18: 'BC'
19: 'CD'
20: 'DE'
21: 'EF'
22: 'FG'
23: 'GH'
24: 'HI'
25: 'IJ'
26: 'JK'
27: 'A'
28: 'B'
29: 'C'
30: 'D'
31: 'E'
32: 'F'
33: 'G'
34: 'H'
35: 'I'
36: 'J'
37: 'K'

The sequences in the array above has been generated by following these steps:

  1. Set length to 4
  2. Set offset to 0
  3. Pick a sequence of length long characters from "ABCDEFGHIJK" (Input string)
  4. Put the sequence at the bottom of output array
  5. Increase offset by 1
  6. If offset + length <= 11 (Input string's length) then goto 3
  7. Decrease length by 1
  8. If length >= 1 then goto 2
  9. Exit

By looking at the output array, sequences in the array have a length which starts at 4 and gradually goes down to 1, and also an offset which is where in the input string the sequence has begun.

What I'm trying to achieve is to "predict" both the length and the offset of a sequence at a given index in the output array, only having the input string's length and index in the output array.

I'm preferably looking for a formula, however an algorithm which doesn't involve simulating the output array will work as well.

Provided more details.
Source Link

[A][B][C][D][E]

[A][B][C][D][E]

Is it possible to get the subset length and offset using an offset from the hash list, maximum length, minimum length and original array's length?

Update:

Following I have provided a sample code in Javascript to be easily tested.

Assuming the code below:

var sourceData = "ABCDEFGHIJK";

var subs = [];

var dataLength = sourceData.length;

var maxLength = 8;

var minLength = 1;

var length = maxLength;

while (length >= minLength) {
  
    var index = 0;

    while (index + length <= dataLength) {
      
        var sub = sourceData.substring(index, index + length);

        subs.push(sub);

        index++;
    }

    length--;
}

If you run the code provided above, an array will be generated this looks like this:

0: 'ABCDEFGH'
1: 'BCDEFGHI'
2: 'CDEFGHIJ'
3: 'DEFGHIJK'
4: 'ABCDEFG'
5: 'BCDEFGH'
6: 'CDEFGHI'
7: 'DEFGHIJ'
8: 'EFGHIJK'
9: 'ABCDEF'
10: 'BCDEFG'
11: 'CDEFGH'
12: 'DEFGHI'
13: 'EFGHIJ'
14: 'FGHIJK'
15: 'ABCDE'
16: 'BCDEF'
17: 'CDEFG'
18: 'DEFGH'
19: 'EFGHI'
20: 'FGHIJ'
21: 'GHIJK'
22: 'ABCD'
23: 'BCDE'
24: 'CDEF'
25: 'DEFG'
26: 'EFGH'
27: 'FGHI'
28: 'GHIJ'
29: 'HIJK'
30: 'ABC'
31: 'BCD'
32: 'CDE'
33: 'DEF'
34: 'EFG'
35: 'FGH'
36: 'GHI'
37: 'HIJ'
38: 'IJK'
39: 'AB'
40: 'BC'
41: 'CD'
42: 'DE'
43: 'EF'
44: 'FG'
45: 'GH'
46: 'HI'
47: 'IJ'
48: 'JK'
49: 'A'
50: 'B'
51: 'C'
52: 'D'
53: 'E'
54: 'F'
55: 'G'
56: 'H'
57: 'I'
58: 'J'
59: 'K'

Considering the out array, if we take the index number 17, the item length is 4 and it has started on the index 2 of the initial input data (which I call offset of 2).

What I'm trying to find is a formula or algorithm which allows me to figure the length and offset of any item in the output array only by having its index, without having access to the actual output array.

[A][B][C][D][E]

Is it possible to get the subset length and offset using an offset from the hash list, maximum length, minimum length and original array's length?

[A][B][C][D][E]

Is it possible to get the subset length and offset using an offset from the hash list, maximum length, minimum length and original array's length?

Update:

Following I have provided a sample code in Javascript to be easily tested.

Assuming the code below:

var sourceData = "ABCDEFGHIJK";

var subs = [];

var dataLength = sourceData.length;

var maxLength = 8;

var minLength = 1;

var length = maxLength;

while (length >= minLength) {
  
    var index = 0;

    while (index + length <= dataLength) {
      
        var sub = sourceData.substring(index, index + length);

        subs.push(sub);

        index++;
    }

    length--;
}

If you run the code provided above, an array will be generated this looks like this:

0: 'ABCDEFGH'
1: 'BCDEFGHI'
2: 'CDEFGHIJ'
3: 'DEFGHIJK'
4: 'ABCDEFG'
5: 'BCDEFGH'
6: 'CDEFGHI'
7: 'DEFGHIJ'
8: 'EFGHIJK'
9: 'ABCDEF'
10: 'BCDEFG'
11: 'CDEFGH'
12: 'DEFGHI'
13: 'EFGHIJ'
14: 'FGHIJK'
15: 'ABCDE'
16: 'BCDEF'
17: 'CDEFG'
18: 'DEFGH'
19: 'EFGHI'
20: 'FGHIJ'
21: 'GHIJK'
22: 'ABCD'
23: 'BCDE'
24: 'CDEF'
25: 'DEFG'
26: 'EFGH'
27: 'FGHI'
28: 'GHIJ'
29: 'HIJK'
30: 'ABC'
31: 'BCD'
32: 'CDE'
33: 'DEF'
34: 'EFG'
35: 'FGH'
36: 'GHI'
37: 'HIJ'
38: 'IJK'
39: 'AB'
40: 'BC'
41: 'CD'
42: 'DE'
43: 'EF'
44: 'FG'
45: 'GH'
46: 'HI'
47: 'IJ'
48: 'JK'
49: 'A'
50: 'B'
51: 'C'
52: 'D'
53: 'E'
54: 'F'
55: 'G'
56: 'H'
57: 'I'
58: 'J'
59: 'K'

Considering the out array, if we take the index number 17, the item length is 4 and it has started on the index 2 of the initial input data (which I call offset of 2).

What I'm trying to find is a formula or algorithm which allows me to figure the length and offset of any item in the output array only by having its index, without having access to the actual output array.

Source Link

How to get length and relative offset, given the overall offset?

I have a list of hashes and I need to find the length and offset of the subsets in the list.

Here is an example:

There is an array of values, like the following array:

[A][B][C][D][E]

We have a Maximum Length and a Minimum Length from which a loop generates 1 hash per a subset of the original array, moving the offset from 1 until the point which the subset still fits in the original array.

Assuming the Maximum Length as 3 and the Minimum Length as 1, the output will be:

1) [A][B][C]
2) [B][C][D]
3) [C][D][E]
4) [A][B]
5) [B][C]
6) [C][D]
7) [D][E]
8) [A]
9) [B]
10)[C]
11)[D]
12)[E]

For each subset, a hash will be generated which seats in the same index as the hash list like this:

1) Hash#1  ([A][B][C])
2) Hash#2  ([B][C][D])
3) Hash#3  ([C][D][E])
4) Hash#4  ([A][B])
5) Hash#5  ([B][C])
6) Hash#6  ([C][D])
7) Hash#7  ([D][E])
8) Hash#8  ([A])
9) Hash#9  ([B])
10)Hash#10 ([C])
11)Hash#11 ([D])
12)Hash#12 ([E])

Is it possible to get the subset length and offset using an offset from the hash list, maximum length, minimum length and original array's length?