letters1=[‘a’,‘b’,‘c’].repeated_permutation(1).map(&:join)
letters2=[‘a’,‘b’,‘c’].repeated_permutation(2).map(&:join)
letters3=[‘a’,‘b’,‘c’].repeated_permutation(3).map(&:join)
numbers=[1,2].repeated_permutation(4).map(&:join)

1111 a
1112 b
1121 c
1122 aa
1211 ab
1212 ac
1221 ba
1222 bb
2111 bc
2112 ca
2121 cb
2122 cc
2211 aaa
2212 aab
2221 aba
2222 abb

increasing in depth starting from one… hope this pattern makes more
sense…

the above output is NOW fixed, but this is the output I’m looking for.
I have example code, but its super long and ugly(80 lines)…
I hope some one can simplify this…

i8igmac
November 2, 2015, 11:31pm
2
I don’t really see the link between the two columns.
From the letters, ‘bb’ and ‘cc’ are left out, while from the numbers
1121 is left out.

Földes László wrote in post #1179132:

I don’t really see the link between the two columns.
From the letters, ‘bb’ and ‘cc’ are left out, while from the numbers
1121 is left out.

the output example above is not exact, i wrote this from my phone. I can
update it from my desktop.

[1,2].repeated_permutation(4).map(&:join).size=>16
16 combinations for 2 elements @ four deep
Or
2**4=>16

(“a”,“b”,“c”).repeated_permutation(3).map(&:join).size=>27
Or
31=>3
3 2=>9
3**3=>27
1+9+27

So, I’m trying to generate equal ammount’s for both repeated_permutation
but the a,b,c is increasing in depth until we reach 16…

I have a loop until, 1+9+27 >=16 and then join these blocks…

Here is the best I can do from my android phone.

deep=4
cash=[“a”,“b”,“c”]
hash=[1,2].repeated_permutation(deep).map(&:join)
goal=hash.size
loot=[]
gold=0
cnt=1

until gold>=goal do
gold+=cash.size**cnt
loot+=cash.repeated_permutation(cnt).map(&:join)
cnt+=1
end
cnt-=1

#hash loot
algo=hash.inject({}) { |m, e| t = loot.delete_at(0).split(’,’); m[e] =
t.size > 1 ? t : t[0]+" "; m }