Function Repository Resource:

GrayCodeKSubsets

Source Notebook

Get k-subsets of a given set in minimum change order

Contributed by: Sriram V. Pemmaraju and Steven S. Skiena, submitted by Wolfram staff

ResourceFunction["GrayCodeKSubsets"][l,k]

generates k-subsets of l in Gray code order.

Details and Options

In the list generated by ResourceFunction["GrayCodeKSubsets"], each subset differs from its neighbors by the insertion and deletion of one element.

Examples

Basic Examples (1) 

Get 4-subsets in Gray code order:

In[1]:=
ResourceFunction["GrayCodeKSubsets"][{a, b, c, d, e, f}, 4]
Out[1]=

Version History

  • 1.0.0 – 06 March 2020

Related Resources

License Information