Skip to content

Instantly share code, notes, and snippets.

View hdorothea's full-sized avatar

Dorothea Hörmann hdorothea

View GitHub Profile
var FAILURE_COEFF = 10;
var MAX_SERVER_LATENCY = 200;
function getRandomBool(n) {
var maxRandomCoeff = 1000;
if (n > maxRandomCoeff) n = maxRandomCoeff;
return Math.floor(Math.random() * maxRandomCoeff) % n === 0;
}
function getSuggestions(text) {
// input is an ordered array
let input_1 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
// we pick a random value from the input array
let randomValue = input_1[Math.floor(Math.random() * input_1.length)];
let binaryGuessIndex = (sortedArray:any[]): number => Math.floor(sortedArray.length/2)
function search (sortedArray:any[], value:any): any {
@hdorothea
hdorothea / hash_table.ipynb
Last active November 17, 2016 16:38
A one afternoon "proof of I understood" implementation of a hash table in python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hdorothea
hdorothea / tictactoe.py
Created August 21, 2016 02:16
A simple tic-tac-toe game in Python
import itertools
class Board(object):
def __init__(self):
self.rows = [[' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' ']]
@property
def diagonals(self):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hdorothea
hdorothea / cracklepop.s
Created July 27, 2016 14:59
CracklePop in x86 assembly
.section .data
number:
.quad 0 # we start out with 0
crackle_output:
.ascii "Crackle\n"
pop_output:
.ascii "Pop\n"