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
repeatChar char times = take times (repeat char) | |
filledLine = repeatChar '*' | |
dashedLine = repeatChar '-' | |
emptyLine = repeatChar ' ' | |
hollowLine width = take width ("*" ++ (emptyLine (width - 2)) ++ "*") | |
topLine width = take width ("/" ++ (emptyLine (width - 2)) ++ "\\") | |
bottomLine width = take width ("\\" ++ (emptyLine (width - 2)) ++ "/") |
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
let greeting="Hello Universe"; | |
console.log(greeting); |
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
data Tree a = EmptyTree | Node a (Tree a) (Tree a) deriving (Show) | |
createTree :: (Ord a) => a -> Tree a | |
createTree x = Node x EmptyTree EmptyTree | |
insert :: (Ord a) => Tree a -> a -> Tree a | |
insert EmptyTree x = Node x EmptyTree EmptyTree | |
insert (Node x left right) y | |
| x == y = Node x left right | |
| x > y = Node x (insert left y) right |
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
by6 :: Int -> [Int] | |
by6 n = [(6*n)-1,(6*n)+1] | |
genPrimeCandidates :: Int -> [Int] | |
genPrimeCandidates n = (by6 n) ++ genPrimeCandidates (n+1) | |
primeCandidates :: [Int] | |
primeCandidates = [2,3] ++ (genPrimeCandidates 1) | |
primeCandidatesBelow :: Int -> [Int] |
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
(def -directions [:N :E :S :W :N]) | |
(defn position [c h] | |
{:co-ord c :heading h}) | |
(def moves {:N [identity inc] | |
:E [inc identity] | |
:S [identity dec] | |
:W [dec identity]}) |
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
(defn sqr [x] (* x x)) | |
(defn winning-combinations [size-of-grid] | |
(let [indices (range 1 (inc (sqr size-of-grid))) | |
rows (partition size-of-grid indices) | |
cols (apply map list rows) | |
diagonal-1 (take-nth (inc size-of-grid) indices) | |
diagonal-2 (take-nth (dec size-of-grid) | |
(range size-of-grid (sqr size-of-grid)))] | |
(map set (concat rows cols [diagonal-1 diagonal-2])))) |
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
(def koch-curve-right-angles | |
{:productions {\F "F+F-F-F+F"}, | |
:axiom "F", | |
:iterations 3, | |
:actions {\F '(FD 20) | |
\+ '(LT 90) | |
\- '(RT 90)}}) | |
(def sierpenski-triangle | |
{:productions {\F "F-G+F+G-F" |
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
;; I've watched most, if not all of these. | |
Korean: | |
Oldboy | |
Sympathy for Mr Vengeance | |
Sympathy for Lady Vengeance | |
Bakjwi | |
JSA | |
Memories of Murder | |
Man From Nowhere |
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
(defn max-adjacents [coll] | |
(map max coll (rest coll))) | |
(defn sum-of [prev current] | |
(map + current (max-adjacents prev))) | |
(defn max-path-sum [tree] | |
(first (reduce sum-of (reverse tree)))) | |
;; To test use the following |
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
(defn pow [x y] | |
(loop [i y k 1N] | |
(if (zero? i) | |
k | |
(recur (dec i) (* k x))))) | |
(count (into #{} | |
(for [a (range 2 101) | |
b (range 2 101)] | |
(pow a b)))) |