<jupyter_start><jupyter_text>2020년 11월 22일 일요일 leetCode - Validate IP Address (Python) 문제 : https://leetcode.com/problems/validate-ip-address/ 블로그 : https://somjang.tistory.com/entry/leetCode-468-Validate-IP-Address-Python  첫번째 시도<jupyter_code>class Solution:
    def validIPAddress(self, IP: str) -> str:
        def checkIPv4(IP):
            ip_split = IP.split(".")

            for ip in ip_split:
                if len(ip) == 0 or len(ip) > 3 or  ip.isdigit() == False or (ip[0] == '0' and len(ip) != 1) or int(ip) > 255:
                    return "Neither" 
            return 'IPv4'
        
        def checkIPv6(IP):
            ip_split = IP.split(":")

            for ip in ip_split:
                if len(ip) == 0 or len(ip) > 4:
                    return "Neither"
                for c in ip:
                     if c.lower() not in '0123456789abcdef':
                        return "Neither" 
            return "IPv6"

        
        if len(IP.split("."))-1 == 3:
            return checkIPv4(IP)
        elif len(IP.split(":"))-1 == 7:
            return checkIPv6(IP)
        
        return "Neither"<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1285591026747196, 'fraction_numerical': 0.03537532355478861, 'mean_word_length': 1.600896860986547, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '331353', 'license': 'MIT', 'n_tokens_mistral': 431, 'n_tokens_neox': 402, 'n_words': 92, 'path': 'DAY 201 ~ 300/DAY267_[leetCode] Validate IP Address (Python).ipynb', 'repo_name': 'SOMJANG/CODINGTEST_PRACTICE', 'size': '1159'}