Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement #1

Open
BertLisser opened this issue Sep 24, 2018 · 0 comments
Open

Improvement #1

BertLisser opened this issue Sep 24, 2018 · 0 comments

Comments

@BertLisser
Copy link

BertLisser commented Sep 24, 2018

-- Permutations have the property that if x is a permutation of y and
-- y is a permutation of z, then x is a permutation of z.
prop4d :: [Int] -> [Int] -> [Int] -> Bool
prop4d x y z
    | isPermutation x y && isPermutation y z && not (isPermutation x z) = False
    | otherwise = True

better

prop4d x y z =  isPermutation x y && isPermutation y z && isPermutation x z
-- Derangements have the property that if x is a derangement of y and y is
-- a derangement of z and x not equal to z, then x is a derangement of z.
prop5d :: [Int] -> [Int] -> [Int] -> Bool
prop5d x y z
    | isDerangement x y && isDerangement y z && not (isDerangement x z) && x /= z = False
    | otherwise = True

Counter example
x=[1,2,3,4] y=[4,3,1,2] y=[3,1,2,4] z= [1,2,4,3] x=[1,2,3,4] z=[1,2,4,3]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant