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 Main where | |
import Data.List | |
monkeys = [{-2416, -} 2117, 2085, 2018, 2013, 2010, 2006, 1929, 1749, 1746, 1678, 1622, 1622, 1586, 1543, 1497, 1487, 1445] | |
bishops = [2064, 2052, 2031, 1965, 1935, 1930, 1904, 1808, 1772, 1760, 1732, 1730, 1715, 1676, 1656, 1599, 1550, 1523, 1410] | |
diff :: Num a => [a] -> [a] -> [a] | |
diff = zipWith (-) |
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
// send first ball from (0, 0) to (200, 0) | |
animate(firstBall, 0, 200)(); | |
// send second ball from (0, 0) to (100, 0) but with the tempo like it was sent to (200, 0) | |
animateWithTweak(secondBall, 0, 100, 200)(); | |
function animate(ball, start, intended) { | |
return function () { | |
ball.animate({cx: intended}, 2000, ">"); | |
} |
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
// send first ball from (0, 0) to (200, 0) | |
animate(firstBall, 0, 200)(); | |
// send second ball from (0, 0) to (100, 0) but with the tempo like it was sent to (200, 0) | |
animateWithTweak(secondBall, 0, 100, 200)(); | |
function animate(ball, start, intended) { | |
return function () { | |
ball.animate({cx: intended}, 2000, ">"); | |
} |
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
SSH_ENV="$HOME/.ssh/environment" | |
function start_agent { | |
echo "Initializing new SSH agent..." | |
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" | |
echo succeeded | |
chmod 600 "${SSH_ENV}" | |
. "${SSH_ENV}" > /dev/null | |
/usr/bin/ssh-add; | |
} |
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 Main where | |
d = [3, 4, 9, 14, 15, 19, 28, 37, 47, 50, 54, 56, 59, 61, 70, 73, 78, 81, 92, 95, 97, 99] | |
superset [] = [[]] | |
superset (x:xs) = ss ++ map (x:) ss | |
where ss = superset xs | |
check [] = False | |
check xs = m == sum xs - m where m = maximum xs |
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
primes :: [Integer] | |
primes = sieve [2..] | |
where | |
sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p > 0] | |
main = print $ primes !! 10000 | |
-- compile with `ghc --make primes.hs`, then run run run :) |
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 Main where | |
import Data.List (maximumBy) | |
import Data.Word (Word64) | |
import Data.Array.IO (IOUArray, newArray, readArray, writeArray, unsafeFreeze) | |
import Data.Array.Unboxed (UArray) | |
import Data.Array.IArray (assocs) | |
import Control.Monad (forM_) | |
type Cache = IOUArray Word64 Word64 |
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
(define l_y1 :: int) | |
(define l_y2 :: int) | |
(define l_y3 :: int) | |
(define l_x1 :: int) | |
(define l_x2 :: int) | |
(define l_x3 :: int) | |
(define l_x4 :: int) | |
(assert (<= l_x1 3)) | |
(assert (>= l_x1 0)) |
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 Q where | |
data Quarter = NE | NW | SE | SW deriving Show | |
type Vector = (Float, Float) | |
quarter :: Vector -> Vector -> Quarter | |
quarter look target = detect $ angle look - angle target | |
detect :: Float -> Quarter | |
detect x |
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
import Control.Monad | |
import System.Random | |
import Data.List | |
size :: Int | |
size = 3 | |
steps :: Int | |
steps = 10000 |
OlderNewer