Skip to content

Instantly share code, notes, and snippets.

View mizuhara's full-sized avatar

Masaya Mizuhara mizuhara

View GitHub Profile
// 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))
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 _),
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
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) {
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();
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) {
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
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]]) ) {
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 = {
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef vector<vector<char>> field_t;