Ruby Editor times out with certain code

It looks like Exercism’s running Ruby 3.0.2 in the online editor. I’m working on the Anagram exercise, and I’m running into an error where the editor times out. It’s happening when running permutation on a three element array of values with six characters, leading to an array of 2160 strings.

I was using this code and it resulted in this error message. I was able to find a solution that didn’t use all that space, but I wanted to give a heads up that
words.map {|word| word.chars.permutation.map(&:join) }.flatten on an array ["lemons", "cherry", "melons"] is all that’s needed to cause the timeout.

Looping over Permutation is not fast, so unless needed it should be avoided.

That makes sense, as does the timeout message given. Looking it over again, it’s a good enough of a hint. Thanks @Meatball

You can mark this conversation as answered.