Add 2026.03.04
Some checks failed
Deploy to birb co. production / deploy (push) Failing after 6s

This commit is contained in:
2026-03-04 14:55:42 -08:00
parent a4b8468cba
commit b6caeb0130
2 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
class Dictionary:
backing: "list" = [None] * 26
def hash(self, key: str):
return ord(key) - 97
def get(self, key: str):
index = self.hash(key)
return self.backing[index]
def set(self, key: str, value):
index = self.hash(key)
self.backing[index] = value
sample_dict = Dictionary()
sample_dict.set("h", "hello")
sample_dict.set("i", "hello")
print(sample_dict.get("j"))
print(sample_dict.get("i"))

View File

@@ -0,0 +1,7 @@
# Homework:
# Make the Dictionary class work for any length string. Use any method you can think of.
# The following should work:
# sample_dict = Dictionary()
# sample_dict.set("test string", "test value")
# sample_dict.set("foo", "bar")