GithubHelp home page GithubHelp logo

software-testing's People

Contributors

bapostma avatar grammarware avatar kevinvancleef avatar leonardpunt avatar

Watchers

 avatar  avatar  avatar

software-testing's Issues

Week 6: if you have read this and you have no questions, please close this issue.

.
This is good-looking, clear, concise report, you did he bonus, and
used the right definition of Carmichael numbers (++).

A few remarks:

I don't believe your remark. Factorisation of large numbers is very expensive.
I bet that on the large run compositesAlternative wins.

composites :: [Integer]
composites = composite_sieve [2..]
-- Get all composite numbers from an inputted integer list.
composite_sieve :: [Integer] -> [Integer]
composite_sieve xs = [i | i <- xs, head (factors i) /= i]
-- Credits to Ferry for optimalisation.

-- This function is implemented according the hints in the assignment, but the function above is much faster
compositesAlternative :: [Integer]
compositesAlternative = [x | (x,False) <- sieveComposites [(i,True) | i <- [2..]]]

sieveComposites :: [(Integer,Bool)] -> [(Integer,Bool)]
sieveComposites ((i,False):ibs) = (i,False) : sieveComposites ibs
sieveComposites ((i,True):ibs) = (i,True) : sieveComposites (map (\ (n,b) -> (n, b && rem n i /= 0)) ibs)

This is very good observatiion.

- Results of testing:
-- testF 1 carmichael -> seems to return all CarMicheal numbers
-- testF 2 carmichael -> seems to return all CarMicheal numbers
-- testF 5 carmichael -> does not return the first CarMicheal number (294409) as a number that fools Fermat's little theory

-- So if 'k' gets higher, not all CarMicheal numbers are returned as numbers that fool Fermat's little theory. This is because
-- Fermat's little theory states that prime numbers have the property a^p = a (mod p). CarMicheal numbers have the property
-- a^p = a (mod p) too, however 'a' and 'p' have to be relatively prime (i.e. gcd has to be 1). So if we find an 'a' that is
-- not relatively prime with 'p', is does not pass Fermat's prime check. The higher 'k' gets, the higher the probability we
-- find such an 'a'.

This routine doesn't terminate. Why not testing from which primes
are connected to Mersenne Primes (see Answers Week 6).

-- Precondition: input is a prime number
mersennePrimes :: Integer -> IO ()
mersennePrimes p = do
  print(show p)
  let p1 = (2^p - 1) in
    do
      r <- primeMR 5 p1
      when r $ mersennePrimes p1

Week 4: if you have read this and you have no questions, please close this issue.

-- 3.1
Opg 3

intersectSet :: Ord a => Set a -> Set a -> Set a
intersectSet (Set xs) (Set ys) = list2set (intersect xs ys)

-- 3.3
differenceSet :: Ord a => Set a -> Set a -> Set a
differenceSet (Set xs) (Set ys) = list2set (xs \\ ys)

Better not use the internal representation of Set

Opg 4

- Written code (as lambda)
trClos :: Ord a => Rel a -> Rel a
trClos x = lfp (\ x -> nub (x ++ (x @@ x))) x

-- Alternative implementation of trClos
trClosAlternative :: Ord a => Rel a -> Rel a
trClosAlternative [] = []
trClosAlternative r | uhm == r = r
                    | otherwise = trClosAlternative uhm
                    where uhm = nub (r ++ (r @@ r))

{-|
Exercise 5
-}
-- Properties
-- A relation R is transitive if R^2 is subset of R
transitiveProp1 :: Ord a => Rel a -> Bool
transitiveProp1 r = containsSubSet r (r @@ r)

containsSubSet :: Eq a => Rel a -> Rel a -> Bool
containsSubSet r = all (\ x -> elem x r)

OK!!!!
Opg 5

1. Properties:
-- - a relation R is transitive if R^2 is subset of R
transitiveProp1 :: Ord a => Rel a -> Bool
transitiveProp1 r = containsSubSet r (r @@ r)

containsSubSet :: Eq a => Rel a -> Rel a -> Bool
containsSubSet r = all (\x -> elem x r)

The is also a property called minimality: There exists a tuple in trClos(R) at which the trClos minus that tuple
is not transitive any more.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.