This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sys import stdin | |
| #amount = int(stdin.readline()) | |
| class Node(object): | |
| def __init__(self, id): | |
| self.id = id | |
| self.neighboors = [] | |
| class Edge(object): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def f(digits, target, current=None, rest=None): | |
| """ | |
| It doesnt work for the given case, it does for small runs | |
| Some performance situation... | |
| The idea is to try each digit with each of the operators | |
| once the digit have been used, it will be appended to the current | |
| and a new iteration will be done with the other digits. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Stack(object): | |
| def __init__(self): | |
| self.stack = [] | |
| def push(self, elem): | |
| self.stack.append(elem) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pow(a,b): | |
| if b == 0: | |
| return 1 | |
| if b == 1: | |
| return a | |
| if b % 2 == 1: | |
| return pow(a,b/2)*pow(a,b/2)*a | |
| if b % 2 == 0: | |
| return pow(a,b/2)*pow(a,b/2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def is_int(c): | |
| return ord(c) >= 48 and ord(c) <= 58 | |
| def get_int(c): | |
| return ord(c) - 48 | |
| def int_to_parse(input): | |
| result = 0 | |
| for x in xrange(0, len(input)): | |
| character = input[x] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BTree(object): | |
| def __init__(self, value, left=None, right=None): | |
| self.value = value | |
| self.left = left | |
| self.right = right | |
| def bfs(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| arr = [1,2,3, 4, 5, 6] | |
| #In Place | |
| def binary_search(elem, arr, init=None, end=None): | |
| if not init and not end: | |
| init = 0 | |
| end = len(arr) | |
| if end < init or init >= len(arr): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "errors" | |
| "fmt" | |
| ) | |
| type KeyPair struct{ | |
| key string | |
| value string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "flag" | |
| "time" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Tree(object): | |
| def __init__(self, value): | |
| self.value = value | |
| self.left = None | |
| self.right = None | |
| def add(self, number): |