forked from mouredev/retos-programacion-2023
-
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.
Merge pull request mouredev#6039 from pakiuh/main
Reto mouredev#47 -C#
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [Fácil]/c#/pakiuh.cs
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,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
class Program | ||
{ | ||
static void Main() | ||
{ | ||
var valores = new Dictionary<char, int>(); | ||
for (int i = 0; i < 14; i++) | ||
{ | ||
valores.Add((char)(i + 'A'), i + 1); | ||
} | ||
valores.Add('Ñ', 15); | ||
for (int i = 14; i < 26; i++) | ||
{ | ||
valores.Add((char)(i + 'A'), i + 2); | ||
} | ||
|
||
int puntos = 0; | ||
|
||
while (puntos != 100) | ||
{ | ||
Console.Write("Introduce una palabra: "); | ||
string palabra = Console.ReadLine().ToUpper(); | ||
puntos = 0; | ||
foreach (char letra in palabra) | ||
{ | ||
if (valores.ContainsKey(letra)) | ||
{ | ||
puntos += valores[letra]; | ||
//Console.WriteLine($"El valor de la letra {letra} es: {valores[letra]}"); | ||
} | ||
} | ||
Console.WriteLine("La valoración de la palabra es: " + puntos); | ||
} | ||
|
||
Console.WriteLine("¡Has alcanzado los 100 puntos!"); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Retos/Reto #47 - LA PALABRA DE 100 PUNTOS [Fácil]/python/pakiuh.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,17 @@ | ||
valores = {chr(i + 65): i + 1 for i in range(14)} | ||
valores['Ñ'] = 15 | ||
valores.update({chr(i + 65): i + 2 for i in range(14, 26)}) | ||
|
||
puntos = 0 | ||
|
||
while puntos != 100: | ||
palabra = input("Introduce una palabra: ").upper() | ||
puntos = 0 | ||
|
||
for letra in palabra: | ||
if letra in valores: | ||
puntos += valores[letra] | ||
#print(f"El valor de la letra {letra} es: {valores[letra]}") | ||
print("La valoración de la palabra es:", puntos) | ||
|
||
print("¡Has alcanzado los 100 puntos!") |