Skip to content

Instantly share code, notes, and snippets.

View nomeyer's full-sized avatar

Nick Omeyer nomeyer

View GitHub Profile
@nomeyer
nomeyer / tree.md
Created May 19, 2016 16:14 — forked from hrldcpr/tree.md
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@nomeyer
nomeyer / get_all_positions.py
Last active February 10, 2016 20:54 — forked from matthieualouis/get_all_positions.py
Get all positions of a value in a list
L = [1, 2, 3, 1]
[i for i, x in enumerate(L) if x == value]