모범 답안
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class Solution {
fun solution(assets: Array<String>): Array<String> =
assets.mapNotNull { asset -> runCatching { asset.toAssetResult() }.getOrNull() }
.sorted()
.filter(Asset::isValid)
.map(Asset::text)
.distinct()
.toTypedArray()
}
object Validati : Throwable()
fun String.toAssetResult(): Asset =
when {
length != 9 -> throw Validati
slice(0..1).toIntOrNull() == null -> throw Validati
get(2) != '-' -> throw Validati
runCatching { Asset.Type.valueOf(slice(3..4)) }.isFailure -> throw Validati
slice(5..6).toIntOrNull() == null -> throw Validati
slice(7..8).toIntOrNull() == null -> throw Validati
else -> Asset(
text = this,
yy = slice(0..1).toInt(),
type = Asset.Type.valueOf(slice(3..4)),
mm = slice(5..6).toInt(),
no = slice(7..8).toInt()
)
}
data class Asset(
val text: String,
val yy: Int,
val type: Type,
val mm: Int,
val no: Int
) : Comparable<Asset> {
enum class Type {
SP, KE, MO, CO, DE
}
val isValid: Boolean
get() {
return (yy in 13..22) && (mm in 1..12) && when {
yy == 13 && mm < 4 -> false
yy == 22 && mm > 8 -> false
else -> true
} && (no in 1..99)
}
override fun compareTo(other: Asset): Int {
return when {
yy > other.yy -> 1
yy < other.yy -> -1
type.ordinal > other.type.ordinal -> 1
type.ordinal < other.type.ordinal -> -1
mm > other.mm -> 1
mm < other.mm -> -1
no > other.no -> 1
no < other.no -> -1
else -> 0
}
}
}
모범답안 맞지?
지피티는 지적도 안하는데
뭔 씨발 지피티 넣고 해석하니 뭐니 이러냐
내가 씨발 궁금해서 넣어보고 왔다
지피티는 지적도 안하는구만
뭔 씨발 지적했다고 지피티라 카면 뭐라해야할지도 모르겄네 그냥
저거 4o 모델이제? ㅋㅋㅋㅋㅋㅋ
ㅇㅇ
4o 모델들이 답변할때 글에 이모티콘 넣더라고
@루도그담당(118.235) 그치