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 inspect | |
| from functools import wraps | |
| def _log_method(method): | |
| @wraps(method) | |
| def wrapped(self, *a, **kw): | |
| doc = { | |
| # module where class was defined | |
| "module": type(self).__module__, |
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 collections import Counter | |
| def pad(board): | |
| """ | |
| Zero-pad a square board | |
| """ | |
| n = len(board) | |
| return [[0] * (n + 2)] + [[0, *row, 0] for row in board] + [[0] * (n + 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
| """Solve 9x9 Sudoku with a tree-based backtracking algorithm | |
| Approach: | |
| - On an empty cell select an available digit and move on. | |
| - If there isn't an available digit then backtrack to the | |
| previous cell to try a different available digit. | |
| - If there is a valid digit for the last cell then the game is solved. | |
| Implementation: | |
| Model a solution as a particular path down a tree, where |
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
| CREATE ROLE writeaccess; | |
| GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO writeaccess; | |
| ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO writeaccess; | |
| GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO writeaccess; | |
| ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO writeaccess; | |
| CREATE USER admin WITH PASSWORD 'password'; | |
| GRANT writeaccess TO admin; |
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
| [tool.poetry] | |
| name = "example" | |
| version = "0.1.0" | |
| description = "" | |
| authors = ["Gus Ostow <ostowster@gmail.com>"] | |
| [tool.poetry.dependencies] | |
| python = "^3.7" | |
| [tool.poetry.dev-dependencies] |
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
| [tool.poetry] | |
| name = "example" | |
| version = "0.1.0" | |
| description = "" | |
| authors = ["Gus Ostow <ostowster@gmail.com>"] | |
| [tool.poetry.dependencies] | |
| python = "^3.7" | |
| [tool.poetry.dev-dependencies] |
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 itertools import combinations | |
| class Solution: | |
| def lenLongestFibSubseq(self, A: List[int]) -> int: | |
| """ | |
| Brute force solution | |
| """ | |
| terms = set(A) | |
| max_len = 0 # max length is 0 unless there's a sequence > 3 long | |
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
| [tool.poetry] | |
| name = "db_scripts" | |
| version = "0.1.0" | |
| description = "" | |
| authors = ["Gus Ostow <ostowster@gmail.com>"] | |
| [tool.poetry.dependencies] | |
| python = "=3.6.8" | |
| numpy = "1.16.4" | |
| pandas = "=0.24.2" |