🌲 Invert a binary tree! 🌲
Except with 3 catches:
- It must invert the keys ("bit-reversal permutation")
- It must be a dependency-free, pure recursive function
- It must have type
Bit -> Tree -> Tree(i.e., a direct recursion with max 1 bit state)
| import os | |
| import torch | |
| import psutil | |
| import datasets | |
| import glob | |
| from transformers import ( | |
| AutoTokenizer, LlamaConfig, LlamaForCausalLM, Trainer, TrainingArguments, | |
| DataCollatorForLanguageModeling | |
| ) |
| from typing import Tuple, Dict, List | |
| import spacy | |
| from spacy.cli import download | |
| from spacy.tokens import Token | |
| class DependencyParser: | |
| def __init__(self): | |
| self.NEGATION = {"no", "not", "n't", "never", "none"} |
| import tkinter as tk | |
| from tkinter import simpledialog, messagebox | |
| class NestedDictManager: | |
| def __init__(self, root, data): | |
| self.root = root | |
| self.root.title("Nested Dictionary Manager") | |
| self.data = data # Use the provided dictionary | |
| self.tree = tk.ttk.Treeview(self.root) |
| import tkinter as tk | |
| from tkinter import simpledialog, messagebox | |
| class NestedDictManager: | |
| def __init__(self, root): | |
| self.root = root | |
| self.root.title("Nested Dictionary Manager") | |
| self.data = { | |
| 'key1': 'value1', |
| #!/usr/bin/env bash | |
| set -e | |
| # pj-append.bash is a timestamped log file for you, a human. Set up a cron job to launch it every | |
| # hour to note what you were working on, or append lines from the terminal whenever you're chewing | |
| # on a hard problem. | |
| # | |
| # Use the data to build a picture of what you worked on during the last week, or grep | |
| # last quarter's log to find out why you decided to use library A instead of library B. | |
| # |
| // ==UserScript== | |
| // @name noVNC Paste for Proxmox | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.2a | |
| // @description Pastes text into a noVNC window (for use with Proxmox specifically) | |
| // @author Chester Enright | |
| // @match https://* | |
| // @include /^.*novnc.*/ | |
| // @require http://code.jquery.com/jquery-3.3.1.min.js | |
| // @grant none |
| """Dag Factory""" | |
| from datetime import datetime | |
| from airflow import DAG | |
| def create_dag(schedule, default_args, definition): | |
| """Create dags dynamically.""" | |
| with DAG( | |
| definition["name"], schedule_interval=schedule, default_args=default_args | |
| ) as dag: |
I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.
So below I made a list of leetcode problems that are as close to grokking problems as possible.