Guest User

Untitled

a guest
Mar 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. 1 1 5 1 2 1
  2.  
  3. 11 5 1 2 1
  4. 1 15 1 2 1
  5. 1 1 51 2 1
  6. 1 1 5 12 1
  7. 1 1 5 1 21
  8.  
  9. function pc_permute($items, $perms = array( )) {
  10. if (empty($items)) {
  11. print join(' ', $perms) . "n";
  12. } else {
  13. for ($i = count($items) - 1; $i >= 0; --$i) {
  14. $newitems = $items;
  15. $newperms = $perms;
  16. list($foo) = array_splice($newitems, $i, 1);
  17. array_unshift($newperms, $foo);
  18. pc_permute($newitems, $newperms);
  19. }
  20. }
  21. }
  22. print_r(pc_permute($ns));
Add Comment
Please, Sign In to add comment