Skip to content

Instantly share code, notes, and snippets.

def chunk(xs, n):
""" Split an iterable into chunks.
Parameters
----------
xs : iterable
Iterable to be split.
n : int
Chunk size.
@dslaw
dslaw / btree.cpp
Created May 29, 2016 21:17
Invert binary tree
#include "btree.h"
template <typename T>
void Btree<T>::insert(const T &x) {
if (root == nullptr) {
node_ptr node = std::make_unique<Node>(x);
root = std::move(node);
return;
}
#!/usr/bin/env python3
""" Binary search tree with method to invert in-place. """
class Node(object):
def __init__(self, x):
self.value = x
self.left = None
self.right = None