Skip to content
Related Articles

Related Articles

SymPy | Subset.prev_lexicographic() in Python

Improve Article
Save Article
Like Article
  • Last Updated : 26 Aug, 2019

Subset.prev_lexicographic() : prev_lexicographic() is a sympy Python library function that returns the previous lexicographically ordered subset.

Syntax :
sympy.combinatorics.subset.Subset.prev_lexicographic()

Return :
the previous Gray code ordered subset.

Code #1 : prev_lexicographic() Example




# Python code explaining
# SymPy.Subset.prev_lexicographic()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.prev_lexicographic()
  
# Creating Subset
a = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])
  
# prev_lexicographic value
print ("Subset a prev_lexicographic : ", a.prev_lexicographic().subset)

Output :

Subset a prev_lexicographic : [‘c’]

Code #2 : prev_lexicographic() Example




# Python code explaining
# SymPy.Subset.prev_lexicographic()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.prev_lexicographic()
  
# Creating Subset
a = Subset([2, 3, 4], [1, 2, 3, 4, 5])
  
# prev_lexicographic value
print ("Subset a prev_lexicographic : ", a.prev_lexicographic().subset)

Output :

Subset a prev_lexicographic : [2, 3]


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!