Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
find differences
#1
suppose that i have 2 arrays:
an array b[i] with i=0...7, (b=before) with for example
b0="00000000"
b1="00000000"
b2="00000000"
b3="00000000"
b4="00010000"
b5="00000000"
b6="11101111"
b7="11111111"


and an array a[i] with i=0...7, (a=after) with for example
a0="00000000"
a1="00000000"
a2="00000000"
a3="00000000"
a4="00010000"
a5="00100000"
a6="11001111"
a7="11111111"


In my mind, there is only 1 or 2 changes maximum, i mean only one or two 1 in b that will change of position and give the a array! it is very important, so i ask (and i thank if it is possible!) for a code that would be fast : there is no need to test all 8x8=64 positions in b array, only positions of 1 in the array b !!! only one or two 1 in the b array will change position!

So: I want to find the position of change(s) betwenn before (b) and after (a), i mean:
find all i and j such that bi(j)=1 AND ai(j)=0 (there is only 1 or 2 different such i maximum)
find all k and l such that bk(l)=0 AND ak(l)=1

in my example: i=6 and j=2 and k=5 and l=2



I hope you will understand my query, else please ask questions, it is very exciting and fun for me!
#2
for i 0 b.len
,if(a[i]!=b[i])
,,for(j 0 8)
,,,if(a[i][j]!=b[i][j]) ...

It is not very fast in QM. Particularly the last line.
#3
str s="r1bqkb1r/pppp1ppp/2n2n2/4p3/4P3/3P4/PPPN1PPP/R1BQKBNR w KQkq -"


how to get t[0]="r1bqkb1r"
t|1]="pppp1ppp"
t[2]="2n2n2"
---
t[7]="R1BQKBNR"

?


then i want to create an array called d with d[0] --- d[7] lists such that:

for i 0 7

,for j 0 t[i].len (maybe not t[i].len !!)

,,if t[i][j] is a min (small) character, then augment d[i] with the position of t[i][j] in t[i] when we understand t[i] like a string with 8 character ( for example understand t[0] as r0bqkb0r and t[2] as 00n00n00 ...)


so i want to get : d[0]="0,2,3,4,5,7" d[1]="0,1,2,3,5,6,7" d[2]="2,5" ...





if you can do this, my code will be faster than previous you gave me...

Thanks!!
#4
here is my idea, but please tell me the correct code Smile



str s="r1bqkb1r/pppp1ppp/2n2n2/4p3/4P3/3P4/PPPN1PPP/R1BQKBNR w KQkq -"


get t[0]="r1bqkb1r"
t|1]="pppp1ppp"
t[2]="2n2n2"
---
t[7]="R1BQKBNR"



then i want to create an array called d with d[0] --- d[7] lists such that:

for i 0 7

,k=0 #k will be the position of min characters in t[i]

,for j 0 t[i].len

,,if t[i][j] is a number (like 1 or 2) then k=k+length(t[i][j]) -1

,,else if t[i][j] is a min character (like r,b,q ..) then put k in the list d[i]

,k=k+1







something like this should work, what do you think about it?


Forum Jump:


Users browsing this thread: 1 Guest(s)