Skip to content

Commit

Permalink
Merge pull request #6311 from franmu94/main
Browse files Browse the repository at this point in the history
Reto #16 - Swift
  • Loading branch information
Roswell468 authored Feb 4, 2024
2 parents 60968a5 + 224b29b commit 91a58ea
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Retos/Reto #16 - LA ESCALERA [Media]/swift/franmu94.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Foundation

func escalera(escalones e: Int) {
if e == 0 {
print("__")
return
}
let n = abs(e)
let c = e > 0 ? "_|" : "|_"
var arr = [String]()
var espacios = ""
for i in (0...n){
if i == n && e > 0 {
arr.append(espacios + "_")
} else if i == 0 && e < 0 {
arr.append(espacios + "_")
espacios += " "
} else {
arr.append(espacios + c)
espacios += " "
}
}

e > 0 ? arr.reversed().forEach{ print($0) } : arr.forEach{ print($0) }
}
escalera(escalones: -4)
escalera(escalones: 9)
escalera(escalones: 0)


0 comments on commit 91a58ea

Please sign in to comment.