Skip to content

Instantly share code, notes, and snippets.

View QuantumFractal's full-sized avatar

Thomas Moll QuantumFractal

View GitHub Profile
import itertools as i
import sys
def main():
with open("test.pr", 'r') as f:
n = int(f.read(1))
def main():
cases = int(input())
for case in range(cases):
print(deletions(input()))
def deletions(s):
# Set our first char
last = s[0]
''' Requestester '''
import requests
base = 'http://helixtangowebapi.azurewebsites.net'
response = requests.get(base+'/api/values')
print response.text
@QuantumFractal
QuantumFractal / sunglasses.py
Created September 17, 2015 23:20
Post Order N-Ary Tree Traversal using Iteration
''' Question: N-Ary tree post order traversal
Twist: Using only iteration!
Rationale:
This essentially becomes a Dynamic Programming question. Instead
of using Top-Down recursion. We build up our solution from the bottom
up using a list and our base case. The base case is if a node has no
children.
I built a simply NaryTree for testing and a function that takes a node
@QuantumFractal
QuantumFractal / all-your-base.py
Last active September 9, 2015 16:19
Google Code Jam Solutions
''' All Your Base
2009 1-C
thomas moll 2015
'''
import sys
filename = 'A-large-practice.in'
outfile = 'file.out'
@QuantumFractal
QuantumFractal / README.md
Last active September 1, 2015 15:30
Fun with Brainfuck

Yeah yeah, gist's aren't supposed to have README's. Whatever. In order to run this stuff I'll write a brainfuck interpreter. Run it with >python brainfuck.py file.bf

Enjoy!

def check_parenthesis(string):
stack = Stack()
# We're using a dict which allows us to do some fun things!
brackets = {'{':'}', '[':']', '(':')'}
for character in string:
# Keys being the left-side brackets
if character in brackets.keys():
stack.push(character)
@QuantumFractal
QuantumFractal / tom_fn.c
Created August 10, 2015 21:14
Q-bit layout
#include "keymap_common.h"
/*
* SpaceFN
* http://geekhack.org/index.php?topic=51069.0
*/
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Keymap 0: Default Layer
* ,-----------------------------------------------------------.
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
@QuantumFractal
QuantumFractal / VillagerDeathSimulator.py
Last active August 29, 2015 14:25
Dynamic Graphs // A Sketch
import inspect
""" Dynamic weighted graphs
tmoll 2015
"""
class DynamicWeight(object):
"""docstring for DynamicWeight"""
def __init__(self, weight, weight_func):
self.weight_func = weight_func
@QuantumFractal
QuantumFractal / Layers
Last active August 29, 2015 14:24
Q-bit Keymap Layers
Layer 0
,-----------------------------------------------------------.
|Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp |
|-----------------------------------------------------------|
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|
|-----------------------------------------------------------|
|Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
|-----------------------------------------------------------|
|Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |
|-----------------------------------------------------------|