     if row == 3 {
         row = 0
         part2TriangleArray.forEach { item in
-            let sortedArray = item.sorted(by: { (s1: Int, s2:Int) -> Bool in
+            let sortedArray2 = item.sorted(by: { (s1: Int, s2:Int) -> Bool in
                 s1 < s2
             })
-            if sortedArray[0] + sortedArray[1] > sortedArray[2] {
+            if sortedArray2[0] + sortedArray2[1] > sortedArray2[2] {
                 triangleCount2 += 1
             }
         }
         part2TriangleArray = [[Int]](arrayLiteral: [],[],[])
     }
-
 }
-
+print(triangleCount)
 print(triangleCount2)
 
 

        .flatMap{
            $0
        }
        .sorted(by: { (s1: Int, s2:Int) -> Bool in
            s1 < s2
    })
    if singleItemArray[0] + singleItemArray[1] > singleItemArray[2] {
        triangleCount += 1
    }
}
print(triangleCount)

var triangleCount2 = 0
var part2TriangleArray = [[Int]](arrayLiteral: [],[],[])
var row = 0
triangles.enumerateLines { (line, _) in
    let singleItemArray = line.components(separatedBy: CharacterSet.newlines)[0].components(separatedBy: CharacterSet.whitespaces)
        .filter{
            $0 != ""
        }
        .map{ item in
            Int(item)
        }
        .flatMap{
            $0
    }
    if row < 3 {
        for i in 0...2 {
            part2TriangleArray[i].append(singleItemArray[i])

import UIKit

guard let triangles = try? String(contentsOf: #fileLiteral(resourceName: "input.txt")) else { fatalError() }

var triangleCount = 0
var triangleCount2 = 0
var part2TriangleArray = [[Int]](arrayLiteral: [],[],[])
var row = 0
triangles.enumerateLines { (line, hi) in
    var singleItemArray = line.components(separatedBy: CharacterSet.whitespaces)
        .filter{
            $0 != ""
        }
