Motivated by a historical combinatorial problem that resembles the well-known Josephus problem, we investigate circular partition algorithms and formulate problems in deterministic finite automata with practical algorithms. The historical problem involves arranging individuals on a circle and eliminating every k-th person until a desired group remains. We analyze both removal and non-removal approaches to circular partitioning, establishing conditions for balanced partitions and providing explicit algorithms. We introduce generalized run-length encodings over partitioned alphabets to capture alternating letter patterns, computing their cardinalities using Stirling numbers of the second kind. Connecting these combinatorial structures to formal language theory, we formulate an existence problem: given a context-free grammar over a dictionary and block-pattern constraints on letters, does a valid sentence exist? We prove decidability in polynomial time by showing block languages are regular and applying standard parsing techniques. Complete algorithms with complexity analysis are provided and validated through implementation on both historical and synthetic instances.
翻译:受一个与著名约瑟夫问题相似的历史组合问题启发,我们研究了循环划分算法,并在确定性有限自动机中构建了具有实用算法的问题。该历史问题涉及将若干个体排列在圆周上,并持续淘汰第k个个体,直至留下期望的群体。我们分析了循环划分的淘汰与非淘汰两种方法,建立了平衡划分的条件,并给出了显式算法。我们引入了基于划分字母表的广义游程编码以捕捉交替字母模式,并利用第二类斯特林数计算其基数。通过将这些组合结构与形式语言理论相联系,我们提出了一个存在性问题:给定字典上的上下文无关文法及字母的块模式约束,是否存在合法句子?我们证明了该问题在多项式时间内可判定,方法是证明块语言是正则的,并应用标准解析技术。我们提供了完整的算法及其复杂度分析,并通过在历史实例与合成实例上的实现进行了验证。