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 math.max | |
/* | |
James is a businessman. He is on a tight schedule this week. The week starts | |
on Monday at 00:00 and ends on Sunday at 24:00. His schedule consists of M | |
meetings he needs to take part in. Each of them will take place in a period of | |
time, beginning and ending on the same day (there are no two ongoing meetings | |
at the same time). James is very tired, thus he needs to find the longest | |
possible time slot to sleep. In other words, he wants to find the longest | |
period of time when there are no ongoing meetings. The sleeping break can |
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 java.text.SimpleDateFormat | |
import java.time.Instant | |
import java.util.Date | |
import java.util.concurrent.TimeUnit | |
import TimeUnit.{MILLISECONDS => Milliseconds} | |
import TimeUnit.{SECONDS => Seconds} | |
import scala.annotation.tailrec | |
/* |
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 scala.annotation.tailrec | |
/* | |
Assassin | |
-------- | |
Write a method that given a board, `b`, with obstacles, guards, and an assassin, will determine if said assassin can | |
reach the bottom right undetected: | |
object Assassin { | |
def undetected(b: Array[String]): Boolean |
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 ArrayRotation { | |
def rotate(a: Array[Int], k: Int): Array[Int] = { | |
val n = a.length | |
lazy val kRn = k % n | |
if (n == 0 || kRn == 0) | |
a | |
else | |
Array.tabulate(n) { i => | |
val j = i - kRn |
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
/* Divisible by 3 | |
-------------- | |
Given a string representation of a number, returns the number of variations of said input that is divisible by 3. The variations consist of changing one digit for each variation. | |
For example, "21"'s variations are: | |
01 | |
11 | |
21 | |
31 |
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
package jj.musicshareroomapp.msr | |
import scala.concurrent | |
import concurrent.{ Future, Promise, ExecutionContext } | |
import ExecutionContext.Implicits.global | |
import Future.firstCompletedOf | |
import concurrent.duration._ | |
import scala.util.{ Success, Failure } | |
import scala.collection | |
import collection.parallel |
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
log_factorial <- function (n) { | |
# Return the log of factorial(n) for any integer n > 0 | |
if (n <= 1) | |
return (0) | |
return (log(n) + log_factorial(n - 1)) | |
} | |
sum_log_factorial <- function (n) { | |
# Return the sum of log_factorial(i) for i in 1..n | |
sum <- 0 |
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
--- | |
title: 'Project 2: Modeling and Evaluation' | |
subtitle: '<p>CSE6242 - Data and Visual Analytics</p><p>Due: Friday, April 21, 2017 | |
at 11:59 PM UTC-12:00 on T-Square</p>' | |
output: | |
pdf_document: default | |
html_document: default | |
--- | |
# Data |
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
# AC4: Visualize Vehicular Accident Non-motorist Mortalities per State | |
# inspirational reference: https://blog.dominodatalab.com/geographic-visualization-with-rs-ggmaps/ | |
# infrastructure | |
install.packages("ggmap", type = "source") | |
library(ggmap) | |
setwd("~/Google Drive/gatech/dva/ac4") # **** Needs to accomodate particular workstation **** | |
vas <- read.csv("vehicle-accidents.csv") | |
# only continental states |
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
# Activity: Time Series Analysis | |
library(zoo) # basic time series package | |
library(xts) # eXtensible Time Series package | |
data_dir <- "data" | |
label_dir <- "labeled_windows" | |
load_ts <- function(csv_filename) { | |
# Load and return time series data from a CSV file. |
NewerOlder