Topswops: Difference between revisions
m
→Searching derangements: Tidying, updated output.
m (→Searching permutations: hindent, tidying) |
m (→Searching derangements: Tidying, updated output.) |
||
Line 995:
<br>Uses only permutations with all elements out of place.
<lang Haskell>import Data.List (permutations, inits)
import Control.Arrow (first)
derangements :: [Int] -> [[Int]]
derangements = (\x -> filter
topswop :: Int -> [a] -> [a]
topswop x xs =
topswopIter :: [Int] -> [[Int]]
Line 1,016 ⟶ 1,015:
main = mapM_ print $ take 10 $ topSwops [1 ..]</lang>
'''Output'''
<pre>(1,0)▼
▲(1,0)
(2,1)
(3,2)
|