Skip to main content
added 593 characters in body
Source Link
Alexander
  • 501
  • 2
  • 6

Swift 2.2, 157157 142 Bytes

let t={(l:Int)in[Int](1..<l)+[Int](l.stride(to:0,by:-1))}
for x in(t(n).map{t($0).map{"\(UnicodeScalar($0+64))"}.reduce(""){$0+$1}}){print(x)}

ungolfed:

let makeTriangleArray = {(limit: Int) -> [Int] in
    return [Int](1 ..< limit) + [Int](limit.stride(to: 0, by: -1))
}

let n = 26
let lines = makeTriangleArray(n).map{
    makeTriangleArray($0).map{String(UnicodeScalar($0 + 64))}
                         .reduce(""){ $0 + $1}
}

for line in lines {
    print(line)
}

157 bytes:

let t={(l:Int)in[Int](1..<l)+[Int](l.stride(to:0,by:-1))}
print(t(n).map{t($0).map{"\(UnicodeScalar($0+64))"}.joinWithSeparator("")}.joinWithSeparator("\n"))

ungolfed:ungolfed:

let makeTriangleArray = {(limit: Int) -> [Int] in // "called t" above
    return [Int](1 ..< limit) + [Int](limit.stride(to: 0, by: -1))
}

let n = 26
let s = makeTriangleArray(n).map{
    makeTriangleArray($0).map{String(UnicodeScalar($0 + 64))}
                         .joinWithSeparator("")
}.joinWithSeparator("\n")
print(s)

Swift 2.2, 157 Bytes

let t={(l:Int)in[Int](1..<l)+[Int](l.stride(to:0,by:-1))}
print(t(n).map{t($0).map{"\(UnicodeScalar($0+64))"}.joinWithSeparator("")}.joinWithSeparator("\n"))

ungolfed:

let makeTriangleArray = {(limit: Int) -> [Int] in // "called t" above
    return [Int](1 ..< limit) + [Int](limit.stride(to: 0, by: -1))
}

let n = 26
let s = makeTriangleArray(n).map{
    makeTriangleArray($0).map{String(UnicodeScalar($0 + 64))}
                         .joinWithSeparator("")
}.joinWithSeparator("\n")
print(s)

Swift 2.2, 157 142 Bytes

let t={(l:Int)in[Int](1..<l)+[Int](l.stride(to:0,by:-1))}
for x in(t(n).map{t($0).map{"\(UnicodeScalar($0+64))"}.reduce(""){$0+$1}}){print(x)}

ungolfed:

let makeTriangleArray = {(limit: Int) -> [Int] in
    return [Int](1 ..< limit) + [Int](limit.stride(to: 0, by: -1))
}

let n = 26
let lines = makeTriangleArray(n).map{
    makeTriangleArray($0).map{String(UnicodeScalar($0 + 64))}
                         .reduce(""){ $0 + $1}
}

for line in lines {
    print(line)
}

157 bytes:

let t={(l:Int)in[Int](1..<l)+[Int](l.stride(to:0,by:-1))}
print(t(n).map{t($0).map{"\(UnicodeScalar($0+64))"}.joinWithSeparator("")}.joinWithSeparator("\n"))

ungolfed:

let makeTriangleArray = {(limit: Int) -> [Int] in // "called t" above
    return [Int](1 ..< limit) + [Int](limit.stride(to: 0, by: -1))
}

let n = 26
let s = makeTriangleArray(n).map{
    makeTriangleArray($0).map{String(UnicodeScalar($0 + 64))}
                         .joinWithSeparator("")
}.joinWithSeparator("\n")
print(s)
Source Link
Alexander
  • 501
  • 2
  • 6

Swift 2.2, 157 Bytes

let t={(l:Int)in[Int](1..<l)+[Int](l.stride(to:0,by:-1))}
print(t(n).map{t($0).map{"\(UnicodeScalar($0+64))"}.joinWithSeparator("")}.joinWithSeparator("\n"))

ungolfed:

let makeTriangleArray = {(limit: Int) -> [Int] in // "called t" above
    return [Int](1 ..< limit) + [Int](limit.stride(to: 0, by: -1))
}

let n = 26
let s = makeTriangleArray(n).map{
    makeTriangleArray($0).map{String(UnicodeScalar($0 + 64))}
                         .joinWithSeparator("")
}.joinWithSeparator("\n")
print(s)