티스토리 뷰
https://programmers.co.kr/learn/courses/30/lessons/42840
import Foundation
func solution(_ answers:[Int]) -> [Int] {
let one = [1,2,3,4,5]
let two = [2,1,2,3,2,4,2,5]
let three = [3,3,1,1,2,2,4,4,5,5]
var result = [Int: Int]()
result[1] = markingTest(answers: answers, choice: one)
result[2] = markingTest(answers: answers, choice: two)
result[3] = markingTest(answers: answers, choice: three)
let maxScore = result.values.max()
return result.filter { $0.value == maxScore }.keys.sorted()
}
func markingTest(answers: [Int], choice: [Int]) -> Int {
var count = 0
let size = choice.count
for (index, answer) in answers.enumerated() {
if answer == choice[index%size] {
count = count + 1
}
}
return count
}
'프로그래머스' 카테고리의 다른 글
[프로그래머스] 스위프트 오픈채팅방 (0) | 2021.12.26 |
---|---|
[프로그래머스] 스위프트 네트워크 (0) | 2021.10.30 |
[프로그래머스] 스위프트 N으로 표현 (0) | 2021.10.30 |
[프로그래머스] 스위프트 실패율 (0) | 2021.09.21 |
[프로그래머스] 스위프트 음양 더하기 (0) | 2021.09.21 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 네트워크 유량
- CompositionalLayout
- 코딩대회
- WWDC17
- 최단경로문제
- Testable
- HIG
- WWDC19
- 최대 매칭
- rxswift
- 포드 풀커슨 알고리즘
- WWDC21
- test coverage
- 부스트캠프 6기
- MeTal
- State Restoration
- 벨만포드 시간복잡도
- 강한 순환 참조
- CPU와 Memory
- mach-o
- observeOn
- 최단경로 알고리즘
- 에드몬드 카프 알고리즘
- 컴퓨터 추상화
- 벨만포드 알고리즘
- 네트워크 플로우
- WWDC16
- 최단경로 문제
- 다익스트라 시간복잡도
- IOS
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함