Skip to content

Instantly share code, notes, and snippets.

View siddMahen's full-sized avatar

Siddharth Mahendraker siddMahen

  • Toronto, Canada
View GitHub Profile
3375
3376
3408
3409
3410
3411
3447
4822
4823
4824
function swap_col(A, i, j)
col_i = A[:,i]
col_j = A[:,j]
A[:,i] = col_j
A[:,j] = col_i
end
function swap_row(A, i, j)
row_i = A[i,:]
using Compose
function koch_side(n)
if n == 1
return compose(context(),
line([(0,1),(1/3,1),(1/2, 1 - (sin(pi/3)/3)),(2/3,1),(1,1)]))
else
ks = koch_side(n - 1)
return compose(context(),
(context(0,2/3,1/3,1/3), ks),
@siddMahen
siddMahen / koch.jl
Last active August 29, 2015 14:22
Drawing the Koch fractal using Julia and Compose.
using Compose
function koch_side(n)
if n == 1
return compose(context(),
line([(0,1),(1/3,1),(1/2, 1 - (sin(pi/3)/3)),(2/3,1),(1,1)]))
else
ks = koch_side(n - 1)
return compose(context(),
(context(0,2/3,1/3,1/3), ks),
set nocompatible
set backupdir=~/.vim/backups
set undofile
set undodir=~/.vim/undo " remember undos across sessions
set noswapfile
" ----------------------------------------------------------------------------
" Text Formatting
" ----------------------------------------------------------------------------
#a = Expr(symbol("F_{n + 1}"))
#b = Expr(symbol("F_n"))
#c = Expr(symbol("F_{n - 1}"))
a = Expr(:a)
b = Expr(:b)
c = Expr(:c)
# fibonacci matrix
F = [ a b ;
@siddMahen
siddMahen / group_theory.v
Created February 24, 2015 19:13
Elementary Group Theory in Coq
Require Import Notations.
Generalizable All Variables.
Require Import Setoid.
Class Group {A : Type}(comp: A -> A -> A)(inv: A -> A)(iden: A) := {
assoc: forall a b c : A, comp a (comp b c) = comp (comp a b) c;
left_id: forall a : A, comp iden a = a;
right_id: forall a : A, comp a iden = a;
left_inv: forall a : A, comp (inv a) a = iden;
right_inv: forall a : A, comp a (inv a) = iden
var alg = require("algorithms"),
sort = alg.mergeSort;
/*
* Huffman coding.
*
* @api public
*/
var huffman = function(alphabet){
var algorithms = require("algorithms"),
fs = require("fs");
var dynamicLowMem = function(capacity, values, weights){
var max = function(x, y){
return x ^ ((x ^ y) & -(x < y));
}
var items = values.length,
value = 0,
import System.Environment
import System.IO
import Data.Char
main = do
args <- getArgs
let action = args !! 0
shift = read (args !! 1) :: Int
file = args !! 2
handle <- openFile file ReadMode