XPost: comp.lang.asm.x86, comp.lang.pl1   
   From: robin51@dodo.com.au   
      
   "Robert AH Prins" wrote in message news:85a   
   p6F4bpU1@mid.individual.net...   
   | Hi all,   
   |   
   | Can anyone give me some hints as to solve the following problem,   
   | preferably in a way that is faster than the way I used to do it, and   
   | without the bug in the current version;   
   |   
   | Problem description:   
   |   
   | The program processes an array of N cells, with N up to about 4096. The   
   | array is filled from the start, it may not be completely full but there   
   | are no empty cells between full cells. A cell contains a value of   
   | 1..255, so logically every cell would be a byte, but if processing   
   | efficiency requires each cell to be a word or even a double-word, that   
   | would be no problem.   
      
   In general, byte values are quicker to manipulate than word,   
   halfword, and doubleword values.   
      
   | The values are normalized, they are effectively   
   | indexes into a table, so if the table contains just T entries, the   
   | values would go from 1 to T.   
   |   
   | Given the above setup, the problem is to find *all* sub-arrays that   
   | contain 3..T distinct elements and are as short as possible, i.e. if   
   | there are 42 sub-arrays of three elements containing three distinct   
   | values, there is no need to find sub-arrays of four elements containing   
   | three distinct values. Also, a shorter sub-array may *never* be a part   
   | of a longer sub-array containing *only* distinct values.   
   |   
   | An example, suppose only the array contains 56 elements, in this case   
   | with, for clarity, values a..j:   
   |   
   | 1 2 3 4 5 5   
   | ....5....0....5....0....5....0....5....0....5....0....56   
   | aaaaaabbbbbabbbcbcccccccddddddddccbbbbbbefffghggggihbfja   
   |   
   | in this case the program should find the following sub-arrays:   
   |   
   | len aperture from to value   
   | 3 3 40 42 bef   
   | 3 3 44 46 fgh   
   | 7 7 50 56 gihbfja   
   | 8 16 41 56 efffghggggihbfja, containing efghibja   
   | 9 23 34 56 cbbbbbbefffghggggihbfja, containing cbefghija   
   | 10 25 32 56 dccbbbbbbefffghggggihbfja, containing dcbefghija   
   |   
   | It is possible to find sub-arrays with 4, 5, or 6 distinct values, but   
   | they are either longer than the series of 7-in-7 (12-25 contain abcd),   
   | or are part of the 7-in-7 series and as such they should not be included!   
   |   
   | My AD 1996 program used to slide a window that started with three   
   | elements (plus a sentinel on either side) over the big array and spit   
   | out the position of the first element if it found three distinct   
   | elements in the window *and* the two sentinels also contained any of the   
   | values in the window.   
      
   This sounds like something adaptable to using INDEX.   
   especially as your data are byte entries. (or maybe I'm   
   thinking of the wrong part of the search...).   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|