[ํ๋ก๊ทธ๋๋จธ์ค LV.0 _ Swift] Day64 n๊ฐ ๊ฐ๊ฒฉ์ ์์๋ค
๐ ๋ฌธ์ ๋งํฌ : https://school.programmers.co.kr/learn/courses/30/lessons/181888
import Foundation
func solution(_ num_list:[Int], _ n:Int) -> [Int] {
var result: [Int] = []
for i in 0..<num_list.count {
if i % n == 0 {
result.append(num_list[i])
}
}
return result
}
stride๋ฅผ ์ฌ์ฉํด์ ์ธ๋ฑ์ค๋ฅผ ๋ฝ์๋ด๊ณ map์ ์ฌ์ฉํด์ ํด๋น ์ธ๋ฑ์ค์ ๊ฐ์ map์ผ๋ก ๊ตฌํด์ค๋ค.
stride๋ฅผ ์์ผ๋ก๋ ์์ฃผ ์ฌ์ฉํด๋ณผ ๊ฒ!