2021年4月30日星期五

Find 2 letter or 3 letters from wordlist

I have a 256 wordlist with 8 digits like "DDUUDDUU", "DDDDUUUU", "DDUUUUUU" and I am having a hard time trying to match any combination of 2 or 3 consecutive letters like "UUDDUUUU", "DDDUUDDD"

            foreach (var eachWord in AAAA.Values) {                int iCountU = 0;              int iCountD = 0;              char iLastChar = (char)106;                foreach (char letter in eachWord) {                  if (letter == 'D') {                      if (iCountD < 3) {                          if (letter != iLastChar) {                              iLastChar = letter;                              iCountD = 1;                          } else {                              iCountD += 1;                          }                      }                    }                    if (letter == 'U') {                      if (iCountU < 3) {                          if (letter != iLastChar) {                              iLastChar = letter;                              iCountU = 1;                          } else {                              iCountU += 1;                          }                      }                    }                }                if (iCountU > 2 && iCountD > 2) {                  BBBB[eachWord] = eachWord;              }          }  
https://stackoverflow.com/questions/67341570/find-2-letter-or-3-letters-from-wordlist May 01, 2021 at 07:34AM

没有评论:

发表评论