ํฐ์คํ ๋ฆฌ ๋ทฐ
๐๐๐๐๐๐/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
๊ณต์ง์ฌํญ
์ต๊ทผ์ ์ฌ๋ผ์จ ๊ธ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
- Total
- Today
- Yesterday
๋งํฌ
TAG
- Cannot create an instance
- Effective Kotlin
- How to import android AAR file
- decomplie
- import aar
- DexArchiveBuilderException
- Hilt
- android launch mode in manifest
- android
- android databinding
- AAR
- databinding onclick not working
- Kotlin
- custom getter
- GitHub
- custom setter
- android aar
- com.android.build.api.transform.TransformException
- Make onClick event in Android databinding
- module-info is missing a super type
- launchemode
- databinding onClick
- annotaion
- android aar library
- Please use a personal access token instead
- viewmodel
- aar import
- The requested URL returned error
- AndroidManifest
- Support for password authentication was removed on August 13
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 | 31 |
๊ธ ๋ณด๊ดํจ