Skip to content

Instantly share code, notes, and snippets.

@r2k0
Created October 20, 2014 01:21
Show Gist options
  • Select an option

  • Save r2k0/ad18d9a8dcbd7420133e to your computer and use it in GitHub Desktop.

Select an option

Save r2k0/ad18d9a8dcbd7420133e to your computer and use it in GitHub Desktop.

Revisions

  1. r2k0 created this gist Oct 20, 2014.
    8 changes: 8 additions & 0 deletions permutations
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    >>> from itertools import permutations
    >>> perms = [''.join(p) for p in permutations('hat')]
    >>> perms
    ['hat', 'hta', 'aht', 'ath', 'tha', 'tah']
    >>> print sorted(perms)
    ['aht', 'ath', 'hat', 'hta', 'tah', 'tha']
    >>> print ','.join(sorted(perms))
    aht,ath,hat,hta,tah,tha