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 tick(world): | |
| output_world = world.copy() | |
| if len(world) <= 2: | |
| return set() | |
| for cell in world: | |
| if len(get_live_neighbors(cell, world)) < 2: | |
| output_world.remove(cell) |
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
| import math | |
| from collections import deque | |
| class Node: | |
| balanceFactor = 0 | |
| height = 0 | |
| lchild = None | |
| rchild = None | |
| def __init__(self, key): | |
| self.key = key |
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
| import math | |
| from collections import deque | |
| class Node: | |
| lchild = None | |
| rchild = None | |
| def __init__(self, key): | |
| self.key = key | |
| class Tree: |
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 sort(l): | |
| for x in range(len(l)-1): | |
| for i in range(len(l)-(x+1)): | |
| if l[i] > l[i+ 1]: | |
| swap(l, i, i+1) | |
| return l | |
| def swap(l, index1, index2): | |
| buff = l[index1] | |
| l[index1] = l[index2] |
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 sort(l): | |
| if len(l) <= 1 : | |
| return l | |
| left = [] | |
| right = [] | |
| pivot = l[len(l)/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 merge(l1, l2): | |
| result = [] | |
| pos_left = 0 | |
| pos_right = 0 | |
| for i in range(len(l1) + len(l2)): | |
| if(pos_left >= len(l1)): | |
| result = result + l2[pos_right:len(l2)] | |
| break |
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
| <!-- | |
| --> | |
| <html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html"; charset="UTF-8"/> | |
| <title>Page Title</title> | |
| <script type="text/javascript" src="d3.js"></script> | |
| <link rel="stylesheet" type="text/css" href="test.css"> | |
| </head> |
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
| """Expression Compiler/Evaluator | |
| This is a simple expression compiler. | |
| It has the following limitations | |
| - supported operation: +,-,/,%, | |
| - only supports binary operations enclosed in () | |
| - ((1+3) + (1+3)) -- valid | |
| - (1+3) + (1+3) -- invalid | |
| - does not support implict multiplication | |
| - (1(1+3)) -- bad juju |
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
| object App { | |
| def main (args: Array[String]){ | |
| val fp = candidate(_) | |
| val f = decorate(fp,decorator) // F o G | |
| println(f("Hello World")) | |
| println(fp("Hello World")) |
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
| /* | |
| a by name parameter is not evaluated at the point of function application | |
| but rather it is evaluated at each use within the function | |
| */ | |
| object App { | |
| def main (args: Array[String]){ | |
| println(delayed(nano())) | |
| } | |
| def nano() ={ |