Skip to content

Instantly share code, notes, and snippets.

@stulacy
stulacy / CODWarzoneSolver.R
Created July 18, 2023 16:14
Solves the puzzle in COD Warzone
library(stringr)
solve <- function(code) {
# Extract the num
nums <- as.numeric(strsplit(gsub("[A-Z]", "", code), '')[[1]])
letters <- unique(strsplit(gsub("[0-9]", "", code), "")[[1]])
miss_nums <- setdiff(seq(1, 9), nums)
# Generate all permutations of possible solution numbers
# No permutation function in R so make my own
@stulacy
stulacy / MAUCpy.py
Last active November 29, 2020 11:23
"""
MAUCpy
~~~~~~
Contains two equations from Hand and Till's 2001 paper on a multi-class
approach to the AUC. The a_value() function is the probabilistic approximation
of the AUC found in equation 3, while MAUC() is the pairwise averaging of this
value for each of the classes. This is equation 7 in their paper.
"""
library(reshape2)
formattedtable <- function(x, block, group, value) {
# Form a dataframe with the mean values and get a logical matrix of the max values
mean <- setNames(aggregate(x[, value], list(x[, block], x[, group]), mean), c(block, group, "mean"))
# To get the max values need in wide format
mean.wide <- dcast(mean, get(block) ~ get(group), value.var="mean") # get() comes from reshape2, gets string values from variables
colnames(mean.wide)[1] <- block