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
#! /usr/bin/ruby | |
# CodeIQ q1215 サルベジオン社で宇宙船のデータを救え | |
# 初期処理 -- API キャッシュロード | |
BEGIN { | |
MEMOFILE = 'apicache.db' | |
$memo = File.open(MEMOFILE) do |io| | |
Marshal.load( io) | |
end rescue {} | |
} |
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
#! /usr/bin/ruby | |
# coding: sjis | |
# CodeIQ q1097 中学入試から:正三角形?二等辺? | |
REGULAR = 'あ' | |
ISOSCELES = 'い' | |
OTHOER = 'う' | |
wa=[] | |
$<.each do |l| |
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
#! /usr/bin/ruby | |
# 分割+分枝限定法版 | |
# 最大ツアー数プラン検索クラス | |
class MaxPlan | |
# コンストラクタ | |
def initialize( tore) | |
@tore = tore |
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
(do((s"`@ぁァァぁ@`"(princ(map'string(lambda(c)(code-char(1+(char-code c))))s))))((string> s"z"))) |
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
#! /usr/bin/ruby | |
# CodeIQ q832 スペーストーキー社の危機を救え! | |
# 初期処理 -- API キャッシュロード | |
BEGIN { | |
MEMOFILE = 'apicache.db' | |
$memo = File.open(MEMOFILE) do |io| | |
Marshal.load( io) | |
end rescue {} | |
} |
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
#! /usr/bin/ruby | |
# CodeIQ 暗号解読クリプタン問題 暗号文1解析 | |
# 入力 | |
ctext = $<.map{|l| l.split.map{|h|h.to_i(16)}}.flatten | |
# ヒストグラム | |
hist=[0]*256 | |
ctext.each{|d| hist[d]+=1} |
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
/* CodeIQ q684 gemstring */ | |
/* 全ての場合を列挙する素朴な方法 */ | |
/* ターゲットが指定されるとそれだけ表示する */ | |
/* 非常に遅い */ | |
#include <stdio.h> | |
#include <string.h> | |
#define MAXGEMS 32 | |
#define MAXLINE 80 |
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
#! /usr/bin/ruby | |
# テトラミノビンゴ | |
# 指定位置から連続する穴の位置リスト(4個以下なら正確) | |
def run(pos) | |
x,y = pos; | |
return [] if !$hole[pos] || $visit[pos] | |
$visit[pos]=1; | |
l = [pos] | |
l += run([x-1,y]) if x > 0 && l.size <= 4 |
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
#! /usr/bin/ruby | |
# 言語: Ruby 2.0.0 | |
#------------------------ | |
# 入力:data1.in | |
# 2020.811047 | |
# 35.640485 140.063040 | |
# 35.443708 139.638026 | |
# 34.741327 137.791773 | |
# 35.599629 138.517272 | |
# 34.778815 136.908237 |
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
#! /usr/bin/ruby | |
# 動的計画法 | |
# 支払い金種バリエーション(各金種でちょうど払うか全く払わないか選択) | |
MANEY=[1000,500,100,50,10,5,1] | |
GOODS=$<.map(&:to_i) | |
wallet=[1,0,0,0,0,0,0] | |
# ヒープ | |
# データ:[総時間, 財布のリスト, 未購入商品リスト, 支払いリスト] |
NewerOlder