January 2008
Intermediate to advanced
384 pages
8h 1m
English
Mike Whiting asked for code to generate all the possible permutations of a string. This was a popular problem in the British Computer Journal a few decades ago. They published several Algol programs with good discussions at that time. A good reference website is http://portal.acm.orglcitatioN.cfm?id=356692, but you can find others. But because they were written for a procedural programming language, many of the articles focus on the sequence of generation of permutations, rather than just getting the entire set.
Alex Kuznetsov replied with a recursive CTE solution that assumes an auxiliary Sequence table. Begin by setting the :input_str = ’ABCDE’ and running this query:
WITH RECURSIVE Subsets ...
Read now
Unlock full access