Python Help


  • 0
    K

    Can someone explain how the IP problem works? I don't understand where the "/32", "/29", and "255.0.0.16/32" comes from in the problem explanation.

    This is as far as I got. It converts each to binary.

    class Solution:
        def ipToCIDR(self, ip, range):
            """
            :type ip: str
            :type range: int
            :rtype: List[str]
            """
            ipArr = ip.split(".")
            print(ipArr)
            for idx, x in enumerate(ipArr):
                print(x)
                x = int(x)
                ipArr[idx] = bin(x).lstrip('-0b').zfill(8)
            print(ipArr)
            ```
    Thanks!

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.