Function Repository Resource:


Source Notebook

Get subsets of a given set in minimum change order

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


gives a binary reflected Gray code on set l.

Details and Options

Gray code order is a minimum change order.
ResourceFunction["GrayCodeSubsets"] returns a list in which adjacent subsets differ by the insertion or deletion of exactly one element.


Basic Examples (1) 

In a Gray code, each subset differs in exactly one element from its neighbors:

ResourceFunction["GrayCodeSubsets"][{1, 2, 3}]

Version History

  • 1.0.0 – 06 March 2020

Related Resources

License Information