Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- Redux
- Template literals
- BOJ
- firebase
- es11
- HTML #CSS
- Python
- es6
- 카카오맵
- JavaScript
- spread operation
- optional chanining
- react
- Python #CodeUp
- React #Hooks
- CSS
- Default parameter
- 카카오맵 api
- Next
- 프로그래머스
- css #html
- HTML
- Python #Baekjoon
- Hooks
- Nullish Coalescing Operator
- React Kakao map
- nextjs
Archives
- Today
- Total
거북이개발자
[프로그래머스] 내적, 로또의 최고순위와 최저순위 본문
0. 제목
- 프로그래머스 내적
- 프로그래머스 로또의 최고순위와 최저순위
1. 문제
https://programmers.co.kr/learn/courses/30/lessons/70128
코딩테스트 연습 - 내적
길이가 같은 두 1차원 정수 배열 a, b가 매개변수로 주어집니다. a와 b의 내적을 return 하도록 solution 함수를 완성해주세요. 이때, a와 b의 내적은 a[0]*b[0] + a[1]*b[1] + ... + a[n-1]*b[n-1] 입니다. (n은 a, b의
programmers.co.kr
https://programmers.co.kr/learn/courses/30/lessons/77484
코딩테스트 연습 - 로또의 최고 순위와 최저 순위
로또 6/45(이하 '로또'로 표기)는 1부터 45까지의 숫자 중 6개를 찍어서 맞히는 대표적인 복권입니다. 아래는 로또의 순위를 정하는 방식입니다. 1 순위 당첨 내용 1 6개 번호가 모두 일치 2 5개 번호
programmers.co.kr
2. 풀이
3. 코드
(1). 내적
def solution(a, b):
answer=0
for i in range(0, len(a)):
answer+=a[i]*b[i]
return answer
(2). 로또의 최저 순위와 최고 순위
def solution(lottos, win_nums):
max_num=0
min_num=0
zero_num=0
cor_num=0
answer = []
for i in lottos:
if i==0:
zero_num+=1
for j in lottos:
if j in win_nums:
cor_num+=1
max_num=cor_num+zero_num
min_num=cor_num
if(max_num!=0):
max_rank=7-max_num
else:
max_rank=6
if(min_num!=0):
min_rank=7-min_num
else:
min_rank=6
answer.append(max_rank)
answer.append(min_rank)
return answer
'Algorithm(Python) > programmers(Lv.1)' 카테고리의 다른 글
[프로그래머스] 모의고사 (0) | 2021.06.23 |
---|---|
[프로그래머스] K번째수 (0) | 2021.06.23 |
[프로그래머스] 음양 더하기 (0) | 2021.06.21 |
[프로그래머스] 체육복 (0) | 2021.06.21 |
[프로그래머스] 완주하지 못한 선수 (0) | 2021.06.21 |
Comments