Skip to content

Instantly share code, notes, and snippets.

View b-adams's full-sized avatar

Prof. Bryant E Adams b-adams

  • Wells College
  • Aurora NY
View GitHub Profile
@b-adams
b-adams / musiclookup.pl
Created October 17, 2011 01:50
Music Lookup
playsThe(anmarcus, accordion).
playsThe(anmarcus, percussion).
playsThe(mferguson, didgeriedoo).
playsThe(mferguson, trombone).
playsThe(avannorstrand, guitar).
playsThe(avannorstrand, fiddle).
playsThe(nvannorstrand, percussion).
playsThe(nvannorstrand, fiddle).
playsThe(mferguson, saw).
playsThe(aamarcus, concertina).
@b-adams
b-adams / jeldridge_my_lil_if.c
Created October 18, 2011 19:37
Nesting versions
// This is the main function.
// program MAIN;
#include <stdio.h>
int main(void)
{
if(gamepoint<10)
{
printf("Strike!");
@b-adams
b-adams / inceptionish.c
Created October 19, 2011 13:23
Recursion example
/** @file inceptionish.c
@author Prof. Adams
@assistance Plot overview from Wikipedia [http://en.wikipedia.org/wiki/Inception]
@assistance Plot overview from Jamie LaFountain
@status funky
*/
#include <stdio.h>
#include <stdbool.h>
/** Letter user enters for 'Dream' command in main menu */
@b-adams
b-adams / p5output.txt
Created October 24, 2011 17:39
Program 5 example output
Welcome to badams' program 5
Please enter a number between 0 and 50: 0
Please enter a number between 50 and 100: 100
I'm thinking of a number. Can you guess it? Please enter a number between 0 and 100: 50
Too high. Try again. I'm thinking of a number. Can you guess it? Please enter a number between 0 and 49: 25
Too high. Try again. I'm thinking of a number. Can you guess it? Please enter a number between 0 and 24: 12
Too high. Try again. I'm thinking of a number. Can you guess it? Please enter a number between 0 and 11: 5
Too low. Try again. I'm thinking of a number. Can you guess it? Please enter a number between 6 and 11: 8
Too low. Try again. I'm thinking of a number. Can you guess it? Please enter a number between 9 and 11: 10
@b-adams
b-adams / p5Fdoc.txt
Created October 24, 2011 17:42
Program 5 Specs
/**
@brief Run the guessing game, using a FOR loop.
@param rounds How many guesses the user gets
@param low The smallest number that might be the target
@param high The biggest number that might be the target
@param target The number the user should guess
@returns how many times the user guessed correctly.
The user is prompted to enter a number between low and high. If correct, select a new target randomly between low and high, not the victory, and congratulate the user. Otherwise, change high or low (as appropriate) to the user's guess.
@b-adams
b-adams / main_and_part0.txt
Created October 30, 2011 20:36
Sample output for Program 6
Welcome to badams's Program 6
(Part 0) Welcome to the Main Menu. Please select one of the following:
0: Display this lovely menu.
1: Total some numbers
2: Display ASCII codes for letters
3: Compute some Ulam numbers, whatever those are.
-1: Quit
Whatchawannado? -2
@b-adams
b-adams / prog7output.txt
Created November 13, 2011 20:45
Sample output from Program 7
$ ./program_7_solution
MAIN MENU:
-----------------------------------
(a) Input data automatically
(b) Input data manually (BAD IDEA!)
-----------------------------------
(c) Display all array contents
(d) Display all contents, backward
(e) Display contents in a range
(f) Display evenly spaced contents
@b-adams
b-adams / cs228records.erl
Created November 17, 2011 21:28
Mergesort and three sort orders in Erlang, and pattern matching example
-module(cs228records).
-export([listJobbers/2]).
listJobbers(NameOfJob, [CurrentRecord | RemainingRecords]) ->
case CurrentRecord of
{person, {name, UsefulName}, {job, NameOfJob}, _} ->
[ UsefulName | listJobbers(NameOfJob, RemainingRecords)]
;
{person, {name, UselessName}, {job, RandomJob}, {Label, Data}} ->
io:format("Ignoring the <~p-~p'ed> ~p, who is a ~p.~n", [Data, Label, UselessName, RandomJob]),
4/5 * 4/9 = 16/45
1/3 + 5/9 = 8/9
2/5 * 1/6 = 1/15
1/1 + 2/1 = 3/1
4/5 * 1/3 = 4/15
2/5 + 5/4 = 33/20
1/4 * 10/9 = 5/18
7/6 + 8/7 = 97/42
3/8 * 1/4 = 3/32
1/1 + 5/1 = 6/1
@b-adams
b-adams / no_arguments.txt
Created December 7, 2011 02:53
Final Program Sample Output
eclipse:cs131 badams$ clang cs131_program_final_badams.c -o bubblesort
eclipse:cs131 badams$ ./bubblesort
Bad syntax. Instead try:
./bubblesort 3 1 4 1 5 9 2 6 5 3 5 7
Or...
./bubblesort verbose 3 1 4 1 5 9 2 6 5 3 5 7
eclipse:cs131 badams$