-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd17471
commit 227171e
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Validação de IP\n", | ||
"Data: 20/03/2024. De: Codewars. Link para o kata.\n", | ||
"\n", | ||
"## Descrição\n", | ||
"Escreva um algoritmo que identificará endereços IPv4 válidos no formato decimal-ponto. Os IPs devem ser considerados válidos se consistirem de quatro octetos, com valores entre 0 e 255, inclusive. Exemplos de entradas válidas:\n", | ||
"\n", | ||
"# Exemplos de entradas válidas:\n", | ||
"\n", | ||
"1.2.3.4\n", | ||
"123.45.67.89\n", | ||
"Exemplos de entradas inválidas:\n", | ||
"\n", | ||
"1.2.3\n", | ||
"1.2.3.4.5\n", | ||
"123.456.78.90\n", | ||
"123.045.067.089\n", | ||
"Notas\n", | ||
"\n", | ||
"Zeros à esquerda (por exemplo, 01.02.03.04) são considerados inválidos\n", | ||
"As entradas estão garantidas de serem uma única string" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def validaIP(strng):\n", | ||
" pass" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"print(validaIP('12.255.56.1')) # expects True\n", | ||
"print(validaIP('')) # expects False\n", | ||
"print(validaIP('abc.def.ghi.jkl')) # expects False\n", | ||
"print(validaIP('123.456.789.0')) # expects False\n", | ||
"print(validaIP('12.34.56')) # expects False\n", | ||
"print(validaIP('12.34.56 .1')) # expects False\n", | ||
"print(validaIP('12.34.56.-1')) # expects False\n", | ||
"print(validaIP('123.045.067.089')) # expects False\n", | ||
"print(validaIP('127.1.1.0')) # expects True\n", | ||
"print(validaIP('0.0.0.0')) # expects True\n", | ||
"print(validaIP('0.34.82.53')) # expects True\n", | ||
"print(validaIP('192.168.1.300')) # expects False" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |