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.io.*; | |
import java.util.*; | |
public class MagicReader { | |
public static void main(String[] args) { | |
String filename = magicsquare.txt; | |
Scanner s = new Scanner(new File(filename)); | |
int lines = 1; | |
while(s.hasNextLine()) { | |
s.nextLine(); |
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.*; | |
public class Timing { | |
public static void main(String[] args) { | |
System.out.println("============================================"); | |
System.out.println(" Lists vs. Sets "); | |
System.out.println("============================================"); | |
int n = 1000; |
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 CaesarSolution { | |
public static String caesarShift(String message, int key, boolean doEncryption) { | |
message = message.toUpperCase(); | |
message = message.replace(" ",""); | |
// This is the variable storing the encrypted/decrypted message | |
String message2 = ""; |
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.*; | |
public class ArraysInPlace { | |
public static void main(String[] args) { | |
int x = 5; | |
System.out.println(x); | |
proofThatWeCopy(x); | |
System.out.println(x); |
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) { |
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.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; | |
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
#!/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
# Look ma, no modules! | |
# bottlenecks around 12, when the problem size starts to mushroom | |
board_size = 11 | |
solutions = [] | |
queens = [] | |
occupied = board_size*[0,] | |