Skip to content

Instantly share code, notes, and snippets.

View futuretechlab's full-sized avatar

FutureTechLab futuretechlab

View GitHub Profile
@futuretechlab
futuretechlab / levenshtein_distance.py
Last active April 27, 2025 14:38
Levenshtein Distance
def levenshtein_distance(s1, s2):
# Initialize dynamic programming table using list comprehension
dp = [[i + j if i * j == 0 else 0 for j in range(len(s2) + 1)] for i in range(len(s1) + 1)]
# Fill DP table
for i in range(1, len(s1) + 1):
for j in range(1, len(s2) + 1):
cost = 0 if s1[i - 1] == s2[j - 1] else 1
dp[i][j] = min(
dp[i - 1][j] + 1, # Deletion
@futuretechlab
futuretechlab / spellingbee.py
Created April 27, 2025 03:03
NYT Spelling Bee Solver
import itertools
import nltk
nltk.download('words')
from nltk.corpus import words
# Step 1: Build the dictionary
word_list = words.words()
# Assign primes to letters
primes = [