jeudi 15 mai 2014

how to count conditioned continuous values in a list with linq? (Revized)


Vote count:

0




I've asked a question some time ago -> how to count conditioned continuous values in a list with linq?


This question answered by @Fung. However, I changed some rules of the question. The new conditions:


So, Can I find how much indexes have "0" value continuously and which are their indexes - even if interrupts by "1, 2 and 3" (not 4) - ? For example;



query[480]=query[481]=query[482]....query[749] = 0,
query[750]=query[751]...query[809] = 1,
query[810]=query[811]....query[999] = 0,
query[1000]?query[1001]...query[1079] = 2,
query[1080]=query[1081]....query[1099] = 0,
query[1100]=query[1101]....query[1199] = 1,
query[1200]=query[1201]....query[1299] = 0, etc..


So, the answer is 270 (before 1) + 190 (after 1) = 460 Although between 1080 and 1099 indexes have 0, they should not be considered because previous values are "2".


In addition, values that from 1080 to 1099 and from 1200 to 1299, should be considered, because they have also new 0 - 1 - 0 serie. And, this serie should be taken another list. Is there a way to accomplish this?



asked 33 secs ago






Aucun commentaire:

Enregistrer un commentaire