Scientific Expedition

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


Transposed Matrix

Transpose a matrix of 2D numbers.

In linear algebra, the transpose of a matrix A is another matrix A^T (also written A′, A^tr, tA or A^t) created by any one of the following equivalent actions:
reflect A over its main diagonal (which runs from top-left to bottom-right) to obtain A^T
write the rows of A as the columns of A^T
write the columns of A as the rows of A^T
Formally, the i-th row, j-th column element of A^T is the j-th row, i-th column element of A:
[A^T]_ij = [A]_ji
If A is an m × n matrix then A^T is an n × m matrix.
You have been given a matrix as a 2D list with integers. Your task is to return a transposed matrix based on input.

Input: A matrix as a list of lists with integers.
Output: The transposed matrix as a list of lists with integers.

How it is used:
The most obvious use for this idea is in mathematical software, but the concept can be applied in the area of vector graphics. On a computer, one can often avoid explicitly transposing a matrix in memory by simply accessing the same data in a different order.

線形代数では, 行列Aの転置を行列A^T(A', A^tr, tAやA^tとも書かれる)と呼ぶ. 転置行列は以下のアクションにより求められる.
Aの対角線で要素を入れ替えると転置行列A^Tが得られる.
Aの列はA^Tの行になる.
形式的に, A^Tのi行j列の要素は, Aのj行i列目の要素となる.
[A^T]_ij = [A]_ji
m×n行列Aはn×m行列A^Tになる.
あなたには整数の2次元リストが行列として与えられる. 入力の行列を転置した行列を返す.

入力:リストのリストとしての行列
出力:転置行列, リストのリストとして

備考
数学的ソフトウェアではこのアイデアは明らかに使われるが, コンセプトはベクタグラフィックスの面積で応用される. コンピュータでは,
異なる順序で同じデータにアクセスすることで, しばしば転置行列の使用を避けている.

Weekend counter

Help Sofia with planning her weekends.

Sofia has given you a schedule and two dates and told you she needs help planning her weekends. She has asked you to count each day of rest (Saturday and Sunday) starting from the initial date to final date. You should count the initial and final dates if they fall on a Saturday or Sunday.
The dates are given as datetime.date (Read about this module here). The result is an integer.

Input: Start and end date as datetime.date.
Output: The quantity of the rest days as an integer.

How it is used:
Now is a good time to learn how to work with dates. These ideas here often come up in calendar apps, customer relation management software, automated messaging schedulers among many other things.

ソフィアはあなたにスケジュールと2つの日にちを与え, あなたに彼女の週末の計画を手伝うことを伝えた. 彼女はある日から別の日までの休日(土曜日と日曜日)の回数を数えたいとあなたに聞いた. あなたは2つの日にちの間にある土曜日と日曜日を数える.
日にちはdatetime.dateとして与えられる. 結果は整数で返す.

入力:開始日と終了日をdatetime.dateとして.
出力:期間の間の休日の数を整数で.

備考
日にちの扱い方を学ぶことができる. これらのアイデアはカレンダーアプリ, 顧客管理ソフトや, スケジュールの自動設定ソフトなどでしばしば出てくる.

The Angles of a Triangle

Discover the angles of a triangle.

You are given the lengths for each side on a triangle. You need to find all three angles for this triangle. If the given side lengths cannot form a triangle (or form a degenerated triangle), then you must return all angles as 0 (zero). The angles should be represented as a list of integers in ascending order. Each angle is measured in degrees and rounded to the nearest integer number (Standard mathematical rounding).

Input: The lengths of the sides of a triangle as integers.
Output: Angles of a triangle in degrees as sorted list of integers.

How it is used:
This is a classical geometric task. The ideas can be useful in topography and architecture. With this concept you can measure an angle without the need for a protractor.

あなたには三角形の3つの辺の長さが与えられる. あなたはこの三角形の3つの角度を全て求める. もし与えられた辺から三角形を作れないなら, あなたは全ての角度を0として返す. 角度は整数のリストとして, 昇順にしたものとして表現される. それぞれの角度は最も近い整数に丸める.

入力:三角形の三辺長さ
出力:三角形の3つの角度, 昇順にソートしたリストで

備考
これは古典的な幾何学の問題である. このアイデアはトポロジーや建築学で使われる. この問題のコンセプトはあなたに分度器を使わせることなく角度を計算させる方法を教えることである.

Loading Cargo

Help Stephen evenly distribute weights into two sets.

You have been given a list of integer weights. You should help Stephen distribute these weights into two sets, such that the difference between the total weight of each set is as low as possible.

Input data: A list of the weights as a list of integers.
Output data: The number representing the lowest possible weight difference as a positive integer.

Hints:
The simplest way (but it's slow) is to check all combinations of distributions.
Python already has the tools for combinatorics — import itertools.
Do you want an effective algorithm? Take a look at Partition problems.

How it is used:
This is a combinatorial optimization version of the partition problem. The combinatorial optimization has wide usage and you often see it when you look at automated schedules or route calculating.

あなたには重さを表す整数のリストが与えられる. あなたはステファンの2つの重さの差が可能な限り小さくなるように分配を手助けする.

入力:重さのリスト
出力:2つの重さ最小の差

ヒント
最も単純な方法(しかし遅い)は全ての組み合わせをチェックすることだ.
Pythonは既に組み合わせのためのツールを持っている, import itertoolsだ.
効率的なアルゴリズムを知りたい? 分割問題を見るべきだ.

備考
これは分割問題の組み合わせ最適化版である. 組み合わせ最適化は幅広く使われ, あなたはしばしば自動スケジューラやルート計算で見かける.

Spaceship landing strip

Carve a landing strip out of the ground for the rescue party to land on…

The Robots have discovered a new island and accidentally crashed on it. To survive, they need to create the largest rectangular field possible to make a landing strip. While surveying the land, they encountered a number of obstacles which they marked on their map. Each square of the map is marked according to whether it contains grass (G), rock (R), water (W), shrubs (S), or trees (T). While the grass can be mowed and the shrubs can be dug from the ground, the water, rocks, and trees cannot be removed with the tools at their disposal. Given these obstacles, they need your help to determine the area of the largest possible rectangular field.
The island map is represented as a list of strings. Each list contains letter characters which indicate the conditions for each square of land (G, R, W, S, or T). The map is rectangular.

Input: An island map as a list of strings.
Output: The maximum area of the largest possible rectangle that can be cleared as an integer.

How it is used:
This concept touches on image and pattern recognition. If you solve the challenge with a Histogram search, you can use it for statistical analysis.

ロボットは新しい島を発見したが, アクシデントが起こって壊れてしまった. 生き残るために, 彼らは着陸可能な大きい四角形のフィールドを作る必要がある. 島で生活する間, 彼らは地図に遭遇した障害物をマークした. 地図のそれぞれのセルは草(G), 岩(R), 水(W), 低木(S), 木(T)でマークされている. 草と低木は地上から掘ることで動かすことができるが, 水, 岩, 木を取り除く道具はない. あなたは与えられた障害の中から, 最も大きな四角形のフィールドを探す手助けをする.
島のマップは文字列のリストとして表現される. それぞれのリストは島の条件を示す(G, R, W, S, T)のセルからなる. マップは四角形である.

入力:文字列のリストとして島のマップ
出力:作成可能な最大の四角形の面積, 整数

備考
このコンセプトは画像とパターンの認識に触れることである. あなたがヒストグラム探索に挑戦したとしたら, あなたはそれを統計分析に使うことができる.

Friendly number

Make a long number friendlier by shortening it.

Long numbers can be made to look nicer, so let’s write some code to do just that.
You should write a function for converting a number using several rules. For starters, you will need to cut the number with a given base (base argument; default 1000). The number should be a coefficient with letters designating the power. The coefficient is a real number with decimal after the point (decimals argument; default 0). You will be given a list of power designations (powers argument; default ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']). If you are given suffix (suffix argument; default ‘’) , then you must be add it at the end. For the coefficient, use the rounding down rule (5.6⇒5, -5.6⇒-5) if the decimal = 0, else use the standard rounding procedure. If you don’t have enough powers - stay at the maximum. If the number of decimals are greater than the real number of digits after dot, trail it with zeroes. And zero is always zero without powers.
Let's look at examples. It will be simpler.
n=102
result: "102", the base is default 1000 and 102 is lower this base.
n=10240
result: "10k", the base is default 1000 and rounding down.
n=12341234, decimals=1
result: "12.3M", one digit after the dot.
n=12000000, decimals=3
result: "12.000M", trailing zeros.
n=12461, decimals=1
result: "12.5k", standard rounding.
n=1024000000, base=1024, suffix='iB'
result: '976MiB', the different base and the suffix.
n=-150, base=100, powers=['', 'd', 'D']
result: '-1d', the negative number and rounding down.
n=-155, base=100, decimals=1, powers=['', 'd', 'D']
result: '-1.6d', the negative number and standard rounding.
n=255000000000, powers=['', 'k', 'M']
result: '255000M', there is not enough powers.

Input: A number as an integer. The keyword argument "base" as an integer, default 1000. The keyword argument "decimals" as an integer, default 0. The keyword argument "powers" as a list of string, default ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'].
Output: The converted number as a string.

How it is used:
In the physics and IT we have a lot of various numbers. Sometimes we need to make them more simpler and easier to read. When you talk about gigabytes sometimes you don’t need to know the exact number bytes or kilobytes.

大きな数は他によい見せ方があり, それをするためだけにいくつかのコードを書こう.
あなたはいくつかのルールに従った数の変換の関数を書く. はじめに, あなたは与えられた基底(引数となる, デフォルトは1000)を使って数字をカットする必要がある. 数値は係数とべきを示す文字であらわされる. 係数は小数点第n位(引数で指定, デフォルトは0)の実数である. あなたにはべきを示す文字(べきの引数, デフォルトは['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'])のリストが与えられる. もし接尾辞が与えられたら(接尾辞も引数, デフォルトは''), あなたはそれを末尾に加える. 引数decimal=0なら係数には下丸め(5.6=>5, -5.6=>-5)が適用され, それ以外は通常の丸めが適用される. もし十分なべきがないなら, 最大のべきで表現する. ドットのあとの桁の実数が指定した桁(decimal)より長いなら, 0で埋める. また0は常にべきなしの0である.
例を見てみよう. シンプルなものだ.
n=102
結果は"102", 基底は1000で, 102は基底より小さい.
n=10240
結果は"10k", 基底は1000で, 下丸めした.
n=12341234, decimals=1
結果は"12.3M", 小数点以下第1位まで.
n=12000000, decimals=3
結果は"12.000M", 0で埋める.
n=12461, decimals=1
結果は"12.5k", 標準的な丸め.
n=1024000000, base=1024, suffix='iB'
結果は'976MiB', 異なる基底と接尾辞の追加.
n=-150, base=100, powers['', 'd', 'D']
結果は'-1d', 負の数と下丸め.
n=-155, base=100, decimals=1, powers['', 'd', 'D']
結果は'-1.6d', 負の数と標準的な丸め.
n=255000000000, powers=['', 'k', 'M']
結果は'255000M', 十分なべきではない.

入力:整数として数値. 引数に基底, デフォルト1000. 引数にdecimal(小数点第n位), デフォルトは1000. 引数にべきリスト, デフォルトは['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'].
出力:変換された数値を文字列として.

備考
物理やITにおいて私たちは様々なたくさんの数を扱う. 時々私たちは読みやすさのためによりシンプルな表記を必要とする. あなたがギガバイトについて話す時, あなたはきっちりしたバイトやキロバイトを必要としない.

The square chest

Count the number of squares which can be possibly drawn in a grid.

On the chest keypad is a grid of numbered dots. The grid is comprised of a square shaped array of dots and contains lines that connect some pairs of adjacent dots. The answer to the code is the number of squares that are formed by these lines. For example, in the figure shown below, there are 3 squares: 2 small squares and 1 medium square.
The dots are marked by the numbers 1 through 16. The endpoints of the lines are represented by lists of two numbers.

Input: A list of lines as a list of list. Each list consists of the two integers.
Output: The quantity of squares formed as an integer.

How it is used:
This is a simple puzzle that illustrates pattern searching. For complex cases you can improve your program and use it to search for more complex patterns, shapes and objects.

数字が割り振られたドットのグリッドがある. グリッドは四角に配置されたドットと隣り合うドットのいくつかのペアとつながった線からなる. それらの線によって作られる四角形の数を求めるためのコードを書く. たとえば, 下の図を見ると, 3つの四角形, 2つの小さな四角形と1つの中型の四角形だ.
ドットは1から16までの数値で割り振られている. 線の終端は2つの数字のリストで表現される.

入力:リストのリストとして線のリスト. それぞれのリストは2つの整数からなる.
出力:四角形の数を整数で

備考
これは画像パターン探索のシンプルなゲームだ. 複雑なケースのためにあなたはプログラムを改良することができ, それをより複雑なパターン, 形状や物, を探索するために使うだろう.

Morse Clock

Morse clock task

Help Stephen to automate his task by creating a module. As you can see in above illustration, gray circle means on, and white circle means off. Every digit in the time string contains a different number of slots. The first digit for the hour has a length of 2 while the second digit for the hour has a length of 4. The first digits for the minute and second not have a length of 3 while the second digits for the minute and second have a length of 4. Every digit in the time is converted to binary representation. You will convert every on ( or 1 ) signal to dash ( - ) and every off ( or 0 ) signal to dot ( . )

Input: An unspecific time string ( could be hh:mm:ss or h:m:s or hh:m:ss format, with no specific format )
Output: A string of Morse symbol from binary representation with specific format: "h h : m m : s s"

where each digits represented as sequence of "." and "-"

How it is used:
Here you can learn about binary numbers and how to format strings.

ステファンの自動化タスクのためにモジュールを作る手助けをしよう. 上の図のように, 灰色の円はオンを意味し, 白の円はオフを意味する. 時間文字列の全ての桁はスロットの異なる数値を含む. 最初の桁は時の10の位で, 長さは2, 次の桁は時の1桁で, 長さは4. 分と秒の最初の桁は長さ3で, 次の桁の長さは4である. 時間のすべての桁はバイナリ表記に変換されている. あなたはそれぞれをオンならダッシュ(-), オフならドット(.)に変換する.

入力:時間を文字列で(hh:mm:ssかh:m:sかhh:m:ss形式)
出力:バイナリ表記のモールス信号の文字列, "h h : m m : s s"形式で

ここでそれぞれの桁は"."と"-"として表現される.

備考
あなたはここで二進数と文字列のフォーマットについて学ぶ.

Ore In The Desert

Our spaceship’s sensors have registered an ore in the region. Help the robots probe the region for precious metals.

During their adventure, the Robo-trio came across a desert, and the ships sensors have registered ore in the region. The desert has a size of 10x10 cells and can be represented as a 2D array. The ship has four probes which can be used to help us find the ore. At each step you will need to return the coordinates of a cell (as [row, column]) for the probe to travel to. If the cell contains ore, then you can finish; else the probe will give a distance to the location of the ore cell (it will be the Euclidean distance between cells' centers). The perception of probe is not very good and it will give you a result rounded to the closest integer (1.41 ≈ 1; 2.83 ≈ 3). At each step you receive information from the previous probes as a list of list. Each list will be in the following format: [row, column, distance]. At the beginning of the mission, you will only receive an empty list.

Input: Information of the previous probes as a list of lists.
Output: The coordinate of the next probe as a list of two integers.

How it is used:
This task illustrates trilateration. Trilateration is the process of determining absolute or relative locations of points by measurement of distances, using the geometry of circles, spheres or triangles. In addition to being an interesting geometric problem, trilateration does have practical applications in surveying and navigation and is an important part of the equations making global positioning systems (GPS) possible.

彼らの冒険の間, ロボトリオは砂漠を横切っていて, 領域内の鉱石を船のセンサーに登録していた. 砂漠は10x10サイズのセルで, 二次元の配列として表現される. 船は4つの私たちに鉱石を探させるために使われる探り針を持っている. それぞれのステップでそこに行くために, あなたは探し針のためにセルの座標を返す必要がある. セルが鉱石を含んでいたら, あなたは終了させることができる. 含んでいないなら探り針は鉱石セルの位置までの距離を与える(セルの中心同士のユークリッド距離). 探り針の認識はとてもよいわけではなく, それはあなたに丸めた近い整数を与える(1.41なら1, 2.83なら3). それぞれのステップであなたは前の探り針からリストのリストとして情報を受け取る. それぞれのリストは[行, 列, 距離]というフォーマットである. ミッションのはじめに, あなたは空のリストを受け取る.

入力:前の探り針の情報をリストのリストとして
出力:次の探り針の座標を2つの整数のリストで

備考
このタスクは三角測量の説明である. 三角測量は円か球体か三角の幾何学を用いて, 距離を測量することによって点の絶対または相対的位置を決定するためのプロセスである.

Calculate Islands

Help the robots calculate the landmass of their newly discovered island chain.

The Robots have found a chain of islands in the middle of the Ocean. They would like to explore these islands and have asked for your help calculating the areas of each island. They have given you a map of the territory. The map is a 2D array, where 0 is water, 1 is land. An island is a group of land cells surround by water. Cells are connected by their edges and corners. You should calculate the areas for each of the islands and return a list of sizes (quantity of cells) in ascending order. All of the cells outside the map are considered to be water.

Input: A map as a list of lists with 1 or 0.
Output: The sizes of island as a list of integers.

How it is used:
This task is an example of a disjoint-set data structure. Disjoint-set data structures model the partitioning of a set; for example, it helps with keeping track of the connected components in an undirected graph (networks).

ロボットは海の中央にある島の連鎖を見つけた. 彼らはこれらの島を発見したいのと, それぞれの島の面積を計算する手助けをあなたに聞いた. 彼らはあなたにテリトリーのマップを与える. マップは二次元の配列で, 0は水, 1は島である. 水に囲まれたセルが島のグループである. セルは端か角でつながる. あなたは島々の面積を計算し, 昇順にソートしたリストを返す. マップの外側は水とする.

入力:1か0で構成されるリストのリスト
出力:島のサイズを整数のリストで

備考
このタスクは素集合データ構造の例である. 素集合データ構造モデルは集合の分割, たとえば無向グラフ(ネットワーク)における要素の接続の経路を維持するのを助ける.

Digging a canal

Help the robots begin their colonization of the newly discovered island.

The robots are trying to colonize a new island. There are many rivers on this island and it would be good idea for them to use ships designed for water, rather than their spaceships. Some of the territories do not have a river for transportation from one edge of a field to another. The robots can dig a canal and convert the land to water if need be. We must explore a field map and count the minimum number of cells necessary for a canal that would allow the robots to sail from northern edge of the map to southern edge. The map is in a 2D array, where 0 is water, 1 is land. Cells are connected by their edges.

Input: A map as a list of lists with 1 or 0.
Output: The minimum number of cells necessary for a canal as an integer.

How it is used:
This concept is a mix of graph-search and optimization problems. It can be useful in navigational software and for network optimization.

ロボットは新しい島に入植を試みている. この島にはたくさん川があり, 宇宙船を使うよりも船を使うのに適した川がある. 地域の中のいくつかは, フィールドの端から他方に輸送するための川がない. ロボットは水路を掘ることができ, 必要なら陸地を水に変えることができる. 私たちはフィールドマップを探検し, ロボットがマップ北側からマップ南側まで船で通れるような水路に必要なセルの最小数を数えるべきだ. マップは2次元の配列で表され, 0は水, 1は島である. セルは各々の端でつながっている.

入力:1と0からなるリストのリストをマップとして
出力:水路に必要なセルの最小の数

備考
これはグラフ探索と最適化問題を組み合わせたものである. それはナビゲーションシステムやネットワーク最適化で使われる.
最終更新:2014年04月15日 16:57