Created
November 5, 2014 17:49
-
-
Save shizone/7a0cac308dac062dab6c to your computer and use it in GitHub Desktop.
gbdaitokai2014winter order
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random | |
val s = List( | |
"Koutarou Ishizaki", | |
"ryosms", | |
"Takafumi Yoshida", | |
"英吉", | |
"Katsuhiro Masaki", | |
"山本裕介", | |
"Tomohiko Himura", | |
"Ryuji IWATA" | |
) | |
val l = List( | |
"もじゃ変", | |
"あべさんはアップを始めています", | |
"きよくらならみ" | |
) | |
val r = new Random | |
val order = (l: List[String]) => (l.sortWith((_, _) => r.nextInt(2) == 1).zipWithIndex.map(s => (s._2 + 1, s._1))) | |
println("Short:") | |
println(order(s)) | |
println("Long:") | |
println(order(l)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Short:
List((1,Ryuji IWATA), (2,Takafumi Yoshida), (3,Katsuhiro Masaki), (4,ryosms), (5,山本裕介), (6,英吉), (7,Koutarou Ishizaki), (8,Tomohiko Himura))
Long:
List((1,きよくらならみ), (2,あべさんはアップを始めています), (3,もじゃ変))