This file contains hidden or 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
// aya_eiyaさんのお題 http://d.hatena.ne.jp/aya_eiya/20110329/1301406161 を | |
// deve68さんの方式に従って解いてみた回答 http://d.hatena.ne.jp/deve68/20110410/1302464249 | |
// 判定機能は未実装 | |
final def MAXCOL = 10 | |
final def MAXROW = 10 | |
assert (MAXCOL == MAXROW) && (MAXCOL >= 2) | |
// ノードクラス | |
class Node { |
This file contains hidden or 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
// XMLの形状は下記の通り(10x10の迷路限定) | |
// ( from http://d.hatena.ne.jp/aya_eiya/20110329/1301406161 ) | |
// <labyrinth> | |
// <cell doors='East:true,West:false,South:true,North:false' position='1,1'></cell> | |
// <cell doors='East:true,West:false,South:true,North:false' position='1,2'></cell> | |
// ... | |
// <cell doors='East:false,West:true,South:false,North:true' position='10,10'></cell> | |
// </labyrinth> | |
// | |
// 実行後の出力結果を次のように GraphViz に与える |
This file contains hidden or 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
class MyTime implements Comparable { | |
int hour | |
int minutes | |
MyTime(hour, minutes) { | |
this.hour = hour | |
this.minutes = minutes | |
assert isValid(), "The time ${this} is not valid." | |
} | |
int compareTo(that) { | |
(hour*60+minutes) <=> (that.hour*60+that.minutes) |
This file contains hidden or 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
// st = [時,分] が [0,0]~[24,0]の範囲内かどうかをチェック | |
def isValidTime = { st -> ((0..23).contains(st[0]) && (0..59).contains(st[1])) || (st[0] == 24 && st[1] == 0) } | |
// st1 = [時,分], st2 = [時,分] が st1 <= st2 を満たすかどうかをチェック | |
def isNotGreaterThan = { st1, st2 -> st1[0] < st2[0] ? true : (st1[0] == st2[0] ? st1[1] <= st2[1] : false) } | |
// pt = [開始時,開始分,終了時,終了分] が [開始時,開始分] <= [終了時,終了分] を満たすかどうかをチェック | |
def isValidPair = { pt -> isValidTime(pt[0,1]) && isValidTime(pt[2,3]) && isNotGreaterThan(pt[0,1],pt[2,3]) } | |
// pt1 = [開始時,開始分,終了時,終了分], pt2 = [開始時,開始分,終了時,終了分] がオーバーラップしているかどうかをチェック |
This file contains hidden or 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
// new Random と nextIntを使用 | |
[*0..9,*'a'..'z',*'A'..'Z','_'].with{a->println new Random().with{(1..16).collect{a[nextInt(a.size())]}.join()}} | |
// Math.randomを使用 | |
[*0..9,*'a'..'z',*'A'..'Z','_'].with{a->println((1..16).collect{a[(int)Math.random()*a.size()]}.join())} | |
// def と println版 | |
def a=[*0..9,*'a'..'z',*'A'..'Z','_'];println((1..16).collect{a[(int)Math.random()*a.size()]}.join()) |
This file contains hidden or 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
/** | |
* Created by IntelliJ IDEA. | |
* User: kyon | |
* Date: 11/03/15 | |
* Time: 0:54 | |
* To change this template use File | Settings | File Templates. | |
*/ | |
String.metaClass.toXML = { builder, entry -> | |
builder."${entry.key}"(entry.value) |
This file contains hidden or 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
// 他プロジェクトの指定期間内の成功ビルドの成果物ディレクトリを一覧する方法 | |
// 以下は groovy plugin の Execute system Groovy script の中で使用して | |
// TESTプロジェクトの | |
// 2011/3/1 00:00:00 から | |
// TESTプロジェクトの最終ビルド まで | |
// の期間を対象にして成功ビルドの成果物ディレクトリを一覧する | |
def jobname = "TEST" | |
def job = hudson.model.Hudson.instance.getItem(jobname) |
This file contains hidden or 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
// 動作中のプロジェクト自身を取得する方法 | |
// 以下は groovy plugin の Execute system Groovy script の中で使用して | |
// groovy plugin自体を実行しているプロジェクトを取得する例 | |
def currentJob = Thread.currentThread().executable.project | |
println currentJob.name |
This file contains hidden or 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
// あるプロジェクトの下流ビルドと上流ビルドを取得する方法 | |
// 以下は groovy plugin の Execute system Groovy script の中で使用して | |
// TEST プロジェクトの下流ビルドと上流ビルドを取得する例 | |
def jobname = "TEST" | |
def job = hudson.model.Hudson.instance.getItem(jobname) | |
def dep = hudson.model.Hudson.instance.dependencyGraph | |
assert job, "ERROR: Can't find the job $jobname." | |
assert dep, "ERROR: Can't get the dependency graph." |
This file contains hidden or 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
// 他のプロジェクトのビルドを中止する方法 | |
// 以下は groovy plugin の Execute system Groovy script の中で使用して | |
// TEST プロジェクトのビルドを中止する例 | |
def jobname = "TEST" | |
def job = hudson.model.Hudson.instance.getItem(jobname) | |
assert job, "ERROR: Can't find the job $jobname." | |
def lastbuild = job.lastBuild | |
if( lastbuild ) { |