Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shanecandoit
shanecandoit / snap_shot_dates.ipynb
Last active March 1, 2023 21:31
last_24_snapshot_dates
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shanecandoit
shanecandoit / list-tokens-hash.ipynb
Last active March 3, 2023 23:52
python_list_tokens_hashing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shanecandoit
shanecandoit / csv_to_markdown_to_html.py
Created June 28, 2023 21:30
Turn csv text into markdown tables and also into html
def csv_to_markdown_table(csv_string):
"""
Convert a csv style string to a markdown table string.
Args:
csv_string: The csv style string to convert.
Returns:
The markdown table string.
import random
import string
def generate_slug(pattern='cvccvc-cvccvc-xxxxxx-cvccvc-000'):
""" Return something like 'pevqak-jaxkev-evryfd-IGyv-45v94'
given a pattern like: 'cvccvc-cvccvc-xxxxxx-XXxx-00x00'
"""
vowels = 'aeiou'
consonants = 'bcdfghjklmnpqrstvwxyz'
@shanecandoit
shanecandoit / scratch.py
Created June 7, 2024 18:04
leetcode 648 replace words
"""
https://leetcode.com/problems/replace-words/submissions/1280805154/?envType=daily-question&envId=2024-06-07
648. Replace Words
Medium
Topics
Companies
In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word derivative. For example, when the root "help" is followed by the word "ful", we can form a derivative "helpful".
@shanecandoit
shanecandoit / roman-to-integer.py
Created June 7, 2024 18:13
Convert roman numerals to integers
"""
https://leetcode.com/problems/roman-to-integer/description/
13. Roman to Integer
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Symbol Value
I 1
V 5
@shanecandoit
shanecandoit / unique-paths-py
Created June 10, 2024 22:01
unique paths to end of maze, solve back to front
# https://leetcode.com/problems/unique-paths/description/
"""
62. Unique Paths
Medium
Topics
Companies
There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right at any point in time.
@shanecandoit
shanecandoit / longest_valid_parentheses.py
Created June 12, 2024 15:32
longest valid parens using a stack
"""
32. Longest Valid Parentheses
Hard
Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses
substring
Example 1:
Input: s = "(()"
from typing import List
class Solution:
def canJump(self, nums: List[int]) -> bool:
"""
55. Jump Game
You are given an integer array nums.
You are initially positioned at the array's first index,
and each element in the array represents your maximum jump length at that position.