Skip to content

Instantly share code, notes, and snippets.

View unfrgivn's full-sized avatar
💜
We're all doing our best, support one another

Brad Ash unfrgivn

💜
We're all doing our best, support one another
View GitHub Profile
@unfrgivn
unfrgivn / ip_in_cidr.py
Created February 23, 2024 02:13
IP in CIDR Block
'''
Given an IP and a CIDR block, write a utility function to determine whether an input IP belongs to the CIDR block or not. Solution from a recent interview:
# Write a function to return back a boolean (true or false) given inputs of the following:
# 1. Candidate IP - 10.25.22.233
# 2. Mask size - 22
# 3. Subnet IP - 10.25.11.111
'''
def convert_to_int(ip):