- At 11/30/2011 13:28, Eb wrote:
>The alphabet is like a base-26 number set (English aplhabet), after

If I am interpreting correctly what you said here, the statement is not

>shifting a to zero. Straight conversion to numbers creates gaps, where it

>rolls to the next digit, i.e. aaz --> aba has a gap of 26!, the value of

>the next digit, and azz to baa has a gap much larger!

correct - there is no gap using the alphabet as symbols for a base 26

numbering system.

Any integer (including negative ones), may be used as a base for counting

sequentially and takes the form: sum(d(i) * b^i) where "d" is the ith

"digit" (right to left, 0 based) and "b" is the base-1. In the case of

using the alphabet symbols to represent base 26 digits: a=0, b=1 ... z=25

and the base 10 value of any such number would be d2 * 26^2 + d1 * 26^1 +

d0 * 26^0 or d2*676 +d1*26 + d0*1.

Thus aaz = 0*676 + 0*26 + 25*1 = 25 and aba = 0*676 + 1*26 +0*1 = 26

(no gap)

Also azz = 0*676 + 25*26 + 25*1 = 675 and baa = 1*676 + 0*26 +0*1 = 676

(again, no gap)

Your code uses does correctly so the statement may just be ambiguously worded.

BTW, very clever use of ^!Inc & ^!Dec to do arithmetic! I'll have to

remember that.

I have noted that none of the suggested solutions have done any input data

verification but all assume that each line truly begins with a three (lower

case) alpha character. Your use of ^$GetDocMatchAll("^[a-z]{3}")$ to

extract the sequence codes would seem to offer a simple, one-line way to

verify that assumption: just compare the size of the ^%codes% array to the

line count of the source document.

^!If ^$GetParaCount$ <> %codes0% ^!Continue Input data error - missing

sequence code(s)

Namaste', Art - --- In ntb-clips@yahoogroups.com, "flo.gehrke" <flo.gehrke@...> wrote:
>

My pleasure. Joy

> --- In ntb-clips@yahoogroups.com, "joy8388608" <mycroftj@> wrote:

> >

> > Flo -

> >

> > Very interesting. Your clip is much faster than mine even

> > when I turned ScreenUpdate off. Mine took 41 seconds and

> > yours took 15 for 17550 lines (aaa to zzz with 26 .rr lines

> > removed). Why? I'm not sure...

>

> > Flo -

> >

> > Very interesting. Your clip is much faster than mine even when

> > I turned ScreenUpdate off. Mine took 41 seconds and yours took

> > 15 for 17550 lines (aaa to zzz with 26 .rr lines removed). Why?

> > I'm not sure...

>

> Joy,

>

> I think there are three main reasons for that:

>

> 1. Assigning the whole list to an array

>

> 2. Calculating ^$ConvertTo26$ only twice -- it's done three times in your clip

>

> 3. Gathering up the gaps with ^!Append and outputting them all at once -- no ^!InsertText

>

> > I wrote a quick clip to generate the lines aaa to zzz. Let

> > me know if anyone wants me to post the code.

>

> I put my hand up and would enjoy seeing that clip!

>

> Flo

>

Generate Base 26 numbers

; by Joy

^!Continue This will generate 17576 lines from aaa to zzz.

^!SKIP Leave Screen update on? (Slower...)

^!Setscreenupdate OFF

^!StatusShow Generating sequences aaa to zzz...

; Start with aaa

^!Set %I%=-1

:LoopStart

^!Inc %I%

^!Set %Num%=^%I%

; Find value of first digit (of 3) (will be 0 to 25)

^!Set %x%=^$Calc(INT(^%Num%/676))$

; Convert first digit to letter (will be a to z)

^!Set %B26%=^$DecToChar(^$Calc(^%x%+97)$)$

; adjust value of current number

^!Set %Num%=^$Calc(^%Num% - (^%x%*676))$

; Find value of second digit (of 3) (will be 0 to 25)

^!Set %x%=^$Calc(INT(^%Num%/26))$

; Convert second digit to letter (will be a to z) and append

^!Set %B26%=^%B26%^$DecToChar(^$Calc(^%x%+97)$)$

; adjust value of current number

^!Set %Num%=^$Calc(^%Num% - (^%x%*26))$

; Convert remaining value (0 to 25) to letter (will be a to z) and append

^!Set %B26%=^%B26%^$DecToChar(^$Calc(^%Num%+97)$)$

; Output value

^!InsertText ^%B26%^%NL%

^!If "^%B26%" <> "zzz" LoopStart

^!Sound SystemExclamation