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.
- Loading branch information
1 parent
3534604
commit e2e63c8
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
Retos/Reto #29 - EL CARÁCTER INFILTRADO [Fácil]/vbscript/arielposada.vbs
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,42 @@ | ||
' Ejemplo de uso: | ||
' cscript arielposada.vbs | ||
' Crea una función que reciba dos cadenas de texto casi iguales, | ||
' a excepción de uno o varios caracteres. | ||
' La función debe encontrarlos y retornarlos en formato lista/array. | ||
' - Ambas cadenas de texto deben ser iguales en longitud. | ||
' - Las cadenas de texto son iguales elemento a elemento. | ||
' - No se pueden utilizar operaciones propias del lenguaje | ||
' que lo resuelvan directamente. | ||
' | ||
' Ejemplos: | ||
' - Me llamo mouredev / Me llemo mouredov -> ["e", "o"] | ||
' - Me llamo.Brais Moure / Me llamo brais moure -> [" ", "b", "m"] | ||
Option Explicit | ||
|
||
Dim str1, str2, result | ||
|
||
str1 = "Me llamo mouredev" | ||
str2 = "Me llemo mouredov" | ||
result = FindDifferences(str1, str2) | ||
WScript.Echo "Diferencias: " & Join(result, ", ") | ||
|
||
str1 = "Me llamo.Brais Moure" | ||
str2 = "Me llamo brais moure" | ||
result = FindDifferences(str1, str2) | ||
WScript.Echo "Diferencias: " & Join(result, ", ") | ||
|
||
Function FindDifferences(str1, str2) | ||
Dim i, differences() | ||
Dim count | ||
|
||
count = 0 | ||
For i = 1 To Len(str1) | ||
If Mid(str1, i, 1) <> Mid(str2, i, 1) Then | ||
ReDim Preserve differences(count) | ||
differences(count) = Mid(str2, i, 1) | ||
count = count + 1 | ||
End If | ||
Next | ||
|
||
FindDifferences = differences | ||
End Function |