Created
October 15, 2009 01:58
-
-
Save yosshi/210587 to your computer and use it in GitHub Desktop.
単純にいろんな言語でロト6の数字を決めてみる
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
function shuffle(list) { | |
var i = list.length; | |
while (--i) { | |
var j = Math.floor(Math.random() * (i + 1)); | |
if (i == j) continue; | |
var k = list[i]; | |
list[i] = list[j]; | |
list[j] = k; | |
} | |
return list; | |
} | |
var myArray = new Array(); | |
for(cnt=1;cnt<=43;cnt++){ | |
myArray[cnt-1] = cnt; | |
} | |
myArray = shuffle(myArray); | |
document.write(myArray.slice(0,5).join('-')); |
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
Aとは配列。 | |
Bで1から43まで繰り返す。 | |
AにBを配列追加。 | |
Aを配列シャッフル。 | |
「{A[0]}-{A[1]}-{A[2]}-{A[3]}-{A[4]}-{A[5]}-{A[6]}」を表示 |
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
# -*- coding: utf-8 -*- | |
# 01から43までの43個の数字の中から異なる6個を選択するものである | |
p (1..43).to_a.shuffle[0..5].sort.join('-') |
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
use test; | |
CREATE TABLE loto6 ( | |
loto_num int(5) NOT NULL, | |
PRIMARY KEY (loto_num) | |
); | |
INSERT INTO loto6 VALUES(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); | |
SELECT loto_num FROM loto6 ORDER BY Rand() LIMIT 6; | |
DROP TABLE loto6; |
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 flash.display.Sprite; | |
import flash.text.TextField; | |
public class Main extends Sprite | |
{ | |
public function Main() | |
{ | |
var textField:TextField = new TextField(); | |
textField.text = range(1,43).shuffle().slice(0,6).join('-'); | |
addChild(textField); | |
} | |
Array.prototype.shuffle = function():Array { | |
var i:int = this.length; | |
while (--i) { | |
var j:int = Math.floor(Math.random() * i); | |
if (i == j) continue; | |
var t:int = this[i]; | |
this[i] = this[j]; | |
this[j] = t; | |
} | |
return this; | |
}; | |
private function range(start:int, end:int):Array | |
{ | |
var list:Array = new Array(); | |
for (var i:int = start; i <= end; i++) { | |
list.push(i); | |
} | |
return list; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment