This file contains hidden or 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 Phone where | |
import Data.Char (isUpper, toLower) | |
import Control.Arrow | |
import Data.List (maximumBy) | |
type Digit = Char | |
type Presses = Int | |
type Key = (Digit, String) |
This file contains hidden or 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
import Test.QuickCheck | |
import Data.List | |
import Data.Monoid | |
prop_revapp :: [Int] -> [Int] -> Bool | |
prop_revapp xs ys = reverse (ys++xs) == reverse xs ++ reverse ys | |
quotVsRem :: Integral a => a -> a -> Bool | |
quotVsRem x y = quot x y * y + rem x y == x |
This file contains hidden or 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
import Test.QuickCheck | |
import Test.QuickCheck.Function | |
prop_revapp :: [Int] -> [Int] -> Bool | |
prop_revapp xs ys = reverse (ys++xs) == reverse xs ++ reverse ys | |
data Two a b = Two a b deriving (Eq, Show) | |
data Or a b = First a | Second b deriving (Eq, Show) | |
instance Functor (Two a) where |
This file contains hidden or 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
newtype Constant a b = Constant { getConstant :: a } deriving (Eq, Ord, Show) | |
instance Functor (Constant a) where | |
fmap _ (Constant a) = Constant a | |
instance Monoid a => Applicative (Constant a) where | |
pure x = Constant mempty | |
(<*>) (Constant a) (Constant b) = Constant (a <> b) |
This file contains hidden or 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 interview; | |
/** | |
* Created by yannickgrenzinger on 02/12/2016. | |
*/ | |
public class Executor { | |
private final Printer3D printer = new Printer3D(); | |
private final XMLFileReader reader = new XMLFileReader(); |
This file contains hidden or 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(week1). | |
-export([perimeter/1,area/1,enclose/1, bitsD/1, bitsT/1]). | |
% I don't use Erlang Unit test http://erlang.org/doc/apps/eunit/chapter.html | |
% Because I don't know how to setup a project with dependancies at this point | |
% Each shape is defined by it's name, some general info and some points | |
perimeter({circle,R, _CenterPoint}) -> | |
2 * math:pi() * R; | |
perimeter({rectangle,W,H, _Points}) -> |
This file contains hidden or 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 interview; | |
import com.google.common.collect.Sets; | |
import org.junit.Test; | |
import java.util.*; | |
import static org.assertj.core.api.Assertions.assertThat; | |
This file contains hidden or 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(week2). | |
-export([get_file_contents/1,show_file_contents/1, processText/1]). | |
-include_lib("eunit/include/eunit.hrl"). | |
isAlphabetical(X) -> | |
($A =< X andalso X =< $Z) or ($a =< X andalso X =< $z). | |
isAlphabetical_test() -> | |
?assertEqual(true, isAlphabetical($G)), | |
?assertEqual(true, isAlphabetical($g)), |
This file contains hidden or 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(week2). | |
-export([get_file_contents/1,show_file_contents/1, processText/1]). | |
-include_lib("eunit/include/eunit.hrl"). | |
isAlphabetical(X) -> | |
($A =< X andalso X =< $Z) or ($a =< X andalso X =< $z). | |
isAlphabetical_test() -> | |
?assertEqual(true, isAlphabetical($G)), | |
?assertEqual(true, isAlphabetical($g)), |
This file contains hidden or 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
;; https://leetcode.com/problems/invert-binary-tree/?tab=Description#/description | |
;; exemple of a graph [[[1] 2 [3]] 4 [[6] 7 [9]]] | |
(defn invert [tree] | |
(if (< (count tree) 2) | |
tree | |
[(invert (nth tree 2)) (nth tree 1) (invert (nth tree 0))])) |