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
module Euler1 where | |
{- | |
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
Find the sum of all the multiples of 3 or 5 below 1000. | |
-} | |
import Data.List (nub) |
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
module Euler2 where | |
{- | |
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: | |
1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... | |
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. | |
-} |
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
package com.jnape.dynamiccollection; | |
import com.jnape.dynamiccollection.lambda.Function; | |
import com.jnape.dynamiccollection.list.CachingStream; | |
import com.jnape.dynamiccollection.list.DynamicList; | |
import com.jnape.dynamiccollection.list.Stream; | |
import static com.jnape.dynamiccollection.lambda.library.numeric.accumulator.Add.add; | |
import static com.jnape.dynamiccollection.list.NumericDynamicArrayList.numbers; |
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
module Primes where | |
main :: IO () | |
main = print $ take 1000 primes | |
(√) :: Int -> Int | |
(√) = floor . sqrt . fromIntegral | |
primes :: [Int] | |
primes = 2 : sieve [3, 5..] |
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
module PrimeFactorization where | |
import Data.List | |
primeFactorsOf :: Int -> [Int] | |
primeFactorsOf n = (nub . unfoldr (2 `factorOutOf`)) n | |
where k `factorOutOf` n | |
| n < 2 = Nothing | |
| n `mod` k == 0 = Just (k, n `div` k) | |
| otherwise = (k+1) `factorOutOf` n |
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
module Snippet where | |
import Data.List | |
compress :: String -> String | |
compress = (foldl1 (++)) . (foldl (\acc xs -> acc ++ [(show.length) xs, (head xs):[]]) []) . group | |
compressions :: String -> [String] | |
compressions x = let n = compress x in n:compressions n |
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
module GroupSort ( | |
groupsort | |
) where | |
groupsort :: Ord a => [a] -> [a] | |
groupsort [] = [] | |
groupsort xs = let | |
groups = group xs | |
n = length xs | |
k = length groups |
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
package com.thoughtworks.futureeither | |
import scala.collection.mutable | |
abstract sealed class LoopOutcome { | |
def endOrElse(fn: => Any) = this match { | |
case Repeat() => fn | |
case _ => | |
} |
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 unittest2 import TestCase | |
from mockito import when, unstub | |
from uuid import UUID | |
import uuid | |
def use_mocking(test_suite): | |
wrapped_tearDown = test_suite.tearDown if 'tearDown' in dir(test_suite) else lambda self: True | |
def tearDown(self): |
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
% The person who has to deploy to Mobile is not Max or Sam | |
% Neither Max or Charlie are fans of Copying Files | |
% The one who deploys quarterly does so to a Mobile target | |
% Andy deploys weekly | |
% The person making use of a third party PAAS is not Andy or Charlie | |
% Sam is either the Copying Files or the System Package enthusiast | |
% The person who makes VM Images is not Charlie and doesn’t own deploy to a PAAS | |
% The person who deploys to the PAAS is does so more frequently than the person who deploys to the Desktop | |
% Of the System Packaging fan and Charlie, one deploys monthly and the other deploys to Mobile | |
% The person who deploys to the IAAS is not Max |