Skip to content

Instantly share code, notes, and snippets.

View frederni's full-sized avatar
🏳️‍🌈

Frederick Nilsen frederni

🏳️‍🌈
  • Nabla
  • Oslo
View GitHub Profile
@frederni
frederni / exthash.py
Created June 16, 2021 12:58
TDT4145 Extendible hashing
# Simple script used in extendible hashing tasks for course TDT4145 at NTNU
import math
inputs = [int(n) for n in input("Paste list of keys, sep with ',': ").split(',')]
n = input("Enter hash function, k mod ")
if n == '':
# Fallback if no hash function is given
m = max(inputs)
n = math.floor(math.sqrt(m))**2
else: n = int(n)