Skip to content

Instantly share code, notes, and snippets.

/**
* @(#)
*
* This program will generate your Phd thesis, might take a while(like several lifetimes of the universe).
* Simply change the thesisLength to number of characters you would like your Phd to contain.
*
* @Chester Grant
* @version 1.00 2010/8/10
*/
import java.io.*;
if(you.understand(this)){
you.suggestion("Get a Girlfriend");
}
@chestergrant
chestergrant / descramble_php
Created April 10, 2011 11:00
Word Descrambler - PHP
<?
$arr = keypadsArr("h,e,s,s,c");
echo "Created by: Chester Grant \n";
echo "Purpose: Unscrambles letters(see line 199)\n";
echo "Date: 9th/04/2011\n";
combination("",0,$arr);
function combination($output,$pos,$dataSet){
if($pos == count($dataSet)){
echo $output."\n";
@chestergrant
chestergrant / descramble_haskell
Created April 10, 2011 11:04
Word Descrambler - Haskell
-- "Created by: Chester Grant |Got code from:http://www.haskell.org/pipermail/haskell-cafe/2002-June/003122.html";
-- "Purpose: Unscrambles letters(see line 199)\n";
-- "Date: 9th/04/2011\n";
selections [] = []
selections (x:xs) = (x,xs) : [ (y,x:ys) | (y,ys) <- selections xs ]
permutations :: [a] -> [[a]]
permutations [] = [[]]
permutations xs = [ y : zs | (y,ys) <- selections xs, zs <- permutations ys]
@chestergrant
chestergrant / quicksort_cpp
Created April 10, 2011 11:06
QuickSort C++
//Got code from: http://www.haskell.org/haskellwiki/Why_Haskell_matters
template <typename T>
void qsort (T *result, T *list, int n)
{
if (n == 0) return;
T *smallerList, *largerList;
smallerList = new T[n];
largerList = new T[n];
T pivot = list[0];
int numSmaller=0, numLarger=0;
@chestergrant
chestergrant / Quicksort_Haskell
Created April 10, 2011 11:08
QuickSort - Haskell
--Got code from: http://www.haskell.org/haskellwiki/Why_Haskell_matters
qsort [] = []
qsort (x:xs) = qsort less ++ [x] ++ qsort more
where less = filter (<x) xs
more = filter (>=x) xs
@chestergrant
chestergrant / TenCount.java
Created July 1, 2012 07:13
Counts from one to ten. Part of "1000 programming exercise by Chess"
public class TenCount {
public static void main(String[] args) {
for(int i=1; i<=10; i++){
System.out.println(i);
}
}
}
@chestergrant
chestergrant / NameTimesHundred.java
Created July 1, 2012 07:25
Prints my name 100 times. Part of "1000 programming exercises by Chess"
public class NameTimesHundred {
public static void main(String[] args) {
for(int i=0; i<100; i++){
System.out.println("Chester");
}
}
}
@chestergrant
chestergrant / ReadTwoNumbers.java
Created July 1, 2012 07:55
Reads two integers and display them. This is part of "1000 programming exercise by Chess"
import java.util.*;
public class ReadTwoNumbers {
//When reading in digit you need to account for invalid inputs
public static int readNum(String promptMsg, boolean hasPrompt){
boolean isDig = true; //Checks if the value just read in is an integer
int output = -1; //Stores the return value of the read in number
do{
isDig = true;
Scanner input= new Scanner (System.in); //Use to read in the data
@chestergrant
chestergrant / InterweavingNames.java
Created July 1, 2012 08:04
Print my first name 100 times, and every count of 20 print my last name. Part of "1000 programming exercises by Chess"
public class InterweavingNames {
public static void main(String[] args) {
String firstname = "Chester";
String lastname = "Grant";
for(int i =1; i<=100; i++){
System.out.print(firstname);
if((i % 20) == 0){
System.out.print(" "+lastname);