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
# NODE CLASS PROVIDED | |
class Node: | |
def __init__(self,data): | |
self.right=self.left=None | |
self.data = data | |
class Solution: | |
# INSERT METHOD PROVIDED | |
def insert(self,root,data): | |
if root==None: |
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
""" | |
I found some problems with my initial solution including a huge | |
flaw in the final logic. | |
""" | |
BRACKETS = dict(['()', '{}', '[]', "<>"]) | |
CLOSING_BRACKETS = set(BRACKETS.values()) | |
def brackets(test_str): | |
bracket_stack = [] |
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
""" | |
anagram_1 was my initial naive approach to the simple anagram-check problem. | |
anagram_2 is a more compact version which should provide the same results. | |
However out of interests sake I ran timeit tests against both functions and got surprising results: | |
Testing anagram_1 against a small set of words resulted in about 21usec going over each loop | |
>python -m timeit -s "from anagram_test import test, anagram_1" -- "test(anagram_1)" | |
20000 loops, best of 5: 14.9 usec per loop | |
But anagram_2, the more compact version, was surprisingly slower! |
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
const uint8_t numColumns = 5; | |
const uint8_t frames[16 * numColumns] PROGMEM = { | |
0x82, 0x7C, 0x7C, 0x7C, 0x82, // digit 0 | |
0xFE, 0xBC, 0x00, 0xFC, 0xFE, // digit 1 | |
0xB8, 0x74, 0x6C, 0x6C, 0x9C, // digit 2 | |
0xBA, 0x7C, 0x6C, 0x6C, 0x92, // digit 3 | |
0xE6, 0xD6, 0xB6, 0x00, 0xF6, // digit 4 | |
0x1A, 0x6C, 0x6C, 0x6C, 0x72, // digit 5 | |
0xC2, 0xAC, 0x6C, 0x6C, 0xF2, // digit 6 | |
0x7E, 0x70, 0x6E, 0x5E, 0x3E, // digit 7 |
NewerOlder