Deep Freeze for Hashing

medium
Unit 21 · Immutability0/3 to milestone

Dicts and lists can't be used as dict keys or set members. Implement freeze(obj) that converts a nested structure into a hashable, immutable equivalent:

  • dict → frozenset of (key, frozen_value) pairs
  • list / tuple → tuple of frozen items
  • set → frozenset of frozen items
  • anything else is returned unchanged
Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Deep Freeze for Hashing · TechGradify