Skip to content

[week1] 등차수열의 특정한 항만 더하기#6

Open
sonyerim wants to merge 1 commit intoSOPT-all:mainfrom
sonyerim:week1/yerim-son
Open

[week1] 등차수열의 특정한 항만 더하기#6
sonyerim wants to merge 1 commit intoSOPT-all:mainfrom
sonyerim:week1/yerim-son

Conversation

@sonyerim
Copy link

문제 포인트

  • 조건문
  • 반복문

풀이 포인트

  • 문제 자체는 어렵지 않지만, 원래 파이썬으로 풀었어서 코틀린 문법에 익숙해지는 중입니다.

Copy link

@ShinHyeongcheol ShinHyeongcheol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이번주 알콩달콩 수고하셨습니다!!

fun solution(a: Int, d: Int, included: BooleanArray): Int {
var answer: Int = 0

for (i in 0 until included.size) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

included의 bool값을 x라고 하고, 인덱스는 그대로 index라고 할게요.
이때 반복문을 저는 for((index, x) in included.withIndex()) 형태로 인덱스와 리스트의 값이 모두 필요할때 사용하는데 좋더라구요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants