-
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 branch 'mouredev:main' into main
- Loading branch information
Showing
3 changed files
with
75 additions
and
2 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
54 changes: 54 additions & 0 deletions
54
Retos/Reto #13 - ADIVINA LA PALABRA [Media]/python/mouredev.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,54 @@ | ||
import random | ||
|
||
words = ["mouredev", "casa"] | ||
word = random.choice(words) | ||
hidden_letters = int(len(word) * 0.6) | ||
hidden_positions = random.sample(range(len(word)), hidden_letters) | ||
|
||
hidden_word = "" | ||
for index, letter in enumerate(word): | ||
hidden_word += "_" if index in hidden_positions else letter | ||
|
||
attempts = 5 | ||
|
||
while attempts > 0: | ||
|
||
print(f"Adivina la palabra: {hidden_word}\nTienes {attempts} intentos.") | ||
|
||
text = input("Introduce una letra o la solución completa: ") | ||
|
||
if len(text) == 1: | ||
|
||
new_hidden_word = "" | ||
success = False | ||
for index, letter in enumerate(word): | ||
if text == letter and hidden_word[index] == "_": | ||
new_hidden_word += text | ||
success = True | ||
else: | ||
new_hidden_word += hidden_word[index] | ||
|
||
hidden_word = new_hidden_word | ||
|
||
if success: | ||
if word == hidden_word: | ||
print(f"¡Has acertado! La palabra oculta era {word}.") | ||
break | ||
else: | ||
print("¡Has acertado la letra!") | ||
else: | ||
print("Letra no encontrada o ya visible.") | ||
attempts -= 1 | ||
|
||
elif len(text) == len(word): | ||
if text == word: | ||
print(f"¡Has acertado! La palabra oculta era {word}.") | ||
break | ||
else: | ||
print("La palabra no es correcta.") | ||
attempts -= 1 | ||
else: | ||
print("Texto inválido.") | ||
|
||
if attempts == 0: | ||
print(f"Has perdido. La palabra oculta era {word}.") |
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,18 @@ | ||
# Reto #14: Octal y Hexadecimal | ||
#### Dificultad: Fácil | Publicación: 03/04/23 | Corrección: 10/04/23 | ||
|
||
## Enunciado | ||
|
||
``` | ||
/* | ||
* Crea una función que reciba un número decimal y lo trasforme a Octal | ||
* y Hexadecimal. | ||
* - No está permitido usar funciones propias del lenguaje de programación que | ||
* realicen esas operaciones directamente. | ||
*/ | ||
``` | ||
#### Tienes toda la información extendida sobre los retos de programación semanales en **[retosdeprogramacion.com/semanales2023](https://retosdeprogramacion.com/semanales2023)**. | ||
|
||
Sigue las **[instrucciones](../../README.md)**, consulta las correcciones y aporta la tuya propia utilizando el lenguaje de programación que quieras. | ||
|
||
> Recuerda que cada semana se publica un nuevo ejercicio y se corrige el de la semana anterior en directo desde **[Twitch](https://twitch.tv/mouredev)**. Tienes el horario en la sección "eventos" del servidor de **[Discord](https://discord.gg/mouredev)**. |