ํฐ์คํ ๋ฆฌ ๋ทฐ
๐๐๐๐๐๐/Algorithm
[Hacker Rank] Cats and a Mouse (Kotlin)
pyorolong 2022. 8. 1. 20:40๋ฌธ์ ํ์
- 1๊ฐ์ ์ง์ ์ขํ ์์ ๊ณ ์์ด 2๋ง๋ฆฌ, ์ฅ 1๋ง๋ฆฌ๊ฐ ์์น
- Cat A, Cat B ์ค Mouse์ ๋ ๊ฐ๊น์ด ์์น์ ์๋ ๊ณ ์์ด๋ฅผ Print ํ์
๊ธฐํ ์กฐ๊ฑด
- Cat A, Cat B ์ Mouse์ ๊ฑฐ๋ฆฌ๊ฐ ๋ชจ๋ ๋์ผํ ๊ฒฝ์ฐ Mouse๋ฅผ Print ํ์
ํ์ด- Kotlin
fun catAndMouse(x: Int, y: Int, z: Int): String {
val a = Math.abs(x - z)
val b = Math.abs(y - z)
return if (a < b) {
"Cat A"
} else if (a > b) {
"Cat B"
} else {
"Mouse"
}
}
๋์ณค๋ ๋ถ๋ถ
์ฒ์์ ๊ธํ๊ฒ ๋ ผ๋ฆฌ๋ง ์ธ์๋ ์ฑ๋ก ์งํํ์ ๋ Fail์ด ๋์ ์ค๋งํ๋ค.
๋ค์ ์ฐฌ์ฐฌํ๊ฒ ์ดํด๋ณด๋ ๊ฐ ๊ณ ์์ด๋ค๊ณผ ์ฅ์ ๊ฑฐ๋ฆฌ๋ ์ ๋๊ฐ์ผ๋ก ๋น๊ตํด์ผ ํ๋ฏ๋ก ์ ๋๊ฐ ์ฒ๋ฆฌ๋ฅผ ํ์ง ์์๋ ๊ฒ์ด๋ค!
์ฝํ ์ค๋น ์ด์ง๋ก์... ์ด๋ฐ ์ฌ์ํ์ง๋ง ์ค์ํ ์กฐ๊ฑด์ ์์ผ๋ก ํ ๋ฒ์ ํ์ ํ ์ ์๊ฒ ์ง?
https://www.hackerrank.com/challenges/cats-and-a-mouse/problem?h_r=internal-search
Cats and a Mouse | HackerRank
Which cat will catch the mouse first?
www.hackerrank.com
๊ณต์ง์ฌํญ
์ต๊ทผ์ ์ฌ๋ผ์จ ๊ธ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
- Total
- Today
- Yesterday
๋งํฌ
TAG
- Please use a personal access token instead
- Kotlin
- android launch mode in manifest
- viewmodel
- Cannot create an instance
- Support for password authentication was removed on August 13
- databinding onClick
- aar import
- android aar library
- Make onClick event in Android databinding
- android
- annotaion
- Hilt
- com.android.build.api.transform.TransformException
- import aar
- custom setter
- decomplie
- android aar
- launchemode
- GitHub
- custom getter
- databinding onclick not working
- AAR
- How to import android AAR file
- module-info is missing a super type
- The requested URL returned error
- android databinding
- Effective Kotlin
- DexArchiveBuilderException
- AndroidManifest
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 | 29 | 30 |
๊ธ ๋ณด๊ดํจ