Skip to content

Instantly share code, notes, and snippets.

@yuizho
Created June 2, 2019 14:17
Show Gist options
  • Save yuizho/cd614054a1fff71085148c50e74a18da to your computer and use it in GitHub Desktop.
Save yuizho/cd614054a1fff71085148c50e74a18da to your computer and use it in GitHub Desktop.
// ------------- 入力受ける系
// 数値
val N = readLine()?.toInt() ?: 0
// スペース区切り
val steps = readLine()!!.split(" ").map(String::toInt)
// 連続受け取り kotlin 1.3〜
val inputs = List(N) { readLine()!!.split(" ").map(String::toInt) }
// 連続受け取り kotlin ~1.0
val list: ArrayList<List<Int>> = arrayListOf()
for (n in 0 until N) {
list.add(readLine()!!.split(" ").map(String::toInt))
}
// ------------- リスト操作
// 結合
listOf(1) + listOf(2, 3) // [1, 2, 3]
// 先頭n桁スライス
listOf(1, 2, 3, 4).drop(2) // [3, 4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment