Skip to content

Instantly share code, notes, and snippets.

View dillonius01's full-sized avatar

Dillon Powers dillonius01

View GitHub Profile
module Solution
type MultiDimList =
| Value of int
| InnerList of MultiDimList list
let addParens (str: string) =
"[" + str + "]"
let rec multiDimListToString (multiDimList: MultiDimList) =
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;
class Solution {
public static void main(String[] args) {
MultiDimArrayNode n1 = new MultiDimArrayNode(2);
MultiDimArrayNode n2 = new MultiDimArrayNode(3);
MultiDimArrayNode n3 = new MultiDimArrayNode(4);
MultiDimArrayNode n4 = new MultiDimArrayNode(n1, n2, n3);
defmodule CodePad do
def pair_sum(target_sum, list) do
list
|> get_permutations()
|> Enum.filter(fn [num1, num2] ->
num1 + num2 == target_sum
end)
end
def get_permutations(list) do
@dillonius01
dillonius01 / game-of-life-constructor.js
Created January 16, 2017 18:39
Refactor for Game of Life workshop
var GameOfLife = function(width, height) {
this.width = width;
this.height = height;
this.stepInterval = null; // should be used to hold reference to an interval that is "playing" the game
};
GameOfLife.prototype.createAndShowBoard = function() {
// create <table> element
var goltable = document.createElement("tbody");
@dillonius01
dillonius01 / ES6 Codewars problems
Last active January 16, 2017 21:38
List of Codewars problems demonstrating new ES6 features
Rest/spread operator
Compose Function: https://www.codewars.com/kata/compose-functions-t-combinator/
Wrapped Function: https://www.codewars.com/kata/511ed4593ba69cba1a000002/
Duplicate Arguments: http://www.codewars.com/kata/duplicate-arguments
Default+Rest+Spread: https://www.codewars.com/kata/default-plus-rest-plus-spread
Classes
http://www.codewars.com/kata/cylon-evolution //focus on inheritance
https://www.codewars.com/kata/classy-extentions // pretty basic but ES6 specific
https://www.codewars.com/kata/simple-substitution-cipher-helper //also just a basic OOP problem
@dillonius01
dillonius01 / pig_latin_failure
Last active August 29, 2016 18:46
Pig_Latin function failing to run if-statement
var latinify = function(word) {
var vowels = {a: 1, e: 1, i: 1, o: 1, u: 1}
var letters = word.split("");
for (var i in letters) {
if (letters[i] === "q" && letters[i + 1] === "u") {
// This is the problem block here
// It does not run when I pass strings like 'quiet'
// For some reason it works if I omit everything after the && operator