This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Polynomial { | |
public Polynomial add(Polynomial p) { | |
int degp = p.coeffs.length; | |
int degthis = this.coeffs.length; | |
int mindegree = Math.min(degp, degthis); | |
int maxdegree = Math.max(degp, degthis); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EscapeHelloWorld { | |
public static void main(String[] args) { | |
System.out.println("A well-formed Java program has"); | |
System.out.println("a main method with { and }"); | |
System.out.println("braces.\n"); | |
System.out.println("A system.out.println statement"); | |
System.out.println("has ( and ) and usually a"); | |
System.out.println("String that starts and ends"); | |
System.out.println("with a \" character."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sort by total time, in descending order | |
cat profiler_output_nqueens.csv | sort -n -r | |
# Sort by time per call (third column in file), in descending order | |
# -d "," means use "," as a field (column) delimiter | |
# -f 3,4 means grab fields (columns) 3 and 4 | |
cat profiler_output_nqueens.csv | cut -d "," -f 3,4 | sort -n -r |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "----------" | |
echo "running command 1..." | |
time for i in {0..1000}; do true; done | |
echo "----------" | |
echo "running command 2..." | |
time for i in {0..1000}; do echo "hello world" >> file; done | |
echo "----------" | |
echo "running command 3..." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Look ma, no modules! | |
# bottlenecks around 12, when the problem size starts to mushroom | |
board_size = 11 | |
solutions = [] | |
queens = [] | |
occupied = board_size*[0,] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/perl | |
use Time::HiRes qw(time); | |
use strict; | |
use warnings; | |
my $start = time; | |
###################################### | |
########## N Queens Puzzle ########### | |
# | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LinkedList; | |
import java.util.Arrays; | |
public class NQueens { | |
public static final int SIZE = 11; | |
/////////////////////////////////////////////////// | |
// main | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
import java.util.Set; | |
import java.util.Map; | |
import java.util.TreeMap; | |
import java.util.List; | |
import java.util.LinkedList; | |
import java.util.Arrays; | |
import com.google.common.graph.Network; | |
import com.google.common.graph.NetworkBuilder; | |
import com.google.common.graph.ImmutableNetwork; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LinkedList; | |
public class ListTiming { | |
public static void main(String[] args) { | |
long startTime, endTime, diff; | |
// Time our list object | |
startTime = System.nanoTime(); | |
testMyList(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
// This class implements the Fisher-Yates Shuffle Algorithm. | |
// | |
// Author: Charles Reid | |
// Class: CSC 142 | |
// Date: March 2017 | |
public class FisherYates { | |
public static void main(String[] args) { |