[백준] 10798번 - Swift

이창형·2023년 5월 29일
0

https://www.acmicpc.net/problem/10798
문제 링크

코드

var words = [[String]](repeating: [String](repeating: "", count: 15), count: 5)

for i in 0..<5 {
    let word = readLine()!.map { String($0) }
    let lastIndex = word.count - 1
    // (인덱스 범위 만큼, word로 바꿔준다)
    words[i].replaceSubrange(0..<lastIndex, with: word)
}

for i in 0..<15 {
    for j in 0..<5 {
        print(words[j][i], terminator: "")
    }
}

회고

  • replaceSubrange를 알게 되었습니다
  • 못 풀어서 참고했습니다
  • 브론즈1도 생각보다 까다로웠습니다..
profile
iOS Developer

0개의 댓글