Hello Team I have an array of
def Z = ['a','b','c','d','e','f','g']
how to get all possible 3 alphabet combinations without each element repeat by itself.
Output required: [a.b.c],[a,b,d] and so on but shouldnt have [a,a,a] or [a,a,b] something like this
Hope below link will help
print-all-possible-combinations-of-r-elements-in-a-given-array-of-size-n
Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓
Awesome this helps himanshu.
I have found another way to do it in a simple format.
def Z = ['a','b','c','d','e']
def result =[Z,Z,Z].combinations().findAll{x,y,z -> x<y&y<z}
def result2 = [Z,Z].combinations().findAll{x,y -> x<y}
def finalresult = result + result2
log.info finalresult
result :[[a, b, c], [a, b, d], [a, c, d], [b, c, d], [a, b, e], [a, c, e], [b, c, e], [a, d, e], [b, d, e], [c, d, e], [a, b], [a, c], [b, c], [a, d], [b, d], [c, d], [a, e], [b, e], [c, e], [d, e]]
Hi @akashreuben7 ,
You can accept it as solution, so that it will help others seking for help. 🙂
Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓