This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; | |
let | |
pythonEnv = python39.withPackages (ps: [ | |
ps.numpy | |
ps.toolz | |
ps.Babel | |
ps.chardet | |
ps.decorator | |
ps.docutils | |
ps.ebaysdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isPrime :: Int -> Bool | |
isPrime n = null $ dropWhile (not . (n `isDivisableWith`)) [2..n-1] | |
isDivisableWith :: Int -> Int -> Bool | |
isDivisableWith a b = a `mod` b == 0 | |
primes = filter isPrime [1..] | |
largestPrimeFactor :: Int -> Int | |
largestPrimeFactor 1 = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from hypothesis import given | |
from hypothesis.strategies import lists, integers | |
def mergesort(lst): | |
def merge(l1, l2): | |
if not l1: | |
return l2 | |
if not l2: | |
return l1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mergeSort :: Ord a => [a] -> [a] | |
mergeSort [] = [] | |
mergeSort (x:[]) = (x:[]) | |
mergeSort xs = merge (mergeSort (fst (halfList xs))) (mergeSort (snd (halfList xs))) | |
where halfList xs = (take (div len_xs 2) xs, drop (div len_xs 2) xs) | |
where len_xs = length xs | |
merge [] [] = [] | |
merge [] ys = ys | |
merge xs [] = xs | |
merge (x:xs) (y:ys) |