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
def angle_of(sector) | |
div, mod = sector.divmod(100) | |
angle = { 1 => 360 / 8r, 2 => 360 / 16r, 3 => 360 / 24r, 4 => 360 / 32r }[div] | |
base = angle / 2 | |
if mod.zero? | |
[base, base + (div * 8 - 1) * angle] | |
else | |
[base + angle * mod, base + angle * (mod - 1)] | |
end | |
end |
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
var _ = require('underscore'); | |
function sum(ary) { | |
'use strict'; | |
return _.reduce(ary, function(acc, e) { | |
return _.isEmpty(e) ? acc + 0 : e === 'x' ? acc + 1 : acc + parseInt(e, 10); | |
}, 0); | |
} | |
function chooseCash(cash) { |
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
exports.solve = function(src) { | |
'use strict'; | |
var radix = [], | |
n = parseInt(src, 10); | |
for(var i = 2; i < n; ++i) { | |
if( isPalindrome( makeRadixArray(n, i) ) ) { | |
radix.push(i); | |
} | |
} | |
return radix.length === 0 ? '-' : radix.join(); |
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
var _ = require("./node_modules/underscore"); | |
exports.solve = function(src) { | |
'use strict'; | |
var first = [], | |
second = [], | |
curPlayer = [], | |
n = 0, | |
result = ''; | |
for(var i = 0; i < src.length; ++i) { |
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
def count_lines(board) | |
borders = [] | |
board.each do |e| | |
a = [false] * 5 | |
a.size.times do |i| | |
a[i] = true if e[i] != e[i + 1] | |
end | |
borders << a | |
end |
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
object Lcov { | |
object Point extends Enumeration { | |
type Point = Value | |
val LeftTop, LeftBottom, RightTop, RightBottom = Value | |
} | |
import Point._ | |
private val conditions = Map( | |
LeftTop -> List(lte _, lte _, lte _), LeftBottom -> List(lte _, lte _, gte _), |
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
// An answer of http://nabetani.sakura.ne.jp/hena/ord14linedung/ | |
import scala.io._ | |
object Monster | |
{ | |
def isLessThan(c1:Char, c2:Char) = c1.toString.toUpperCase < c2.toString.toUpperCase | |
def solve(src:String) = { | |
var s = src.sortWith((x, y) => isLessThan(x, y)) |
NewerOlder