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#5605 from jduque1989/main
Reto#28 mouredev#29 mouredev#30 mouredev#32 - jduque1989 - Python
- Loading branch information
Showing
4 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
Retos/Reto #28 - EXPRESIÓN MATEMÁTICA [Media]/python/jduque1989.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,36 @@ | ||
numbers = str(list(range(0, 10))) | ||
operations = ["+", "-", "*", "/"] | ||
|
||
# Function to evaluate the expression in operations | ||
|
||
|
||
def math_expression(digit): | ||
if digit in operations: | ||
return True | ||
else: | ||
return False | ||
|
||
# Function to evaluate the expression in numbers | ||
|
||
|
||
def number_expression(digit): | ||
if digit in numbers: | ||
return True | ||
else: | ||
return False | ||
|
||
|
||
def evaluate(expression): | ||
number_expression(expression[0]) | ||
|
||
for i in expression: | ||
if math_expression(i) or number_expression(i) or i == " ": | ||
continue | ||
else: | ||
return False | ||
return True | ||
|
||
|
||
expresion1 = "5 + a / 7 - 4" | ||
|
||
print(f"La expresion {expresion1} es: {evaluate(expresion1)}") |
31 changes: 31 additions & 0 deletions
31
Retos/Reto #29 - EL CARÁCTER INFILTRADO [Fácil]/python/jduque1989.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,31 @@ | ||
|
||
|
||
def comparar_cadenas(cadena1, cadena2): | ||
if len(cadena1) == len(cadena2): | ||
print("Las cadenas tienen la misma longitud") | ||
return True | ||
else: | ||
print("Las cadenas tienen diferentes longitudes") | ||
return False | ||
|
||
|
||
def comparar_caracteres(cadena1, cadena2): | ||
ch = [] | ||
for index, letter in enumerate(cadena2): | ||
if letter != cadena1[index]: | ||
ch.append(letter) | ||
return ch | ||
|
||
# Test 1 | ||
|
||
# cadena1 = "Me llamo Juan Duque" | ||
# cadena2 = "Me llame Juan Doque" | ||
|
||
|
||
# Test 2 | ||
cadena1 = "Me llamo.Brais Moure" | ||
cadena2 = "Me llamo brais moure" | ||
|
||
comparar_cadenas(cadena1, cadena2) | ||
diferentes_caracteres = comparar_caracteres(cadena1, cadena2) | ||
print(f"Las cadenas no tienen los mismos caracteres {diferentes_caracteres}") |
34 changes: 34 additions & 0 deletions
34
Retos/Reto #30 - EL TECLADO T9 [Media]/python/jduque1989.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,34 @@ | ||
# T9 dictionary | ||
|
||
t9_mapping = { | ||
1: ['.', ','], | ||
2: ['A', 'B', 'C'], | ||
3: ['D', 'E', 'F'], | ||
4: ['G', 'H', 'I'], | ||
5: ['J', 'K', 'L'], | ||
6: ['M', 'N', 'O'], | ||
7: ['P', 'Q', 'R', 'S'], | ||
8: ['T', 'U', 'V'], | ||
9: ['W', 'X', 'Y', 'Z'], | ||
0: [' '], | ||
'*': ['+', '-', '*', '/'], | ||
'#': ['?', '!', '@'] | ||
} | ||
|
||
|
||
def t9_to_letters(t9_number): | ||
length = len(t9_number) - 1 | ||
index = int(t9_number[0]) | ||
letter = t9_mapping[index][length] | ||
return letter | ||
|
||
|
||
Entrada = "6-666-88-777-33-3-33-888" # 666-666-88-777-33-3-33-888 | ||
letters = Entrada.split("-") | ||
t9_to_letters(letters[0]) | ||
|
||
word = [] | ||
for i in letters: | ||
word.append(t9_to_letters(i)) | ||
|
||
print(''.join(word)) |
32 changes: 32 additions & 0 deletions
32
Retos/Reto #32 - LA COLUMNA DE EXCEL [Media]/python/jduque1989.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,32 @@ | ||
# Transform letters to numbers for example A=1 and Z=26 | ||
|
||
# get AA = 27 | ||
|
||
def is_valid_column(column): | ||
"""Check if the input is a valid column string.""" | ||
return column.isalpha() | ||
|
||
|
||
def ask_column(): | ||
column = input("Enter a column: ").upper().strip() | ||
while not is_valid_column(column): | ||
column = input("Enter a valid column: ").upper().strip() | ||
return len(column), column | ||
|
||
|
||
def letter_to_number(ch): | ||
return ord(ch) - ord('A') + 1 | ||
|
||
|
||
size, ch = ask_column() | ||
|
||
|
||
suma = 0 | ||
for index, letter in enumerate(ch): | ||
number = letter_to_number(letter) | ||
number = number * (26 ** (size - index - 1)) | ||
print(number) | ||
suma += number | ||
# print(suma) | ||
|
||
print(f"{ch} = {suma}") |