From 4b0bd536ed1d5e8ed81cf4d4b5c5ad8879be4bbd Mon Sep 17 00:00:00 2001 From: murtada666 <91660848+murtada666@users.noreply.github.com> Date: Tue, 12 Jul 2022 23:54:37 +0300 Subject: [PATCH 1/3] IP_classifier --- main.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 71a3166..9a6906c 100644 --- a/main.py +++ b/main.py @@ -1,6 +1,52 @@ -def solution(): - pass +#murtada hayder + +import re + +def solution(value): + #A + if (value>str(0) and valuestr(127) and valuestr(191) and valuestr(223) and valuestr(239) and value Date: Wed, 13 Jul 2022 16:22:23 +0300 Subject: [PATCH 2/3] Update main.py --- main.py | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index 9a6906c..c783fbe 100644 --- a/main.py +++ b/main.py @@ -1,42 +1,45 @@ #murtada hayder - +#If you don't like my code you should check your eyes. import re -def solution(value): +def solution(ip): + + value = ip.split(".") + first_value = int(value[0]) #A - if (value>str(0) and value 0 and first_value < 128): + if (re.match(r"^10\.", ip)): return "Output: Class: A, Designation: Private" - elif (re.match(r"^127\.1/\.|^127\.", value)): + elif (re.match(r"^127\.1/\.|^127\.", ip)): return "Output: Class: A, Designation: Special" else: return "Output: Class: A, Designation: Public" #B - elif (value>str(127) and value 127 and first_value < 192): + if (re.match(r"(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)", ip)): return "Output: Class: B, Designation: Private" - elif (re.match(r"^169\.254\.", value)): + elif (re.match(r"^169\.254\.", ip)): return "Output: Class: B, Designation: Private" else: return "Output: Class: B, Designation: Public" #C - elif (value>str(191) and value 191 and first_value < 224): + if (re.match(r"^192\.168\.", ip)): return "Output: Class: C, Designation: Private" else: return "Output: Class: C, Designation: Public" #D - elif (value>str(223) and value 223 and first_value < 240): return "Output: Class: D, Designation: Public" #E - elif (value>str(239) and value 239 and first_value < 256): return "Output: Class: E, Designation: Public" else: @@ -49,4 +52,3 @@ def solution(value): print(solution("127.0.0.1/24")) print(solution("192.168.1.1/24")) - From 49c9845494c11347d7a1bf19136115e781c5b07d Mon Sep 17 00:00:00 2001 From: murtada666 <91660848+murtada666@users.noreply.github.com> Date: Mon, 29 Aug 2022 16:30:16 +0300 Subject: [PATCH 3/3] Update main.py --- main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index c783fbe..44bb098 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,7 @@ #murtada hayder -#If you don't like my code you should check your eyes. +#If you don't like my code you should check your eyes.(JK) +#regex + import re def solution(ip):