황찌옹
정리왕옹옹
황찌옹
GitHub Contribution
Loading data ...
  • 분류 전체보기 (158)
    • [ 알고리즘 ] (96)
      • Implementation (24)
      • Brute Force (6)
      • String (4)
      • Greedy (14)
      • DFS, BFS (13)
      • Back Tracking (4)
      • Sort & Binary Search (6)
      • DP (8)
      • Shortest Path (5)
      • Hash (3)
      • Stack, Queue (4)
      • Heap (1)
      • Tree (1)
      • Mathematics (1)
      • Ad-Hoc (1)
      • 기타 (COS Pro, etc) (1)
    • [ 언어 및 문법 ] (23)
      • Python (5)
      • C, C++ (13)
      • SQL (1)
      • 공통 개념(CS) (4)
    • [ Error ] (21)
      • Radiomics Feature Extraction (6)
      • CT Skin Segmentation (12)
      • etc (3)
    • [ Git ] (7)
    • [ 환경 설정 및 기타] (6)
    • [ 공부 ] (2)
      • AI, ML (0)
      • Computer Vision (0)
      • Image Processing (1)
      • QT (0)
      • AWS (1)
      • 의료 (0)
    • [ 포트폴리오 ] (1)
      • 🙋‍♀️자기 소개🙋‍♀️ (1)
      • 프로젝트 (0)
      • 공모전 (0)
      • 자격증 (0)
      • 대내외활동 (0)
      • 논문 (0)
      • 교육 봉사 (0)
    • [ 취준 ] (2)
      • 채용 설명회, 직무 상담 (1)
      • 취준 후기 (1)

블로그 메뉴

  • ❤️깃허브❤️

인기 글

태그

  • Cloud
  • pyplot
  • cs
  • configuration
  • 씹어먹는C++
  • SQL
  • numpy
  • keras
  • OpenCV
  • Anaconda
  • Visual Studio
  • tensorflow
  • git
  • cos pro
  • c++
  • config
  • 모두의코드
  • Python
  • QT
  • aws

최근 댓글

최근 글

전체 방문자
오늘
어제
hELLO · Designed By 정상우.
황찌옹

정리왕옹옹

[ 알고리즘 ]/Brute Force

[프로그래머스] 모의고사

2022. 6. 29. 19:04

 

📌문제

https://programmers.co.kr/learn/courses/30/lessons/42840

 

🎖️난이도

Level 1

 

✔️풀이

# sol1
def solution(answers):
    one = [1,2,3,4,5] * 2000
    two = [2,1,2,3,2,4,2,5] * 1250
    three = [3,3,1,1,2,2,4,4,5,5] * 1000
    
    scores = [0, 0, 0]
    l = len(answers)
    
    for i in range(l):
        if answers[i] == one[i]:
            scores[0] += 1
        if answers[i] == two[i]:
            scores[1] += 1
        if answers[i] == three[i]:
            scores[2] += 1
        
    tmp_max = max(scores)
    persons = [i+1 for i in range(3) if scores[i] == tmp_max]
    
    return persons

 

# sol2) pattern & %(나머지) 연산자 사용
def solution(answers):
    pattern1 = [1,2,3,4,5]
    pattern2 = [2,1,2,3,2,4,2,5]
    pattern3 = [3,3,1,1,2,2,4,4,5,5]
    score = [0, 0, 0]
    result = []

    for idx, answer in enumerate(answers):
        if answer == pattern1[idx%len(pattern1)]:
            score[0] += 1
        if answer == pattern2[idx%len(pattern2)]:
            score[1] += 1
        if answer == pattern3[idx%len(pattern3)]:
            score[2] += 1

    for idx, s in enumerate(score):
        if s == max(score):
            result.append(idx+1)

    return result

'[ 알고리즘 ] > Brute Force' 카테고리의 다른 글

[백준] 1759. 암호 만들기  (0) 2022.07.02
[프로그래머스] 두 개 뽑아서 더하기  (0) 2022.07.02
[프로그래머스] 카펫  (0) 2022.06.29
[프로그래머스] 소수 찾기  (0) 2022.06.29
[백준] 11504. 돌려 돌려 돌림판!  (0) 2022.06.29
    황찌옹
    황찌옹
    다 정리해버리꺼야

    티스토리툴바