This file contains hidden or 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
| """ | |
| To Use: | |
| Build your dom structure out of these elements and then call render.() | |
| on the document object to get the dom rendered as a string - either print that out | |
| or write it to a file | |
| """ | |
| class Document: | |
| def __init__(self, dom_elements): |
This file contains hidden or 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
| #include <algorithm> | |
| #include <string> | |
| #include <sstream> | |
| #include <fstream> | |
| #include <iostream> | |
| #include <vector> | |
| using namespace std; | |
| string make_border(const vector<int> &padding_vector, char border_char){ |
This file contains hidden or 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 os | |
| import sys | |
| """Ranked choice voting processes ranked votes as tuples and calculates the winner""" | |
| # a ranked vote is a tuple of the voter preference first to last (can be shorter than candidate list if voter doesn't | |
| # want any votes to go to any specific candidates | |
| # votes is |
This file contains hidden or 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
| from enum import Enum | |
| import pygame.midi | |
| import re | |
| import time | |
| instruments = [ | |
| '0: Acoustic Grand Piano', | |
| '1: Bright Acoustic Piano', | |
| '2: Electric Grand Piano', | |
| '3: Honky-tonk Piano', |
This file contains hidden or 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
| const checkSudoku = (board) => { | |
| let rowCheck = new Array(9).fill(1); | |
| let colCheck = new Array(9).fill(1); | |
| let boxCheck = new Array(9).fill(1); | |
| for(let row = 0; row < 9; row++){ | |
| for(let col = 0; col < 9; col++){ | |
| if( rowCheck[row] &= (1 << board[row][col]) != 0){ | |
| return false; | |
| } | |
| rowCheck[row] |= (1 << board[row][col]); |
This file contains hidden or 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
| function tester(func, input, expected){ | |
| let actual = func(...input); | |
| if ( compare(actual, expected) ){ | |
| console.log( "PASS" ); | |
| } else { | |
| console.log( "FAIL: actual [" + actual + "] did not equal expected [" + expected + "]"); | |
| } | |
| } | |
| function batchTester(func, testCases){ |
This file contains hidden or 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
| const placeMarker = (index) => { | |
| let pad = Array(index); pad.fill(" ");pad.push("|"); | |
| return pad.join(""); | |
| } | |
| const areAnagrams = (word1, word2) => { | |
| if(word1.length != word2.length){ | |
| return false; | |
| } |
This file contains hidden or 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.io.Source | |
| import scala.annotation.tailrec | |
| import scala.collection.mutable.{Map -> MMap} | |
| object WordCounter extends App { | |
| if(args.length != 1){ | |
| println("Give me a file to investigate") | |
| } else { | |
| val wordList = Source.fromFile(args(0)).getLines | |
| .flatMap(_.split("[()<>''+-=!|/ .,:{}\"]")) |
This file contains hidden or 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
| #include <iostream> | |
| #include <functional> | |
| #include <string> | |
| #include <vector> | |
| #include <iostream> | |
| #include <fstream> | |
| #include <iomanip> | |
| #include <algorithm> | |
| #include <cctype> | |
| #include <numeric> |
This file contains hidden or 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.io.FileWriter | |
| object NumberHelper { | |
| def safeMod(num: Int): Int = { | |
| val modded = num % 12 | |
| if (modded < 0){ | |
| modded + 12 | |
| } else { | |
| modded |
NewerOlder