Skip to content

Commit

Permalink
Merge pull request #5915 from espinoleandroo/main
Browse files Browse the repository at this point in the history
Reto #18 - java
  • Loading branch information
kontroldev authored Dec 1, 2023
2 parents c04f212 + 40f5581 commit 0498e9a
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Retos/Reto #18 - WEB SCRAPING [Difícil]/java/EspinoLeandroo.java
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();
}
}
}

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)
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 Retos/Reto #36 - PERMUTACIONES [Media]/python/EspinoLeandroo.py
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)

0 comments on commit 0498e9a

Please sign in to comment.