Skip to content

Instantly share code, notes, and snippets.

@emilyboynton
emilyboynton / tree_and_dfs.py
Last active May 3, 2016 20:39
DFS function with class Tree in Python
# Recurse Center Application 2016, Emily Boynton
# Code below includes a class Tree which can create a navigable tree
# and a function dfs() or "Depth-first Search" which allows a user to
# search the entire tree for a specific tree (by its name)
# class Tree gives each "node" a name, array of children, and parent.
# Tree navigation includes: parent(), find_child(), to_root(), add()
# Tree functions include: print_children(), print_whole_tree(), print_tree()
class Tree:
@emilyboynton
emilyboynton / cracklePop.js
Created April 18, 2016 20:41
CracklePop Program
/* cracklePop prints out numbers 1 - 100 while substituting "Crackle" and "Pop"
for numbers divisible by 3 and 5, respectively */
var cracklePop = function () {
/*print out the numbers 1 to 100 (inclusive). */
for (var i = 1; i <= 100; i++){
/* If the number is divisible by 3 and 5, print CracklePop */
if ( (i % 3 === 0) && (i % 5 === 0) ) {
console.log("CracklePop");
}
/* If the number is divisible by 3, print Crackle */
@emilyboynton
emilyboynton / tic tac toe after
Created May 3, 2013 17:56
tic tac toe after
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
char board [9];
void display_board (void);
bool validate (int z);
@emilyboynton
emilyboynton / gist:5268296
Last active December 15, 2015 13:38
This simple Tic Tac Toe game will invite two players to enter their names and to play a quick round. Player 1 is 'x' and player 2 is 'o.' The players will be given a 3x3 board that will have a number, 0 through 8, assigned to each space. On their turn, the players will enter the number of the space that they wish to play. When a player has marke…
#include <iostream>
#include <string>
using namespace std;
char board [9];
void display_board (void);
bool validate (int z);
int winner (); //returns a 0 for draw, 1 for player 1, and 2 for player 2