Loading ...
Sorry, an error occurred while loading the content.

22222Re: [Clip] Finding gaps in a sequence

Expand Messages
  • Rod Dav4is
    Nov 12, 2011
    • 0 Attachment
      Treat them as 3-digit radix-26 numbers, and check the numerical
      difference between two records. If not =1, something's missing.
      -R.

      On 2011-11-12 11:34, flo.gehrke wrote:
      > I've got a database where each record is indexed with an alpha-code from 'aaa' to 'zzz'.
      >
      > Every now and then, I want to find out if there is a gap in a sorted list of these codes. There's a gap, for example, in...
      >
      > zbx
      > zby
      > zbz
      > zca
      > zcc
      > zcd
      >
      > (missing 'zcb'). How to detect such gaps with a clip?
      >
      > My only basic idea is to calculate a kind of "checksum" and the difference between the checksum of two following codes:
      >
      > 1. Calculate "checksum" %A% with...
      >
      > ^!Set %A%=^$Calc(^$CharToDec(^$StrIndex(^%A%;1)$)$+^$CharToDec(^$StrIndex(^%A%;2)$)$+^$CharToDec(^$StrIndex(^%A%;3)$)$)$
      >
      > 2. Calculate the "checksum" of next code and assign it to %B%
      >
      > 3. Calculate the difference diff = B - A
      >
      > If I'm not mistaken, the sequence is OK if diff=1 or diff=-24. And there's a gap if 'diff' is diverging from 1 or -24.
      >
      > Any ideas - possibly more efficient? Thanks!
      >
      > Flo
      >
      >
      >
      >
      > ------------------------------------
      >
      > Fookes Software: http://www.fookes.com/
      > NoteTab website: http://www.notetab.com/
      > NoteTab Discussion Lists: http://www.notetab.com/groups.php
      >
      > ***
      > Yahoo! Groups Links
      >
      >
      >
      >
    • Show all 29 messages in this topic