Skip to main content
added 277 characters in body
Source Link
Scott
  • 1.1k
  • 6
  • 12

Pyth, 1313 11 bytes

WnSQKO.pQ;K

Previous Solution

L?n.SbSbybb
y

Try it online!Try it online!

WnSQKO.pQ;K
      .pQ    Generate a list of all permutations of input
    KO.pQ    K = random permutation in the list
WnSQK    ;   While(sorted(input) != K): do nothing
          K  print K

CompiledPrevious Solution:
Compiled to python:

assign('Q',eval_input())
@memoized
def subsets(b):
 return (subsets(b) if ne(shuffle(b),Psorted(b)) else b)
imp_print(subsets(Q))

Basically:
Shuffle the list, if it isn't equal to the sorted list:
recursively call.
Else:
Return it

Pyth, 13 bytes

L?n.SbSbybb
y

Try it online!

Compiled to python:

assign('Q',eval_input())
@memoized
def subsets(b):
 return (subsets(b) if ne(shuffle(b),Psorted(b)) else b)
imp_print(subsets(Q))

Basically:
Shuffle the list, if it isn't equal to the sorted list:
recursively call.
Else:
Return it

Pyth, 13 11 bytes

WnSQKO.pQ;K

Previous Solution

L?n.SbSbybb
y

Try it online!

WnSQKO.pQ;K
      .pQ    Generate a list of all permutations of input
    KO.pQ    K = random permutation in the list
WnSQK    ;   While(sorted(input) != K): do nothing
          K  print K

Previous Solution:
Compiled to python:

assign('Q',eval_input())
@memoized
def subsets(b):
 return (subsets(b) if ne(shuffle(b),Psorted(b)) else b)
imp_print(subsets(Q))

Basically:
Shuffle the list, if it isn't equal to the sorted list:
recursively call.
Else:
Return it

Source Link
Scott
  • 1.1k
  • 6
  • 12

Pyth, 13 bytes

L?n.SbSbybb
y

Try it online!

Compiled to python:

assign('Q',eval_input())
@memoized
def subsets(b):
 return (subsets(b) if ne(shuffle(b),Psorted(b)) else b)
imp_print(subsets(Q))

Basically:
Shuffle the list, if it isn't equal to the sorted list:
recursively call.
Else:
Return it