I have a task to create unique groups of 7 elements from an array of 49 and determine the number of possible outputs.
For example: [A,a,B,b,C,c,D,d,E,e,F,f,G,g,H,h,I,i,J,j,K,k,L,l,M,m,N,n,O,o,P,p,Q,q,R,r,S,s,T,t,U,u,V,v,W,w,X,x,Y]
The desired outputs are: [ [A,a,B,b,C,c,D], [a,B,b,C,c,D,d], [B,b,C,c,D,d,E], [b,C,c,D,d,E,e], . . . [A,C,c,D,d,E,e], [A,B,b,c,D,d,E], . . . ] How can I achieve this output? Below is my attempt based on advice received from stackoverflow:
let jar = ["A","a","B","b","C","c","D","d","E","e","F","f","G","g","H","h","I","i","J","j","K","k","L","l","M","m","N","n","O","o","P","p","Q","q","R","r","S","s","T","t","U","u","V","v","W","w","X","x","Y"];
const size = 7;
let result11 = [];
for(let i = 0; i <= (jar.length - size); i++){
result11.push(jar.slice(i, size+i));
}
console.log(result11)
Each output should be unique without any repetition. For example, outputs like aaaaaaa, aaxxxYY, AAAAAAA, AABbcDe are not valid, but outputs like avWwXxY, bvWwXxY, cvWwXxY, among others, are acceptable.