extracted lettersAreContinuous from isLegalState and fixed logical bug in lettersAreContiguous