Skip to content

Instantly share code, notes, and snippets.

View mohanrajendran's full-sized avatar

Mohan Rajendran mohanrajendran

View GitHub Profile
@mohanrajendran
mohanrajendran / Exercise1-11.scm
Created July 13, 2014 22:37
SICP Exercise 1.11
;;; Original function
(define (f n)
(cond ((< n 3) n)
(else (+ (f (- n 1)) (* 2 (f (- n 2))) (* 3 (f (- n 3)))))))
; f
(f 0)
; 0
(f 1)
; 1
@mohanrajendran
mohanrajendran / Exercise1-12.scm
Created July 14, 2014 02:46
SICP Exercise 1.12
;; Rows and columns start with index 1
(define (pascal row col)
(cond ((or (= col 1) (= col row)) 1)
(else (+ (pascal (- row 1) col) (pascal (- row 1) (- col 1))))))
;; Test cases
(pascal 1 1)
; 1
(pascal 13 7)
; 924
@mohanrajendran
mohanrajendran / 113plot.py
Last active August 29, 2015 14:04
SICP Exercise 1.14 Plotting
import pygraphviz as pgv
import networkx as nx
nodeCount = 1
G = nx.DiGraph()
Ranks = {}
def countChange(amount):
global G
global Ranks
@mohanrajendran
mohanrajendran / Chapter3_3_1.rkt
Created November 15, 2015 20:13
SICP Working Code
#lang planet neil/sicp
(define (append x y)
(if (null? x)
y
(cons (car x) (append (cdr x) y))))
(define (last-pair x)
(if (null? (cdr x))
x
@mohanrajendran
mohanrajendran / gcloud-fastai.sh
Last active March 7, 2018 20:36
Script to set up a deep learning box for fast.ai MOOC on Google cloud
# This script is designed to work with ubuntu 16.04 LTS
# ensure system is updated and has basic build tools
sudo apt-get update
sudo apt-get --assume-yes upgrade
sudo apt-get --assume-yes install tmux build-essential gcc g++ make binutils git
sudo apt-get --assume-yes install software-properties-common
# download and install GPU drivers
wget "http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_8.0.44-1_amd64.deb" -O "cuda-repo-ubuntu1604_8.0.44-1_amd64.deb"