-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
https://school.programmers.co.kr/learn/courses/30/lessons/81301
import Foundation
func solution(_ n:Int, _ arr1:[Int], _ arr2:[Int]) -> [String] {
var answer: [String] = []
for i in 0..<n {
var first = String(arr1[i], radix: 2)
var second = String(arr2[i], radix: 2)
if first.count < n {
let max = n - first.count
for _ in 0..<max {
first = "0" + first
}
}
if second.count < n {
let max = n - second.count
for _ in 0..<max {
second = "0" + second
}
}
var row = ""
for j in 0..<n {
if first[first.index(first.startIndex, offsetBy: j)] == "1" || second[second.index(second.startIndex, offsetBy: j)] == "1" {
row += "#"
} else {
row += " "
}
}
answer.append(row)
}
return answer
}