Skip to content

Instantly share code, notes, and snippets.

@mattsan
mattsan / file0.cpp
Created July 6, 2014 11:03
第23回オフラインリアルタイムどう書く を C++ で解く ref: http://qiita.com/emattsan/items/d51095f9f5285ec84ce1
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
struct Cell
{
int value;
int length;
@mattsan
mattsan / file0.cpp
Created July 8, 2014 13:00
第23回オフラインリアルタイムどう書く を C++のテンプレート で解く ref: http://qiita.com/emattsan/items/cc82b19bf38b3f64f761
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
int get_length(const std::string& values, int pos, int lengths[])
{
if(std::isdigit(values[pos]) && (lengths[pos] == 0))
{
int l[] =
@mattsan
mattsan / das28.rb
Last active August 29, 2015 14:07
DAS28の算出法
def das28_crp(tjc, sjc, crp, pga)
# pga は 0〜100 を期待している
0.56 * Math.sqrt(tjc) + 0.28 * Math.sqrt(sjc) + 0.36 * Math.log(crp * 10 + 1) + 0.014 * pga + 0.96
end
def das28_esr(tjc, sjc, esr, pga)
# pga は 0〜100 を期待している
0.56 * Math.sqrt(tjc) + 0.28 * Math.sqrt(sjc) + 0.70 * Math.log(esr) + 0.014 * pga
end
#include "simple.h"
// {'B' => 456, 'A' => 123}
typedef Environment<NamedNumber<'B', 456>>::Merge<NamedNumber<'A', 123>>::environment environment;
// B => 456
auto b = Variable<'B'>::Evaluate<environment>::value;
// B + A => 579
auto aadd_b_a = Add<Variable<'B'>, Variable<'A'>>::Evaluate<environment>::value;
#!/usr/bin/ruby
# coding: utf-8
require 'date'
begin
raise unless ARGV.size == 3
date_range = ARGV.shift.match(/(\d{1,2}\/\d{1,2})-(\d{1,2}\/\d{1,2})/) { Date.parse($1)..Date.parse($2) }
start_time, end_time = ARGV.shift.match(/(\d{1,2}\:\d{1,2})-(\d{1,2}\:\d{1,2})/) { [DateTime.parse($1), DateTime.parse($2)] }
step = ARGV.shift.to_f
Gem::Specification.new do |spec|
spec.name = "nullpo"
spec.version = "0.0.1"
spec.authors = ["e.mattsan"]
spec.email = ["e.mattsan@gmail.com"]
spec.summary = "null pointer"
spec.files = ["nullpo.rb"]
spec.require_path = "."
end
# 修正したコード
def decode(code_sets)
size = code_sets.first.inject(&:+)
board = size.times.map { [0] * size }
depth = [0] * size
code_sets.each do |code_set|
y = depth.min
x = depth.find_index(y)
# puts "decode (%d, %d)" % [x, y]
:- initialization(main).
split(Input, [Point|Points]) :-
append(Point, [0',|Rest], Input),
split(Rest, Points),
!.
split(Point, [Point]).
min(Xs, X) :- sort(Xs, [X|_]).
max(Xs, X) :- sort(Xs, Sorted), reverse(Sorted, [X|_]).
@mattsan
mattsan / data.txt
Created March 7, 2016 22:09
「オフラインリアルタイムどう書くE02」を解いた
3:Oh,Be,AF,in,eG,ir,l5,Q8,mC,7T,Ty,tT 108,1920
3:00,zz,0z,z0 -
1:ho 1,3844
2:am -
4:00,zz,0z,z0 3844,3844
4:00,11,zz,yy,1y,y1 3600,3721
2:00,01,10,11,yz,zy,yy,zz 2,3660
2:AA,AB,BA,BB,SZ,SY,TZ,TY 2,2046
3:Lw,qw,cw,Ow,2w,fw,yw,ow,Zw,iw 7,2170
4:0o,0s,0x,0C,0L,0k,0V,0y,0m,0S 9,2852
@mattsan
mattsan / file0.rb
Created March 13, 2016 11:45
オフラインリアルタイムどう書くE02 の問題を解いた(一週間が経過してた) ref: http://qiita.com/emattsan/items/d0b6d0e0a79af2a28a37
min_area = (pos('m') - pos('e') + 1) * (pos('G') - pos('5') + 1)