necklaces

Good simple algorithm for generating necklaces in Scheme?

自闭症网瘾萝莉.ら 提交于 2019-12-12 08:48:31
问题 A k-ary necklace of length n is an ordered list of length n whose items are drawn from an alphabet of length k, which is the lexicographically first list in a sort of all lists sharing an ordering under rotation. Example: (1 2 3) and (1 3 2) are the necklaces of length 3 from the alphabet {1 2 3}. More info: http://en.wikipedia.org/wiki/Necklace_(combinatorics) I'd like to generate these in Scheme (or a Lisp of your choice). I've found some papers... Savage - A New Algorithm for Generating

Good simple algorithm for generating necklaces in Scheme?

强颜欢笑 提交于 2019-12-04 05:20:14
A k-ary necklace of length n is an ordered list of length n whose items are drawn from an alphabet of length k, which is the lexicographically first list in a sort of all lists sharing an ordering under rotation. Example: (1 2 3) and (1 3 2) are the necklaces of length 3 from the alphabet {1 2 3}. More info: http://en.wikipedia.org/wiki/Necklace_(combinatorics) I'd like to generate these in Scheme (or a Lisp of your choice). I've found some papers... Savage - A New Algorithm for Generating Necklaces Sawada - Generating Bracelets in Constant Amortized Time Sawada - Generating Necklaces with

Is there an algorithm to generate all unique circular permutations of a multiset?

a 夏天 提交于 2019-11-27 03:22:40
问题 I encountered this problem when doing some enthusiastic programming. The problem can be expressed as follows: For a multiset A, let P(A) denote the set of all possible permutations of A. P(A) is naturally divided into disjoint subsets that are equivalence classes, with the equivalence relation being "can be related by circular shifts." Enumerate all these equivalence classes by generating exactly one member from each of them. For example, consider the multiset {0, 1, 1, 2}. The permutations