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
// 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)) |
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
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 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 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 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 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 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 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 toInt(src) { | |
return parseInt(src, 10); | |
} | |
function getSchedules(src) { | |
var schedules = {}; | |
_.each(src.split(','), function(e) { | |
if( _.isUndefined(schedules[e[0]]) ) { |
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
import scala.collection.mutable._ | |
object Problem | |
{ | |
private def format(m: Map[String, Array[Int]]): String = { | |
val keys = m.keys.toArray.sorted | |
( for(key <- keys) yield key + "_" + m.get(key).get.sorted.mkString(":") ).mkString("|") | |
} | |
private def solve(a: Array[String], m: Map[String, Array[Int]]): String = { |
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
#include <iostream> | |
#include <string> | |
#include <queue> | |
#include <vector> | |
#include <map> | |
#include <algorithm> | |
using namespace std; | |
typedef vector<vector<char>> field_t; |
OlderNewer