Skip to content

Instantly share code, notes, and snippets.

@shizone
Created November 5, 2014 17:49
Show Gist options
  • Save shizone/7a0cac308dac062dab6c to your computer and use it in GitHub Desktop.
Save shizone/7a0cac308dac062dab6c to your computer and use it in GitHub Desktop.
gbdaitokai2014winter order
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))
@shizone
Copy link
Author

shizone commented Nov 5, 2014

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,もじゃ変))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment