O'reilly

CheckIO O'reillyの問題和訳
問題ページのうち, 問題の前提となる小話は訳してません.
また各問題ページ下部にある「Precondition」は「前提条件」のため訳しません(数値の範囲などだけなので).


Striped Words

Find the hidden striped words in the robots linguistics test.

Our robots are always working to improve their linguistic skills. For this mission, they research the latin alphabet and its applications.
The alphabet contains both vowel and consonant letters (yes, we divide the letters).
Vowels -- A E I O U Y
Consonants -- B C D F G H J K L M N P Q R S T V W X Z
You are given a block of text with different words. These words are separated by white-spaces and punctuation marks. Numbers are not considered words in this mission (a mix of letters and digits is not a word either). You should count the number of words (striped words) where the vowels with consonants are alternating, that is; words that you count cannot have two consecutive vowels or consonants. The words consisting of a single letter are not striped -- do not count those. Casing is not significant for this mission.

Input: A text as a string (unicode)
Output: A quantity of striped words as an integer.

How it is used:
This idea in this task is a useful exercise for linguistic research and analysis. Text processing is one of the main tools used in the analysis of various books and languages and can help translate print text to a digital format.

私たちのロボットは常に言語スキルの改良を行っている. このミッションでは, 彼らはラテンアルファベットとその応用を研究する.
アルファベットは母音と子音の両方を含む(つまり私たちは文字を分けることができる).
母音 -- A E I O U Y
子音 -- B C D F G H J K L M N P Q R S T V W X Z
あなたには異なる単語のテキストのまとまりが与えられる. これらの単語は空白と句読点によって区切られている. このミッションでは単語の数は考えない(文字と数字の混在はどちらも単語として扱わない). あなたは母音と子音が交互になる単語(ストライプ単語)を数える. ストライプ単語では母音か子音が2つ以上連続の場合数えない. 1文字からなる単語はストライプではない, これは数えない. このミッションでは重要ではない.

入力:文字列としてテキスト(unicode)
出力:ストライプ単語の数

備考
このタスクのアイデアは言語研究と分析の練習に使われる. テキスト処理は様々な本, 言語の分析で使われる主なツールの1つで, デジタル形式のテキストを翻訳するのに使われる.

Disposable teleports

Write some code to help people navigate the teleporter maze.

The island has eight stations which are connected by a network of teleports; however, the teleports take a very long time to recharge. This means you can only use each one once. After you use a teleport, it will shut down and no longer function. For this task, you should begin at number 1 and try to travel around to all the stations before returning to the starting point. The map of the teleports is presented as a string in which the comma-separated list represents teleports. Each teleport is given the name of the station it connects to. This name consists of two digits, such as '12' or '32.' Each test requires you to provide a route which passes through every station. A route is presented as a string of the station numbers in the sequence in which they must be visited (ex. 123456781).

Input: A teleport map as a string.
Output: The sequence of station numbers as a string.

How it is used:
This task is another example of the graph-search problem. It's like trying to find a route where you can not to step on the same spot twice.

島にはテレポートのネットワークでつながれた8つの駅がある. しかしながらテレポートは再装填に非常に時間がかかる. これはそれぞれのテレポートを使うのは1度だけということを意味する. あなたがテレポートを使ったあと, それは電源が落ち, 機能しなくなる. このタスクでは, あなたは1番目のテレポートから始め, 全てのテレポートを回って最初のテレポートに戻ってこようとする. テレポートのマップはコンマで区切られた文字列として表現される. それぞれのテレポートはつながっている駅の数字が与えられる. この名前は12や32などの2つの数字を含む. それぞれのテストは全ての駅を通る経路のルートを必要とする. ルートは駅の数字の文字列として表現される. 駅は全て通らなければならない.

入力:文字列としてテレポートのマップ
出力:文字列として駅の番号の数列

備考
このタスクはグラフ探索問題の別の例である. それはあなたが同じ場所を2度行かないルートを見つけようとするものだ.

Ghosts age

Help discover the age of a group of ancient ghosts.

Nicola takes a moment to study the ghosts. He is trying to think up a new method to determine just how old these ghosts are. He knows that their age is somehow related to their opacity. To measure their opacity Nikola uses a scale of 10000 units to 0 units, where 10000 is a completely opaque newborn ghost (0 years old) and 0 is completely transparent ghost (of an unknown age).
After some experimenting, Nikola thinks he has discovered the law of ghostly opacity. On every birthday, a ghost's opacity is reduced by a number of units equal to its age when its age is a Fibonacci number (Read about this here) or increased by 1 if it is not.
For example:
A newborn ghost -- 10000 units of opacity.
1 year -- 10000 - 1 = 9999 (1 is a Fibonacci number).
2 year -- 9999 - 2 = 9997 (2 is a Fibonacci number).
3 year -- 9997 - 3 = 9994 (3 is a Fibonacci number).
4 year -- 9994 + 1 = 9995 (4 is not a Fibonacci number).
5 year -- 9995 - 5 = 9990 (5 is the Fibonacci number).
Help Nicola write a function which will determine the age of a ghost based on its opacity. You are given opacity measurements as a number ranging from 0 to 10000 inclusively. The ghosts cannot be older than 5000 years as they simply disappear after such a long time (really!).
This is a Halloween task so you should try and write a "magic" or "scary" solution. Please, do not write "regular" solution.

Input: An opacity measurement as an integer.
Output: The age of the ghost as an integer.

How it is used:
This task was made for some spooky fun! We hope to see your funny, tricky and creative solutions!

ニコラはゴーストの勉強を始めた. 彼はゴーストの年齢を決定するための新しいメソッドを考えている. 彼はゴーストの不透明さと関連した年齢を知りたい. ゴーストの不透明さを計測するために, ニコラは10000から0の目盛を使う. ここで10000は完全に不透明な生まれたてのゴースト(0歳)で, 0は完全に透明なゴーストだ(何歳かは不明).
何度かの実験のあと, ニコラはゴーストの不透明さに法則があることを発見した. 誕生日ごとに, ゴーストの不透明さは年齢がフィボナッチ数列のときにその数だけ減り, そうでないときは1だけ増える.
たとえば
生まれたてのゴースト -- 10000の不透明度
1年後 -- 10000 - 1 = 9999(1はフィボナッチ数列).
2年後 -- 9999 - 2 = 9997(2はフィボナッチ数列).
3年後 -- 9997 - 3 = 9994(3はフィボナッチ数列).
4年後 -- 9994 + 1 = 9995(4はフィボナッチ数列ではない).
5年後 -- 9995 - 5 = 9990(5はフィボナッチ数列).
ニコラがゴーストの不透明度から年齢を決定する関数を書くのを助けよう. あなたには0から10000の不透明度の計測値が与えられる. ゴーストは5000歳以上になると消えてしまう(本当だ!).
これはハロウィーンタスクなので, あなたには魔法か恐ろしい答えを書いてほしい. どうか, 普通に答えは書かないでほしい.

入力:不透明度の計測値
出力:ゴーストの年齢

備考
このタスクはスプーキーファンのために作られた! 私はあなたの面白おかしく, 創造力のある答えを期待している!

Bats Bunker

Calculate the minimal possible amount of time it will take to catch the Alpha Bat.

While searching for an adventure on the island, our robotic trio found a creepy old bunker. In the bunker, someone has hidden a rare and powerful computer chip which the robots hope to install on their spaceship. Our adventurous heroes have tried to search for this chip, but the bunker is occupied by robo-bats and the Alpha Bat appears to be in possession of the chip. In order to obtain the chip, the robots must capture Alpha Bat. This is no easy feat though; the bunker is filled with bat scouts which will alert the others if they spot intruders. If we want to catch the Alpha Bat, we will need to know the amount of time it takes for the alert sent by the scout near the entrance to reach the Alpha Bat.
We have the advantage that the bunker's walls do not reflect sound, so the alert signals can extend only in a straight line. The time it takes an alert to move between two bats is proportional to the Euclidean distance between cell centers (see the illustration). The time for the alert to travel between neighbouring cells is 1 second. Alert "lines" cannot pass through walls or around corners.
You are given the map of bunker as a list of strings:
"-" is an empty cell
"W" is a wall
"B" is a bat 
"A" is the Alpha Bat 
The entrance is placed at top left cell and there's always a bat right there (be careful, the Alpha bat can be here too).
You should calculate the minimal possible time for the alert to reach the leader with a precision of two digits (±0.01).

Input: A map of the bunker as a list of strings.
Output: The minimal possible time with a precision of two digits as a float.

How it is used:
This task is a tricky search problem. It teaches you how to build a graph and determine the line of visibility for the Bats. These concepts can help develop security in the form of CCTV placement, process lighting and even add search and discover algorithms to in game AI.

島の冒険のために検索をしている間, 3組のロボットが身の毛のよだつような古い掩蔽壕(えんぺいごう)を見つけた. 掩蔽壕の中には, ロボットが宇宙船に取り入れたい強力なコンピュータチップが隠されていた. 私たちの冒険好きな英雄はこのチップを検索しようと試みたが, 掩蔽壕はロボットコウモリに占領されており, アルファバットがチップを占有していた. チップを得るために, ロボットはアルファバットを捕まえなければならない. これはそう簡単ではない. 掩蔽壕は偵察コウモリで満たされ, 侵入者を見つけると他のコウモリに警告を発する. アルファバットを捕まえるには, 私たちは偵察がアルファバットに警告を送るまでどれくらい時間がかかるのかを知る必要がある.
私たちは掩蔽壕の壁が音を反射しないというアドバンテージを得ており, さらに警告信号は直線状にしか展開しないということも知っている. 2匹のコウモリの間を警告が移動する時間は, セルの中心同士のユークリッド距離に比例する. 隣り合うセルに渓谷が移動する時間は1秒だ. 警告信号の線は壁を通らないし, 角を曲がることもない.
あなたには文字列のリストとして掩蔽壕のマップが与えられる. マップのフォーマットは以下のとおりである.
"-"は空のセル
"W"は壁
"B"はコウモリ
"A"はアルファバット
入口は左上のセルである. すぐそこにコウモリがいる(アルファバットもいる可能性がある).
あなたは警告信号がリーダーに届くまでの最小可能時間を計算する. 誤差は小数点第二位の±0.01まで許容する.

入力:文字列のリストとして掩蔽壕のマップ
出力:最小可能時間を浮動小数点で

備考
このタスクはトリッキーな探索問題である. それはあなたにグラフの組み立て方とコウモリの視界の線を決定する方法を教える. これらのコンセプトは有線テレビのセキュリティを開発するのを助けたり, ゲームAIの探索と発見の処理を助けたりする.

Haunted House

Help Stephan escape from the Ghosts in the House.

ステファンは港から放浪し, 森の中に気味の悪い古い家を発見した. 家を探索した後, 彼は家に16(4x4)部屋あることに気づいた. それぞれの部屋には4つのドアがあるが, いくつかのドアは開かない. さらに, 外回りのドアは闇に導かれる. 家の唯一の出口は北にある1番目の部屋のドアだけだ. 最後の部屋(16番目)を探索している間, 彼は忘れられない, ギーギー鳴る音とカタカタ鳴る鎖の音を伴ったうめき声を聞いた. 彼は家のセンサーの掃除をはじめると, 幽霊が最初の部屋に出現することを発見した. 恐怖にかられ, ステファンは家からの脱出手伝ってくれるようにあなたに頼んだ. あなたは幽霊に出会うことなく最初の部屋まで彼と行く.
あなたは部屋の4方向, 北, 南, 西, 東("N", "S", "W", "E")にある, 閉じられていないドアのうち2つに移動できる. ステファンは恐怖でまだ動けないでいた. 暗い奈落の底に落ちてしまうため, 彼が外側のドアから脱出しないように確認する必要がある. 家から出る安全な方法は最初の部屋の北側のドアだけだ. それぞれのステップであなたは文字として方向を返し, ステファンに彼の移動先を伝える. 彼の移動の後, 幽霊もまた移動する. 幽霊はあなたとステファンを積極的に捕まえようとしてくる.幽霊はあなたとステファンのいる場所に最短で行こうとするが, 幽霊は少し馬鹿で, 移動する方向を決めるためにユークリッド距離を使う. あなたは移動を30回に制限されており, それを超えると, 幽霊は仲間を呼び出し, あなたともども捕まえる.
それぞれのステップであなたは3つの引数を与えられる. 家のマップと, ステファンの位置(部屋の番号)と幽霊の位置(部屋の番号)だ. マップは16の要素を持つリストとして表現される. ここでそれぞれの要素は部屋と一致する(1番目の要素は1番目の部屋). それぞれの要素は通れない方向が文字列として入っている. たとえば, 6番目の要素(インデックスは5)は"NS"であるから, 6番目の部屋は北と南のドアが開かない.
注意, 外側のドアはいつでも閉じられていない. あなたは1番目の部屋の北のドアだけを通って脱出しなければならない.

入力:文字列のリストとして家のマップ, ステファンの位置(部屋番号), 幽霊の位置(部屋番号)
出力:文字列としてステファンが移動するルート

備考
このタスクはあなたの経路探索能力とゲーミングアルゴリズムを鍛えるために使われる. 普通の経路探索問題と違って, あなたはAIのアクションの評価を必要とする. これは変化する環境における複雑なナビゲーションシステムに必要とされる.
最終更新:2014年04月19日 01:09