Skip to content

Instantly share code, notes, and snippets.

public boolean nestParen(String str) {
if (str == "")
return true;
else if (str.indexOf("(") != -1)
return nestParen(str.substring(str.indexOf("(")+1, str.lastIndexOf(")")));
else
return false;
}
public String stringClean(String str) {
if (str.length() < 2)
return str;
else if (str.charAt(0) == str.charAt(1))
return stringClean(str.substring(1));
else
return str.charAt(0) + stringClean(str.substring(1));
}
@gcr
gcr / Bird.java
Created February 11, 2012 01:39
Java abstract classes
public abstract class Bird
{
public abstract void Call();
}
# VI editing mode EVERYWHERE.
set editing-mode vi
# Tab completion will automatically correct case.
set completion-ignore-case on
# So useful! After typing a ), the cursor bounces to the opening ( for a
# fraction of a second.
set blink-matching-paren on
@gcr
gcr / boy.py
Created January 30, 2012 01:47
#!/usr/bin/env python2
import random
BOY=1
PARTICULAR_BOY=2
GIRL=3
def is_boy(n):
return n == BOY or n == PARTICULAR_BOY
Word name 1 Word name 1 <strong>Word name 1</strong><ul><li>Definiton one</li><li>Definition two</li><li>Definition three</li></ul><emph>(Example)</emph>
Word name 2 Word name 2 <strong>Word name 2</strong><ul><li>Definiton one</li><li>Definition two</li><li>Definition three</li></ul><emph>(Example)</emph>
@gcr
gcr / pi.c
Created January 1, 2012 01:31
/*
* Program to compute an approximation of pi
* by Brian Westley, 1988
* (requires pcc macro concatenation; try gcc -traditional-cpp)
*/
#define _ -F<00||--F-OO--;
int F=00,OO=00;
main(){F_OO();printf("%1.3f\n",4.*-F/OO/OO);}F_OO()
{
"""
Patrols the edges of the map going clockwise. Just drives around in circles,
taking pains not to hit a wall.
When we see a wall, turn right a little.
"""
from courier import RoboLink
class TICalcRandom {
public static void main(String[] args) {
Calculator calc = new Calculator();
calc.seed(1);
System.out.println( calc.rand() );
System.out.println( calc.rand() );
System.out.println( calc.rand() );
System.out.println( calc.rand() );
System.out.println( calc.rand() );
}