Skip to content

Instantly share code, notes, and snippets.

@aenhsaihan
aenhsaihan / merkletree-solution.py
Created June 10, 2020 03:19 — forked from georgeRenard/merkletree-solution.py
Merkle Tree Implementation Solution
def build_root(self, iterable):
collection = list(iterable)
assert(len(collection) != 0)
if len(collection) % 2 != 0:
collection.append(collection[-1])
collection = [self.__Node(self.digest(x)) for x in collection]
return self.__build_root(collection)
def __build_root(self, collection):
size = len(collection)
@aenhsaihan
aenhsaihan / test
Last active December 29, 2015 11:08
Creating my first test
if (jsonData2 != nil) {
NSError *errorInfo2;
id backToDict = [NSJSONSerialization JSONObjectWithData:jsonData2 options:NSJSONReadingMutableContainers error:&errorInfo2];
if (!backToDict) {
NSLog(@"%@", [errorInfo2 localizedDescription]);
} else {
NSLog(@"%@", backToDict);