Skip to content

Instantly share code, notes, and snippets.

View jcchurch's full-sized avatar

James Church jcchurch

View GitHub Profile
@jcchurch
jcchurch / aardvark.c
Created August 7, 2014 19:17
A unix shell that I wrote in C during my senior year at UT Martin. Wow, this is 10 years old.
/*
*
* The Aardvark Shell
* By James Church
*
* It is better to kiss an avocado than to get in a fight with an aardvark.
*
* Released under the OH-PLEASE-DONT-LET-MY-SOFTWARE-DIE-AT-THE-CRUEL-HANDS-OF-SLASHDOT Licence
* 2004-11-25
*
# Greet the user
print("This program will compute the sum and average of odd numbers.")
print("Enter values at the prompt. To stop, enter 0.")
# The average is computed by the total of odd numbers
# divided by the count of odd numbers. We need variables
# to store the total and the count.
# Set total and count to zero
total = 0
import turtle
"""
Solve the maze in Python 3!
In part 2a of the final, you will be completing a maze.
Your goal is to direct the red turtle (named "tot") to the
green square at the end of the maze. You are not allowed to
cross into the blue portion of the maze.
// ==UserScript==
// @name Set the editor mode
// @namespace
// @description Set the Plain Text Mode within Moddle
// @include http://courses.cs.westga.edu/*
// @version 0.1
// @grant none
// ==/UserScript==
//
// This script will change the default Plain Text editor format

Random Restart Hill Climbing

Random Restart Hill Climbing for N Queens (N=20) found a solution in 60 seconds.

[ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Q ~ ~ ~ ~ ~ ~ ~
  ~ ~ ~ ~ ~ ~ ~ Q ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
  ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Q ~ ~ ~ ~ ~ ~
  ~ ~ ~ ~ ~ ~ Q ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
  Q ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Q ~

@jcchurch
jcchurch / oneliners.txt
Created April 5, 2011 23:38
Oneliners
And that judge wasn't gonna look at the twenty-seven eight-by-ten color glossy pictures with the circles and arrows and a paragraph on the back of each one, explainin' what each one was to be used as evidence against us. And we was fined fifty dollars and had to pick up the garbage in the snow, but that's not what I came to tell you about.
All your base are belong to us.
Support your local medievalist.
The three kinds of people: Those who can count and those who can't.
Must be user error.
Close Cover Before Striking
The light at the end of the tunnel is usually a train.
42
First pants THEN your shoes.
BSA HandBook, 2nd Ed,: "Scouts as a rule do not go into the big woods."
@jcchurch
jcchurch / processMysterBits.py
Created April 11, 2011 14:02
This function fails to decipher a listing of binary digits using the ASCII tables.
import re
text = "101011011101010001101101011011101010100010101101010001101100101011011101010001110100111011010101101110110110101110110101000011010101101110110100111011010101101011010100110101001000100100011010100101011100110101001000101011010100110101001010100111010101101001001010101110100101010001010101101001001010100111010101101010101010110001010001110100101011010101010010010100011101000110101010110001010000101001001101010011101011011101010100101011010100111010110100101001001101010011010101000101001010110111010100011111010110110010101101110111010101000101001010111101101010001101001110110101011101101101101011010011101101011101101010001101000101001010111010110101001101010001101001000110101101010011010101001010111010110101001010100010101001110101011010100010101010101010011101011101001010100010101010101110100101101010101100010100010101001010011010101011010110101110100101101010101011"
def bin2ascii(binary_form):
"""Converts binary strings of length 8 to ASCII"""
if len(binary_form) != 8:
retur
@jcchurch
jcchurch / monty.java
Created April 20, 2011 03:19
Monty Hall Problem solved with Monte Carlo Simulations
/*
* The Monty Hall Problem is a famous teaching problem
* in statistics. It works like this:
*
* Imagine that you are on the show "Let's Make a Deal"
* with Monty Hall. Monty shows you three doors and says
* that a car exists behind one of them. You may pick
* one door and if the car is behind it, you win the car.
*
* You pick a door. Monty then chances the rules. He opens
@jcchurch
jcchurch / quickPlot.m
Created April 20, 2011 03:16
Quickly plot graphs in Matlab
function quickPlot(varargin)
% This function is useful for printing point
% cloud data quickly. This function accepts
% one or more vectors, in either 2D or 3D,
% and either row-order or column-order format.
n = size(varargin, 2);
colors = char('r.', 'g.', 'b.', 'c.', 'm.');
num_colors = size(colors, 1);
@jcchurch
jcchurch / gplot3.m
Created April 20, 2011 03:32
3D Version of Matlab's GPLOT
function gplot3(A, xyz)
% GPLOT3(A, xyz) is nearly the same as GPLOT(A, xy) except
% that the xyz variable requires a third dimension.
% This function takes an adjacency matrix and visualizes it
% in 3D.
[d e] = size(A);
if d ~= e
error('A matrix must be square.');
end