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
# 数学的な処理をまとめた名前空間 | |
class MathEx | |
# 1からnの階乗を行う | |
def self.fact(n) | |
(1..n).inject(:*) | |
end | |
# nPrを計算する | |
def self.p(n, r) |
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
sayHelloworld = function(){ | |
alert("HelloWorld"); | |
} | |
sayHelloWorld(); |
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
# Here your code ! | |
module FibSupport | |
def idx2fib(idx, a=1, b=0) | |
idx == 1 ? a : idx2fib(idx-1,a+b,a) | |
end | |
end |
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
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
permutation = function(ary){ | |
var len = ary.length; | |
var perms = [ary]; | |
for (var startIdx = 0; startIdx <= len-2; startIdx++){ | |
var tempPerms = []; |
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
eratosthenes = function(max){ | |
var nums = []; | |
var primes = []; | |
for(var i = 2; i <= max; i++){ | |
nums.push(i); | |
} | |
var sqrt = Math.sqrt(max); |
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
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
// Here your code ! | |
integer2array = function(int){ | |
var ary = []; | |
while(int !== 0){ | |
ary.push(int % 10); |
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
<div id = "popup">ここを押せば再生が始まります</div> | |
<div id = "player" style = "display: none"></div> | |
<script src = "https://www.youtube.com/iframe_api"></script> | |
<script> | |
var player; | |
var onYouTubeIframeAPIReady = function(){ | |
player = new YT.Player("player",{videoId: "dFf4AgBNR1E"}); | |
} |
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
// 引数のうち、strにはPOSTしたい文字列を入れてください。 | |
function httpPost(url,str){ | |
xhr = new XMLHttpRequest(); | |
xhr.open( "POST", url, false ); | |
xhr.send(str); | |
return xhr.responseText; | |
} |
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
var urls = ["url1","url2","url3"] | |
var strs = ["one", "two","three"] | |
var ul = document.getElementById("ul"); // <ul></ul> | |
for (var i = 0; i <= 2; i++){ | |
var a = document.createElement("a"); // <a></a> | |
a.href = urls[i] // <a href = urls[i]></a> | |
a.target = "blank"; // <a href = urls[i] target = "blank"></a> | |
a.innerHTML = strs[i]; // <a href = urls[i] target = "blank">strs[i]</a> |
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
require "net/http" | |
require "json" | |
def httpPost(url,data) | |
uri = URI.parse(url) | |
http = Net::HTTP.start(uri.host) | |
return http.post(uri.path,data).body | |
end | |
json = { |
OlderNewer