This file contains 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
// original (ew) | |
class Person(val name: String, val department: String) | |
var people = Array(new Person(“Jones”, “Marketing”), new Person(“Smith”, “Engineering”)) | |
var engineer: Person = null | |
var index = 0 | |
while (index < people.length) { | |
if (people(index).department == “Engineering”) engineer = people(index) index = index + 1 | |
} | |
println(engineer.name + “ is an engineer”) |
This file contains 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
object Dijkstra extends App { | |
val graph = buildExampleGraph() | |
shortestPath(Node[String]("car"), Node[String]("tat"), graph) | |
shortestPath(Node[String]("cat"), Node[String]("tar"), graph) | |
case class Node[T](value: T) | |
class Graph[T] { | |
private val edges = new mutable.HashMap[Node[T], Seq[Node[T]]]() | |
private var nodes = Seq[Node[T]]() |
This file contains 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
val input = Array(1,2,3,4,3,4,1,2,3,4,6,2) | |
println(evaluate(input)) | |
def evaluate(arr: Array[Int]): Int = { | |
val p = peaks(arr) | |
var i = arr.length | |
while (i > 0) { | |
if (arr.length % i == 0 | |
&& canSplit(arr.length, p , arr.length/i)) { |
This file contains 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
object Rotation extends App { | |
val matrix = Array(Array(1,2), Array(3,4), Array(5,6)) | |
print(matrix) | |
print(transpose(matrix)) | |
print(rotate90(matrix)) | |
print(rotateMinus90(matrix)) | |
def transpose(matrix: Array[Array[Int]]): Array[Array[Int]] = { |
This file contains 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
[polyglotpiglet/home-office-setup] | |
checkout = git clone 'git@github-personal:polyglotpiglet/home-office-setup.git' 'home-office-setup' | |
[.config/vcsh/repo.d/vim.git] | |
checkout = vcsh clone 'git@github-personal:polyglotpiglet/vim.git' 'vim' | |
[.config/vcsh/repo.d/bashrc.git] | |
checkout = vcsh clone 'git@github-personal:polyglotpiglet/bashrc.git' 'bashrc' | |
[.config/vcsh/repo.d/git.git] |
This file contains 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 static void main(String... args) { | |
int count = 0; | |
for (int i =0; i <1000; i++) { | |
long startTime = System.nanoTime(); | |
for (int j = 0; j < 1000; j ++) { | |
count += j; | |
} |
This file contains 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 matplotlib.pyplot as plt | |
ys = [] | |
with open('output.txt') as fp: | |
content = fp.readlines() | |
for line in content: | |
ys.append(int(line.strip())) |
This file contains 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 static void main(String... args) { | |
String curveBall = null; | |
int count = 0; | |
for (int i =0; i <1000; i++) { | |
long startTime = System.nanoTime(); | |
for (int j = 0; j < 1000; j ++) { | |
count += j; |
This file contains 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 static void main(String... args) throws IOException { | |
Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("/Users/alexbate/out.txt")))); | |
int count = 0; | |
for (int i =0; i <2000; i++) { | |
long startTime = System.nanoTime(); | |
for (int j = 0; j < 1000; j ++) { | |
count += j; | |
} |
This file contains 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 static void main(String... args) { | |
int[] data = new int[100_000]; | |
Random random = new Random(); | |
for (int i = 0; i< 100_000; i++) { | |
data[i] = random.nextInt(); | |
} | |
int max = Integer.MIN_VALUE; | |
for (int x : data) { | |
max = Math.max(max, x); |
OlderNewer