Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: generating permutations

by tybalt89 (Monsignor)
on Mar 29, 2017 at 17:42 UTC ( [id://1186408]=note: print w/replies, xml ) Need Help??


in reply to generating permutations

#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1186402 use strict; use warnings; $_ = 12345; 1 while print, s/.*\K # find the last (.) # digit such that (.*) # there is a later (latest) (.)(??{$1 > $3 and 'x'}) # digit greater than it (.*) # and get rest # swap those two digits ( $1 & $3 ) # then reverse everything after the first swapped digit / $3 . reverse $2.$1.$4 /xe

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1186408]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-26 04:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found