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
void drawFolder(int sides, float rad) { | |
float ang = (frameCount * 2 * PI * 0.05) / sides; | |
PVector maxy = new PVector(0, 0); | |
PVector[] v = new PVector[sides]; | |
for (int i = 0; i != v.length; ++i) { | |
float angle = ((2 * PI * i) / sides) + ang; | |
float x = sin(angle) * rad; |
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
void setup() { | |
size(500, 500, P3D); | |
frameRate(25); | |
blendMode(ADD); | |
ortho(); | |
} | |
void draw() { | |
background(0); | |
noFill(); |
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.Applicative | |
data Vec2 a = Vec2 (a, a) deriving (Eq, Show) | |
instance Functor Vec2 where | |
fmap f (Vec2 (x, y)) = Vec2 (f x, f y) | |
instance Applicative Vec2 where | |
pure x = Vec2 (x, x) | |
(Vec2 (f, g)) <*> (Vec2 (x, y)) = Vec2 (f x, g y) |
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.Applicative | |
import Data.Maybe | |
import Debug.Trace | |
data Board = Board [[Bool]] | |
deriving (Eq, Show) | |
newBoard :: Board | |
newBoard = newBoard' 8 8 | |
where newBoard' x y = Board $ take y $ repeat $ take x $ repeat False |
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
void line(PVector p, PVector q) {line(p.x, p.y, q.x, q.y);} | |
class Line { | |
private PVector i, j; | |
float a, b, c; | |
Line(PVector i_, PVector j_) { | |
i = i_; j = j_; | |
recalc(); | |
} |
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
// | |
// HASKELL | |
// | |
matches i (num, den) | i == 0 = 0 | |
| g (num' + den') > g den' = 1 + f | |
| otherwise = f | |
where num' = den | |
den' = num + (2 * den) | |
f = matches (i - 1) (num', den') |
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 Data.Char (digitToInt) | |
main = print $ maximum [sum $ map digitToInt $ show (a ^ b) | a <- [1..100], b <- [1..100]] |
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
solve = isLychrel 0 | |
where isLychrel i x | d == reverse d = False | |
| i > 50 = True | |
| otherwise = isLychrel (i + 1) c | |
where b = reverse $ show x | |
c = (x + (read b :: Integer)) | |
d = show c | |
main = print $ length $ filter (== True) $ map solve [1..9999] |
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 Matrix where | |
import Control.Applicative | |
import Data.List | |
data Matrix a = Matrix [[a]] | |
deriving (Eq, Show) | |
instance Functor Matrix where | |
fmap f (Matrix x) = Matrix $ fmap (fmap f) 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
class Ray { | |
private PVector origin = new PVector(); | |
private PVector direction = new PVector(); | |
private float length = MAX_FLOAT; | |
Ray(PVector o, PVector d) { | |
setorigin(o); | |
setdirection(d); | |
} | |
NewerOlder