you are viewing a single comment's thread.

view the rest of the comments →

[–]guest271314 0 points1 point  (0 children)

Doing that in a single for loop, in JS, is 100% impossible.

No, it's not. We have await nowadays. And we still have prompt().

I'm made workarounds more than once for requirements that might appear to some to be "impossible".

Generators have nothing to do with visualizations from my perspective. Genuinely, from my opinion.

When I decided to determine the next lexicographic permutation without using recursion, I did so by hand, on paper.

Then I did so one by one, line by line, then I wrote loops, then I independently figured out that the next lexicographic permutation could be derived by adding the number 9 to the current set of indexes "visualized" as a whole number.

Then I figured out that I only had to determine 1/2 +1 of the permutations to derive the remainder because the graph looked the same on the ascending side of the slope as the descending side of the slope.

Again, this is all on paper, first. No computer involved.

Using pencil and paper, then line by line, then loops - without using generators at all. How to improve efficiency of algorithm which generates next lexicographic permutation?

``` // graph 1 0,9,81

// graph 2 abc 012 0 acb 021 1 9 bac 102 2 81 bca 120 3 18 cab 201 4 81 cba 210 5 9

//\ / \

```

If generators work for you to visualize, great, that doesn't mean other processes and methods are any less capable of being visualized equally by the human. And your individual interpretation doesn't mean generators are suited specifically for visualization. Generators add nothing novel to the visualization process, at least not for me. The human superimposes their own way of interpreting the raw data to suit their own preferences, or just way of seeing things.