Skip to content

Instantly share code, notes, and snippets.

View markjgap's full-sized avatar

Mark G markjgap

View GitHub Profile
@markjgap
markjgap / Connect Four with Artificial Intelligence
Last active September 17, 2015 05:14
Uses a decision making minimax algorithm and heuristic to look at future scenarios, the program's artifical intelligence determines board favorability by assigning values to potential board states to decide its next move.
import java.util.ArrayList;
import java.util.Random;
/**
* Contains a heuristic to check board favorability.
*/
public class MyPlayer extends Player {
Random rand;
@markjgap
markjgap / AVL Tree
Last active August 29, 2015 14:16
Implements AVL Tree data structure that stores integer values. If AVL Tree becomes unbalanced, Tree will rebalance itself using single or double rotations depending on where the violation occurs.
/*
* Implements AVL Tree data structure that stores integer values. If AVL Tree becomes unbalanced,
* Tree will rebalance itself using single or double rotations depending on where the violation occurs.
*
*/
public class AVLTreeNode {
private AVLTreeNode left;
private AVLTreeNode right;
@markjgap
markjgap / Puzzle Solving Program
Last active August 29, 2015 14:14
Java program solves a Sudoku puzzle. It is able to target empty squares, search for all possible answers and apply an algorithm to determine the correct solution to complete the puzzle.
/*
* Java program used to solve a Sudoku puzzle. It is able to target empty squares, search for all possible answers
* and apply an algorithm to determine the correct solution to complete the puzzle.
*/
import java.util.*;
import java.io.*;
public class Sudoku {
@markjgap
markjgap / Linux Shell Simulator
Last active September 17, 2015 05:13
Simulates a Linux shell that can execute built-in commands like changing directories or deleting files as well as customized commands like listing command history as a foreground or background process.
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "parse_args.h"
#include "history_queue.h"
/*
@markjgap
markjgap / Cache Simulator
Last active January 16, 2025 10:19
Written in C, program simulates cache logic with a write-back and LRU policy. Handles direct-mapped, set-associative and full-associative caches.
#include <stdlib.h>
#include <stdio.h>
#include <getopt.h>
#include <unistd.h>
#include <math.h> // used to help calculate set and block
#include "cachelab.h"
/*
* Simulates a cache logic with a write-back and LRU (least recently used) policy.
* Handles direct-mapped, set-associative and full-associative caches.
@markjgap
markjgap / Game of Life
Last active August 29, 2015 14:10
Written in C, program is an example of discrete event simulation, where a world of entities live, die, or are born based on their surrounding neighbors. Each time step simulates another round of living or dying.
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <string.h>
/*
* An example of discrete event simulation, where a world of entities live, die, or are born based on their surrounding neighbors.
* Each time step simulates another round of living or dying. This cellular automation can take any initial configuration and
* be observed as it evolves through its life creating unique patterns.
@markjgap
markjgap / Web Scraping and Modifying Data
Last active August 29, 2015 14:06
Written in Python, program scraps data from multiple webs pages, searches a pattern of strings using regular expression and makes necessary modifications so data can be alphabetize.
import os, re # re imports regular expressions
# creates a file called job_list and dumps data.
os.system('lynx -nolist -dump http://www.careercast.com/jobs-rated/jobs-rated-2014-ranking-200-jobs-best-worst > job_list.txt')
os.system('lynx -nolist -dump http://www.careercast.com/content/top-200-jobs-2014-21-40 >> job_list.txt')
os.system('lynx -nolist -dump http://www.careercast.com/content/top-200-jobs-2014-41-60 >> job_list.txt')
os.system('lynx -nolist -dump http://www.careercast.com/content/top-200-jobs-2014-61-80 >> job_list.txt')
os.system('lynx -nolist -dump http://www.careercast.com/content/top-200-jobs-2014-81-100 >> job_list.txt')
os.system('lynx -nolist -dump http://www.careercast.com/content/top-200-jobs-2014-101-120 >> job_list.txt')
os.system('lynx -nolist -dump http://www.careercast.com/content/top-200-jobs-2014-121-140 >> job_list.txt')
@markjgap
markjgap / MyTranslator_V1
Last active August 29, 2015 14:02
Spanish to English study program written in Scala
object MyTranslator {
def main(args: Array[String]): Unit = {
// Spanish to English database
// Translator's stock study list
val db = Map(
// first set
("hola" -> "hello"),
("adios" -> "bye"),