Ruby get permutations of all lengths from a string in order
问题 Here's my code- $arr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-" def scan(f) begin if f.size == 6 exit end $arr.each_char do |y| t = f + y puts t scan(t) end end end I wish to print all permutations and lengths upto 6, I've tried this recursive approach. The output I get is - A AA AAA AAAA AAAAA However I seek something like this- A AA AB AC . . AZ AAA AAB . . AAZ . . upto 6 chars On commenting the recursive call I see that it prints AA AB AC . . Which is fine without