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 count_change(amount, coins): | |
| if amount == 0: | |
| return 1 | |
| if len(coins) == 0 or amount < 0: | |
| return 0 | |
| return count_change(amount - coins[-1], coins) + \ | |
| count_change(amount, coins[:-1]) | |
| results = {} |
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 random | |
| def hash_table(m): | |
| """ initial hash table, m empty entries """ | |
| return [[] for i in range(m)] | |
| def hash_mod(key, mod, func=hash): | |
| return func(key) % mod | |
| def contained(candidate_key, list_of_items): |
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 Node(): | |
| def __init__(self, val): | |
| self.value = val | |
| self.next = None | |
| def __repr__(self): | |
| return "[" + str(self.value) + "," + str(id(self.next)) + "]" | |
| class LinkedList(): | |
| def __init__(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
| def our_for(iterable, what_to_do): | |
| iterator = iter(iterable) | |
| while True: | |
| try: | |
| i = next(iterator) | |
| what_to_do(i) | |
| except StopIteration as e: | |
| return | |
| class A: |
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
| function Scope() { | |
| this.$$watchers = []; | |
| this.$$lastDirtyWatch = null; | |
| } | |
| Scope.prototype.$$areEqual = function(newValue, oldValue, valueEq) { | |
| if (valueEq) { | |
| return _.isEqual(newValue, oldValue); | |
| } else { | |
| return newValue === oldValue || |
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 PIL import Image | |
| from matrix import * | |
| def image2bitmap(path): | |
| ''' Given a string 'path' of image file in "real" format (.jpg/.bmp etc.) creates a new file in format .bitmap under the same directory which can then be loaded into class Matrix using Matrix.load() ''' | |
| from PIL import Image | |
| image = Image.open(path) | |
| image = image.convert("L") | |
| im = image.load() | |
| w,h = image.size |
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
| exports.doTurn = function(pw) { | |
| }; |
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 do_turn(game): | |
| pass |
OlderNewer