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#5081 from joaquinferrero/main
Reto - mouredev#22
- Loading branch information
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
Retos/Reto #22 - LA ESPIRAL [Media]/perl/joaquinferrero.pl
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 @@ | ||
#!/usr/bin/env perl | ||
# | ||
# La espiral | ||
# | ||
# Crea una función que dibuje una espiral como la del ejemplo. | ||
# - Únicamente se indica de forma dinámica el tamaño del lado. | ||
# - Símbolos permitidos: ═ ║ ╗ ╔ ╝ ╚ | ||
# | ||
# Ejemplo: espiral de lado 5 (5 filas y 5 columnas): | ||
# ════╗ | ||
# ╔══╗║ | ||
# ║╔╗║║ | ||
# ║╚═╝║ | ||
# ╚═══╝ | ||
# | ||
# Joaquín Ferrero, 20230921 | ||
# | ||
use v5.38; | ||
|
||
sub espiral($tamano) { | ||
my $ancho = int $tamano/2+0.5; | ||
|
||
say '=' x ($tamano-1), '╗'; | ||
|
||
for my $i (1 .. $ancho-1) { | ||
say '║' x ($i-1), '╔', '=' x ($tamano - (2 * $i) - 1), '╗', '║' x $i; | ||
} | ||
|
||
for my $i ($ancho .. $tamano-1) { | ||
say '║' x ($tamano - $i-1), '╚', '=' x ((2 * $i) - $tamano), '╝', '║' x ($tamano - $i-1); | ||
} | ||
} | ||
|
||
espiral(10); | ||
|
||
__END__ |
35 changes: 35 additions & 0 deletions
35
Retos/Reto #22 - LA ESPIRAL [Media]/raku/joaquinferrero.raku
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,35 @@ | ||
#!/usr/bin/env raku | ||
#`( | ||
La espiral | ||
Crea una función que dibuje una espiral como la del ejemplo. | ||
- Únicamente se indica de forma dinámica el tamaño del lado. | ||
- Símbolos permitidos: ═ ║ ╗ ╔ ╝ ╚ | ||
Ejemplo: espiral de lado 5 (5 filas y 5 columnas): | ||
════╗ | ||
╔══╗║ | ||
║╔╗║║ | ||
║╚═╝║ | ||
╚═══╝ | ||
Joaquín Ferrero, 20230921 | ||
) | ||
use v6; | ||
|
||
sub espiral($tamano) { | ||
my $ancho = ceiling($tamano/2); | ||
|
||
say '=' x ($tamano-1), '╗'; | ||
|
||
for 1 ..^ $ancho { | ||
say '║' x ($_-1), '╔', ('=' x ($tamano - 2*$_ - 1)), '╗', ('║' x $_); | ||
} | ||
|
||
for $ancho ..^ $tamano { | ||
say '║' x ($tamano - $_-1), '╚', '=' x (2*$_ - $tamano), '╝', '║' x ($tamano - $_-1); | ||
} | ||
} | ||
|
||
espiral(10); | ||
|