Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define BUFSZ 256
@yanhan
yanhan / vacuum.rkt
Created January 25, 2012 08:26
Vacuum Cleaner
#lang racket
; CS3243 Vacuum Cleaner world simulation using Racket Scheme
; Initially written by Yong Chun How
; Modified by Pang Yan Han
; Helper functions
(define (accumulate op initial sequence)
(if (null? sequence)
initial
@yanhan
yanhan / stfreq.py
Created January 24, 2012 01:36
Small program for extracting range frequencies
#!/usr/bin/python
import sys
def run():
'''Reads in series of integers and ranges, then outputs frequencies
Input format:
1st line - 2 integers R and C, indicating the rows and columns of data
that follows
@yanhan
yanhan / scale.lisp
Created November 17, 2011 07:00
40 stones - Common Lisp (by a beginning Lisper)
(defparameter *max-weight* 40)
(defparameter *max-stones* 4)
(defparameter *stone-indices* (loop for i from 0 to (1- *max-stones*) collect i))
(defun generate-combos ()
(let ((all-combos ())
(a-limit (- *max-weight* (1- *max-stones*))))
(do ((a 1 (1+ a)))
((> a a-limit) all-combos)
(do ((b 1 (1+ b)))
@yanhan
yanhan / ascii_birthday.c
Created July 4, 2011 15:21
Happy Birthday Ray Chuan
#include <stdio.h>
#define TOP_START 24
#define TOP_END 55
#define MID_START 15
#define MID_END 63
#define BOT_START 13
#define BOT_END 66
#define MAIN(foobar) int main(void) { foobar }