-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5915 from espinoleandroo/main
Reto #18 - java
- Loading branch information
Showing
4 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
Retos/Reto #18 - WEB SCRAPING [Difícil]/java/EspinoLeandroo.java
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,29 @@ | ||
import org.jsoup.Jsoup; | ||
import org.jsoup.nodes.Document; | ||
import org.jsoup.nodes.Element; | ||
import org.jsoup.select.Elements; | ||
import java.io.IOException; | ||
|
||
public class EspinoLeandroo { | ||
|
||
public static void main(String[] args) { | ||
String url = "https://holamundo.day"; | ||
|
||
try { | ||
Document doc = Jsoup.connect(url).get(); | ||
|
||
// Encuentra la sección de la agenda del día 8 | ||
Elements agendaItems = doc.select("div.agenda-day-8 div.agenda-item"); | ||
|
||
// Itera sobre los elementos de la agenda e imprime la hora e información | ||
for (Element item : agendaItems) { | ||
String hora = item.select("span.agenda-hour").text(); | ||
String informacion = item.select("span.agenda-info").text(); | ||
System.out.println(hora + " | " + informacion); | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
8 changes: 8 additions & 0 deletions
8
Retos/Reto #18 - WEB SCRAPING [Difícil]/python/EspinoLeandroo.py
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,8 @@ | ||
from bs4 import BeautifulSoup | ||
import requests | ||
|
||
blockquotes = BeautifulSoup(requests.get( | ||
"https://holamundo.day").content).find_all("blockquote") | ||
|
||
for blockquote in blockquotes[21:]: | ||
print(blockquote.text) |
37 changes: 37 additions & 0 deletions
37
Retos/Reto #19 - ANÁLISIS DE TEXTO [Media]/java/EspinoLeandroo.java
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,37 @@ | ||
public class EspinoLeandroo { | ||
|
||
public static void main(String[] args) { | ||
String texto = "Este es un ejemplo de análisis de texto. Contiene varias oraciones y palabras de diferentes longitudes."; | ||
|
||
int numeroPalabras = 0; | ||
int longitudTotalPalabras = 0; | ||
int numeroOraciones = 0; | ||
String palabraMasLarga = ""; | ||
|
||
String[] palabras = texto.split("\\s+"); | ||
|
||
for (String palabra : palabras) { | ||
// Elimina signos de puntuación al final de las palabras | ||
|
||
if (palabra.contains(".") || palabra.contains("!") || palabra.contains("?")) { | ||
numeroOraciones++; | ||
} | ||
|
||
palabra = palabra.replaceAll("[.,;!?]+$", ""); | ||
|
||
numeroPalabras++; | ||
longitudTotalPalabras += palabra.length(); | ||
|
||
if (palabra.length() > palabraMasLarga.length()) { | ||
palabraMasLarga = palabra; | ||
} | ||
} | ||
|
||
double longitudMediaPalabras = (double) longitudTotalPalabras / numeroPalabras; | ||
|
||
System.out.println("Número total de palabras: " + numeroPalabras); | ||
System.out.println("Longitud media de las palabras: " + longitudMediaPalabras); | ||
System.out.println("Número de oraciones: " + numeroOraciones); | ||
System.out.println("Palabra más larga: " + palabraMasLarga); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Retos/Reto #36 - PERMUTACIONES [Media]/python/EspinoLeandroo.py
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,19 @@ | ||
def generate_permutations(word): | ||
def generate_permutations_helper(word, index, permutations): | ||
if index == len(word) - 1: | ||
permutations.append(''.join(word)) | ||
else: | ||
for i in range(index, len(word)): | ||
word[index], word[i] = word[i], word[index] | ||
generate_permutations_helper(word, index + 1, permutations) | ||
word[index], word[i] = word[i], word[index] # Deshacer el intercambio para volver al estado original | ||
|
||
permutations = [] | ||
generate_permutations_helper(list(word), 0, permutations) | ||
return permutations | ||
|
||
if __name__ == "__main__": | ||
word = "Leandro" | ||
permutations = generate_permutations(word) | ||
for permutation in permutations: | ||
print(permutation) |