Created
November 29, 2014 13:07
-
-
Save terurou/ef1fc4758a56704a53f4 to your computer and use it in GitHub Desktop.
NGK2014B 発表順序抽選プログラム
This file contains 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
package ; | |
class ArrayTools { | |
public static function shuffle<T>(arr : Array<T>) : Array<T> { | |
var i = arr.length; | |
while (i > 0) { | |
var j = Std.random(i); | |
var tmp = arr[--i]; | |
arr[i] = arr[j]; | |
arr[j] = tmp; | |
} | |
return arr; | |
} | |
public static function append<T>(arr : Array<T>, x : T) : Array<T> { | |
arr.push(x); | |
return arr; | |
} | |
public static function take<T>(arr : Array<T>, count : Int) : Array<T> { | |
var ret = []; | |
for (i in 0...count) { | |
ret.push(arr.shift()); | |
} | |
return ret; | |
} | |
} |
This file contains 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
package ; | |
import js.Lib; | |
using ArrayTools; | |
class Main { | |
static function main() { | |
var speakers = [ | |
"y_tana_23", "mzp", "c0hama", "kekyo2", "maeda_", "bleis-tift", | |
"RKTM", "toyoshi", "yusuke_kokubo", "katzueno", "babydaemons", | |
"Tom_G3X", "ahiru3net", "osiire", "field_works", "sunflat", "sqm8", | |
"zetta1985", "athos", "smogami", "dabits", "nobukuma", "ZienChan", | |
"naomat1029" | |
].shuffle(); | |
trace(speakers.take(5)); | |
trace(speakers.take(5)); | |
trace(speakers.take(5)); | |
trace(speakers.append("galao_doce").shuffle().take(5)); | |
trace(speakers); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
galao_doceさんの会場到着が夕方になるため、途中でappend().shuffle()しています。