How can I measure the similarity between 2 IP addresses? Is there any code to re-use? I need to measure the similarity of 2 IP addresses. I could not find any sample code in scala or other languages to find the distance between 2 IPs.
In Python there is the ipaddress module which can convert an IP address to an integer, then simply subtract to find the difference.

from ipaddress import ip_address
int(ip_address(‘10.0.0.1’))