Re: Need help to write routine - Please
- Posted by Juergen Luethje <j.lue at gmx.de> Aug 29, 2003
- 389 views
Tony wrote: > Hello all, > Firstly thanks in advance to anyone who may be able to help. > I need help writing a routine. My main problem is that data may vary > greatly. This is to help me with a master key program (I am a locksmith) > so if anyone can spare a little time I would appreciate it. > > Firstly lets start with the sequence of 0 5 3 4 1 1 - This is not a > number but individual characters, it could just as easily be alpha > characters. The length of this sequence may be anything from 4 to 12 > characters. > Next I specify the parts of the sequence that will change. > > 0 5 3 4 1 1 > X X > > X indicates the column to change. > I then create a list of characters to change. Again the number of > columns to change may vary from 1 to all. > > 0 5 3 4 1 1 > X X > 1 0 > 3 2 > 7 6 > 9 8 > > Now the routine needs to calculate the new sequences. > Which are: > 0 1 3 0 1 1 > 0 1 3 2 1 1 > 0 1 3 6 1 1 > 0 1 3 8 1 1 > 0 3 3 0 1 1 > 0 3 3 2 1 1 > 0 3 3 6 1 1 > 0 3 3 8 1 1 > 0 7 3 0 1 1 > 0 7 3 2 1 1 > 0 7 3 6 1 1 > 0 7 3 8 1 1 > 0 9 3 0 1 1 > 0 9 3 2 1 1 > 0 9 3 6 1 1 > 0 9 3 8 1 1 > > Note the first sequence changes both columns but after that only one > column changes at a time. > > I'll also show you part of another series if three columns were to be > changed: > 0 5 3 4 1 1 > X X X > 1 0 3 > 3 2 5 > 7 6 7 > 9 8 9 > > Now the routine needs to calculate the new sequences. > Which are: > 0 1 3 0 3 1 > 0 1 3 0 5 1 > 0 1 3 0 7 1 > 0 1 3 0 9 1 > 0 1 3 2 3 1 > 0 1 3 2 5 1 > 0 1 3 2 7 1 > 0 1 3 2 9 1 > 0 1 3 6 3 1 > 0 1 3 6 5 1 > 0 1 3 6 7 1 > 0 1 3 6 9 1 > 0 1 3 8 3 1 > 0 1 3 8 5 1 > 0 1 3 8 7 1 > 0 1 3 8 9 1 > 0 3 3 0 3 1 > 0 3 3 0 5 1 > 0 3 3 0 7 1 > 0 3 3 0 9 1 > and so on > As you can see when changing more columns more sequences are possible. > > Thanks, > > Tony Steward This seems to work as expected: --------------------=-----------------------------=-------------------- sequence mainSequence, positionsToChange, newValues integer Level procedure change () for posn = 1 to length(newValues[Level]) do mainSequence[positionsToChange[Level]] = newValues[Level][posn] if Level < length(positionsToChange) then Level += 1 change() Level -= 1 else ? mainSequence end if end for end procedure mainSequence = {0,5,3,4,1,1} positionsToChange = {2,4} newValues = { {1,3,7,9}, {0,2,6,8} } Level = 1 change() --------------------=-----------------------------=-------------------- Regards, Juergen -- /"\ ASCII ribbon campain | |\ _,,,---,,_ \ / against HTML in | /,`.-'`' -. ;-;;,_ X e-mail and news, | |,4- ) )-,_..;\ ( `'-' / \ and unneeded MIME | '---''(_/--' `-'\_)