Skip to content

Instantly share code, notes, and snippets.

class InvalidInput(Exception):
pass
def possible_combinations(attributes):
"""Takes in a user_attribute like described above, and returns
all possible combinations of 1 of each of the attributes
Every attribute has a list
Returns:
import random
def merge(lista, listb):
pa = 0
pb = 0
result = []
while True:
if lista[pa] <= listb[pb]:
result.append(lista[pa])
import random
def partition(_list, pivot):
'''Given a list and a pivot, returns 3 lists:
low, [pivot], and high
'''
pointer = 0
low = []
high = []
@nichochar
nichochar / tree_heap.py
Last active September 19, 2018 09:41
python tree heap implementation
from collections import deque
import random
class InvalidOperation(Exception):
pass
class Node(object):
def __init__(self, data, left=None, right=None, parent=None):
@nichochar
nichochar / json_file_indenter
Created July 6, 2015 20:25
json file indenter script
#!/usr/bin/env python
# Takes in a file as an input, and creates a file with the same name
# with the suffix ".clean"
__author__ = 'Nicholas Charriere'
__VERSION__ = 0.1
import argparse
import sys
import json
@nichochar
nichochar / TweetSet.scala
Created May 26, 2015 01:46
scala tweet set
package objsets
/**
* A class to represent tweets.
*/
class Tweet(val user: String, val text: String, val retweets: Int) {
override def toString: String =
"User: " + user + "\n" +
"Text: " + text + " [" + retweets + "]"
}
Verifying I am +nichochar on my passcard. https://onename.com/nichochar
class Node():
def __init__(self, next_node=None, previous_node=None, data=None):
self.next_node = next_node
self.previous_node = previous_node
self.data = data
class LinkedList():
def __init__(self, node):