Topswops: Difference between revisions

m
m (→‎{{header|Potion}}: Fix comment: Perl 6 --> Raku)
m (→‎Searching permutations: hindent, tidying)
Line 971:
topswops :: Int -> Int
topswops n = maximum $ map tops $ permutations [1 .. n]
where
tops (1 : _) = 0
tops xa@(x : _) = 1 + tops reordered
where
reordered = reverse (take x xa) ++ drop x xa
 
main = mapM_
mapM_ (putStrLn . (\x(++) -<$> putStrLn $ show x ++<*> (":\t" ++) . show (topswops. xtopswops)) [1 .. 10]</lang>
[1 .. 10]</lang>
{{out}}
<pre>1: 0
9,655

edits