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
# 使用例 | |
> genbat.pl > rename_pdf.bat | |
> type rename_pdf.bat | |
ren "oreilly-4873113075.pdf" "エンジニアのための時間管理術.pdf" | |
ren "oreilly-9784873113630.pdf" "ビューティフルコード.pdf" | |
ren "oreilly-9784873114132.pdf" "詳解 OpenCV.pdf" | |
ren "oreilly-9784873114194.pdf" "Silverlightで開発するデータ駆動アプリケーション.pdf" | |
ren "oreilly-9784873114200.pdf" "Head First Statistics.pdf" | |
ren "oreilly-9784873114286.pdf" "アルゴリズムクイックリファレンス.pdf" |
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 java.io.FileOutputStream | |
import com.itextpdf.text.DocWriter | |
import com.itextpdf.text.pdf.{PdfStamper, PdfReader} | |
object FreePdf { | |
val usage = """ | |
|FreePdf [-password password] input-pdf-file output-pdf-file | |
| Option: | |
| -password password: Owner(Master) password of the file | |
""".stripMargin |
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
// お題:ランダム文字列 | |
// <http://d.hatena.ne.jp/fumokmm/20110326/1301144291> | |
// に対する scala での答案(Iterator.continually編)by @akihiro4chawon | |
object Prob2 extends Application{ | |
def gen(nDigits: Int) = { | |
val range = ('a' to 'z') ++ ('A' to 'Z') ++ ('0' to '9') :+ '_' | |
Iterator.continually(range(Random.nextInt(range.size))) take nDigits mkString | |
} |
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
// お題:時間帯重複チェック(応用編)(リファクタリング前) | |
// <http://d.hatena.ne.jp/fumokmm/20110329/1301403400> | |
// お客さんから仕様変更を言い渡されて、さあ大変。 | |
// まずはスパゲチーソースで即応だ! by @akihiro4chawon | |
object Prob1 extends Application { | |
type Duration = (Int, Int, Int, Int) | |
def timePointInMinutes(hour: Int, min: Int) = | |
for { |
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
// お題:時間帯重複チェック(応用編) 別の答案(この答案は、入力チェックはしておりません) | |
// <http://d.hatena.ne.jp/fumokmm/20110329/1301403400> | |
// | |
// (こちらの解答を参考にした後に作成しました → http://d.hatena.ne.jp/route150/20110401/1301661345 | |
object Test extends Application { | |
type TSpan = (Int, Int, Int, Int) | |
def solve(ts: TSpan*) = { | |
val toAns: Seq[Int] => TSpan = { case Seq(a, b) => (a / 60, a % 60, b / 60, b % 60) } | |
val dup = (ts flatMap {case (h1, m1, h2, m2) => h1 * 60 + m1 until h2 * 60 + m2} groupBy identity collect { case(x, l) if l.size > 1 => x}).toSeq.sorted |
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
// お題:時間帯重複チェック(応用編) | |
// <http://d.hatena.ne.jp/fumokmm/20110329/1301403400> | |
// に対する、最良のアルゴリズムを考えた。 by @akihiro4chawon | |
/** 時刻; Time Point */ | |
case class Point(hour: Int, minutes: Int) extends Ordered[Point] { | |
def inMinutes = 60 * hour + minutes | |
override def compare(that: Point) = | |
this.inMinutes compare that.inMinutes |
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
{-# LANGUAGE ViewPatterns #-} | |
-- route150 さんの「時間帯重複チェック:応用編1」への返信コード | |
-- 第4のコーナケースを通るようにしてみた。(時間軸を2倍にしなくてもOKです) | |
-- 元の答案の出典:http://d.hatena.ne.jp/route150/20110401/1301661345 | |
import Control.Applicative | |
import Data.List | |
type Time = (Int, Int) | |
type TimeSpan = (Int, Int, Int, Int) |
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
// お題:一方通行を許可した迷路を作成 | |
// <http://d.hatena.ne.jp/aya_eiya/20110329/1301406161> | |
// に対する答案 by @akihiro4chawon | |
// 基本方針:力押し(グラフ連結に関する理論は一切使っていない) | |
// ポイント:掘るんじゃない、閉ざしていくんだ! | |
// requires scala 2.9.0 RC1 or later | |
// scala 2.8.1 には、Enumeration にバグがあるので scala 2.9.0 RC1 を使用した |
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
// as straight forward as possible | |
def solve1 = { | |
val digits = 0 to 9 | |
def num(ds: Int*) = ds.foldLeft(0){10 * _ + _} | |
for { | |
// send | |
s <- digits diff Seq(0) | |
e <- digits diff Seq(s) | |
n <- digits diff Seq(s, e) | |
d <- digits diff Seq(s, e, n) |
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
// scalaz の ぁゃιぃ 文字数を数える | |
// ちなみに手元の 7e22c46151c24a7b291354091d3b9dc442e3352f ではちょうど 2500 | |
import scalaz._ | |
import scalaz.Scalaz._ | |
import scala.collection.JavaConversions._ | |
import scala.io.Source | |
import java.util.jar.{JarFile, JarEntry} | |
object SymbolCount { |
OlderNewer