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 lightning as L | |
import torch | |
from datasets import concatenate_datasets, load_dataset | |
from lightning.pytorch.callbacks.early_stopping import EarlyStopping | |
from lightning.pytorch.callbacks.model_checkpoint import ModelCheckpoint | |
from tokenizers import Tokenizer | |
from tokenizers.models import BPE | |
from tokenizers.pre_tokenizers import Whitespace | |
from tokenizers.trainers import BpeTrainer |
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
size = 4 | |
winning_pairs = [ | |
*[[(i, j) for j in range(size)] for i in range(size)], | |
*[[(j, i) for j in range(size)] for i in range(size)], | |
[(i, i) for i in range(size)], | |
[(i, (size - 1) - i) for i in range(size)], | |
] | |
possible_moves = [(i, j) for j in range(size) for i in range(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
from random import randint | |
def row(m, i): | |
return m[i] | |
def col(m, i): | |
return [j[i] for j in m] |
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
type vector = number[]; | |
type matrix = vector[]; | |
function interchange(m: matrix, from: number, to: number) { | |
[m[to], m[from]] = [m[from], m[to]]; | |
return m; | |
} | |
function addition(m: matrix, from: number, to: number, c: number) { | |
m[to] = m[to].map((e, i) => e + c * m[from][i]); |
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 re | |
import sys | |
def smart_quotes(content): | |
content = re.sub(r"\"(.*?)\"", r"“\1”", content) | |
content = re.sub(r"'(.*?)'", r"‘\1’", content) | |
content = re.sub(r"'", r"’", content) | |
return content |
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 pathlib import Path | |
from sys import argv | |
def main(): | |
if len(argv) < 2: | |
print("Please specify a file path as an argument.") | |
exit(1) | |
elif len(argv) > 2: | |
print("Unknown options: " + " ".join(argv[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
from sys import argv | |
from pathlib import Path | |
def main(): | |
if len(argv) < 2: | |
print("Please specify the directory or file to count the lines of as an argument.") | |
exit(1) | |
elif len(argv) > 2: | |
print("Unknown options: " + " ".join(argv[2:])) |