Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE HTML>
<html>
<head>
<style>
body {
background-color: black;
}
#mycanvas {
background-color: black;
font-color: green;
"""
Write code that, given a tree with weighted nodes, prints, for each node,
the weight of the subtree rooted at that node (each node only knows it's own ID,
it's parent's ID and it's own weight).
e.g
you get a csv with the following format:
id, parent, weight
import time
def print_board(board):
for row in board:
for column in row:
print(column),
print("")
print("- " * len(board[0]))
def count_neighbours(x, y, board):
import unittest
from functools import partial
class BinaryTree(object):
"""
In computer science, a binary tree is a tree data structure in which each
node has at most two children (referred to as the left child and the right
child).
import unittest
from functools import partial
class BinaryTree(object):
"""
In computer science, a binary tree is a tree data structure in which each
node has at most two children (referred to as the left child and the right
child).