Skip to content

Instantly share code, notes, and snippets.

View client.c
#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 Jan 25, 2012
Vacuum Cleaner
View vacuum.rkt
#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 Jan 24, 2012
Small program for extracting range frequencies
View stfreq.py
#!/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 Nov 17, 2011
40 stones - Common Lisp (by a beginning Lisper)
View scale.lisp
(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 Jul 4, 2011
Happy Birthday Ray Chuan
View ascii_birthday.c
#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 }