Skip to content

Instantly share code, notes, and snippets.

View kirca's full-sized avatar

Kiril Vangelovski kirca

  • Skopje, Macedonia
View GitHub Profile
@kirca
kirca / shell.nix
Created May 14, 2022 23:58
Odoo nix shell
with import <nixpkgs> {};
let
pythonEnv = python39.withPackages (ps: [
ps.numpy
ps.toolz
ps.Babel
ps.chardet
ps.decorator
ps.docutils
ps.ebaysdk
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
@kirca
kirca / mergesort.py
Last active August 29, 2015 14:24
Mergesort in Python, autogenerated test data with hypothesis
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
@kirca
kirca / mergeSort.hs
Last active August 29, 2015 14:24
Mergesort in Haskell
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)