Skip to content

Instantly share code, notes, and snippets.

@snarkbait
snarkbait / TaxCalculator.java
Last active August 29, 2015 14:15
2014 US Federal Tax Calculator
public class TaxCalculator implements TaxLookup
{
public static double getTax(int income, int status)
{
double tax = 0;
for (int i = 0; i < 7; i++)
{
if (income > lookup[status][i][1])
package philyboyd_studge;
public class MinecraftChallenge {
public static void main(String[] args) {
World world = new World();
world.updateWorld();
import java.util.Random;
public class Game21
{
private int[] heap;
private Random rand = new Random();
private boolean computerOpponent;
private boolean lastPlayWins;
@snarkbait
snarkbait / MergeSort.java
Last active August 29, 2015 14:23
Top-Down Merge Sort
/*
* Generic Top-Down Merge Sort
* Based on this
* https://en.wikipedia.org/wiki/Merge_sort#Top-down_implementation_using_lists
*
* for http://www.reddit.com/r/javaexamples
* by user /u/Philboyd_Studge
*
* PUBLIC LICENSE - This software is released with an unlimited license.
* There is no specification of any kind on its usage or implementation.
@snarkbait
snarkbait / FileIO.java
Created December 6, 2015 21:31
FileIO.java Simplified static file functions, made specifically for the AdventOfCode challenges.
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.regex.PatternSyntaxException;
@snarkbait
snarkbait / Advent14.java
Last active December 14, 2015 07:21
Advent Day 14 AdventOfCode
import java.util.ArrayList;
import java.util.List;
/**
* @author /u/Philboyd_Studge on 12/13/2015.
*/
public class Advent14 {
List<Reindeer> deer = new ArrayList<>();
@snarkbait
snarkbait / Advent7.java
Created December 8, 2015 03:18
Advent of Code Day 7
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.IntBinaryOperator;
/**
* @author /u/Philboyd_Studge on 12/6/2015.
*/
public class Advent7 {
@snarkbait
snarkbait / Coordinate.java
Last active December 28, 2015 05:08
Maze DFS/BFS example file for Coursera : UCSD Advanced Data Structures - Week 2
package util;
public class Coordinate {
private int row;
private int col;
public Coordinate(int row, int col) {
this.row = row;
this.col = col;
}
package enumexample;
import javax.swing.*;
import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
/**
* @author /u/Philboyd_Studge on 1/10/2016.
*/
@snarkbait
snarkbait / Inventory.java
Last active November 9, 2016 21:29
Sorted Doiubly-Linked List example for /r/javaexamples
public class Inventory implements Comparable<Inventory>
{
private String item;
private int qty;
private float price;
public Inventory(String item, int qty, float price)
{
this.item = item;
this.qty = qty;