Unix permission bitmask check
Your task
Implement a Unix-style permission check over a bitmask. Permissions are named bits given as a dict mapping name to bit value (a power of two). A user holds a granted integer mask. Given the granted mask, the dict of named bits, and a list of required permission names, return True only if EVERY required permission's bit is set in the granted mask. If a required name is not in the dict, treat the requirement as unsatisfiable and return False.
Examples
has_permissions(granted: int, bits: dict, required: list[str]) -> boolExample 1
Input
has_permissions(3, {"read": 1, "write": 2, "delete": 4, "admin": 8}, ["read", "write"])Output
True