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 random | |
numOfPeople = 8 | |
amountScale = 100 | |
init_amounts = [random.randrange(amountScale) for i in range(numOfPeople)] | |
# Real world example | |
init_amounts = [56.16, 0, 26.7, 14, 80.1, 225.98, 238.86/2, 238.86/2] | |
# print init_amounts | |
sorted_amounts = sorted(init_amounts, reverse=True) |
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
# getmonitor.R | |
getmonitor <- function(id, directory, summarize = FALSE) { | |
## 'id' is a vector of length 1 indicating the monitor ID | |
## number. The user can specify 'id' as either an integer, a | |
## character, or a numeric. | |
## 'directory' is a character vector of length 1 indicating | |
## the location of the CSV files | |
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
complete <- function(directory, id = 1:332) { | |
## 'directory' is a character vector of length 1 indicating | |
## the location of the CSV files | |
## 'id' is an integer vector indicating the monitor ID numbers | |
## to be used | |
## Return a data frame of the form: | |
## id nobs | |
## 1 117 |
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
corr <- function(directory, threshold = 0) { | |
## 'directory' is a character vector of length 1 indicating | |
## the location of the CSV files | |
## 'threshold' is a numeric vector of length 1 indicating the | |
## number of completely observed observations (on all | |
## variables) required to compute the correlation between | |
## nitrate and sulfate; the default is 0 | |
## Return a numeric vector of correlations |
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
best <- function(state, outcome) { | |
data <- read.csv(file='outcome-of-care-measures.csv', colClasses = 'character') | |
if(!any(state == data$State)) { | |
stop('invalid state') | |
} | |
if(outcome == 'heart attack') { | |
i <- 11 |
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
rankhospital <- function(state, outcome, num = "best") { | |
# read outcome | |
data <- read.csv(file="outcome-of-care-measures.csv", colClasses = 'character') | |
if(!any(state == data$State)) { | |
stop('invalid state') | |
} | |
if(outcome == 'heart attack') { | |
i <- 11 |
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
rankall <- function(outcome, num = "best") { | |
data <- read.csv(file="outcome-of-care-measures.csv", colClasses = 'character') | |
if(outcome == 'heart attack') { | |
i <- 11 | |
} | |
else if(outcome == 'heart failure') { | |
i <- 17 | |
} | |
else if(outcome == 'pneumonia') { |
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
fun number_before_reaching_sum (sum : int, xs : int list) = | |
if null xs then 0 | |
(*else if null (tl xs) then 1*) | |
else if hd xs > sum then 0 | |
else | |
let fun helper (i : int, partial_sum : int, tl_xs : int list) = | |
if partial_sum < 0 then i | |
else | |
helper(i + 1, partial_sum - hd tl_xs, tl tl_xs) | |
in |
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
.DS_STORE |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
div.tooltip { | |
position: absolute; | |
text-align: right; | |
z-index:9999; | |
width: 6px; | |
height: 18px; |
OlderNewer