paizaラーニングレベルアップ問題集の「3Dプリンタ」をSTS分割(?)っぽくやってみた

paiza×Qiita記事投稿キャンペーンということで、paizaラーニングレベルアップ問題集の[3Dプリンタ](https://paiza.jp/works/mondai/b_rank_skillcheck_archive/3d_printer)をSTS分割っぽくやってみました。対象は[コードモンスター大図鑑](https://paiza.jp/code_monster)で対応している9言語です。
- - -
###### 方針
Source（源泉）
- 整数$X$（立体の奥行き）、$Y$（立体の横幅）、$Z$（立体の高さ）を受け取る
- $k=1,2,...,Z$について
	- $i=1,2,...,X$について
		- 文字列$S_{k,i}=c_{k,i,1}c_{k,i,2}\dots c_{k,i,Y}$を受け取る
	- `--`を読み捨てる

Transform（変換）
- $k=1,2,...,Z$について、文字列$T_k$の$j$文字目（$1\le j\le Y$）を
	- `'#'` $\text{if }c_{k,i,j}=$`'#'` $\text{for }\exists i\in[1,X]$
	- `'.'` $\text{if }c_{k,i,j}=$`'.'` $\text{for }\forall i\in[1,X]$

	とする。

Sink（吸収）
- $k=Z,Z-1,...,2,1$について
	- 文字列$T_k$を改行区切りで出力する
- - -
###### PHP
```php
<?php
	/* Source */
	[$X, $Y, $Z] = explode(" ", fgets(STDIN));
	$S = [];
	for ($k = 0; $k < $Z; $k++) {
		$S[] = [];
		for ($i = 0; $i < $X; $i++) {
			$S[$k][] = fgets(STDIN);
		}
		$bar = fgets(STDIN);
	}
	
	/* Transform */
	$T = [];
	for ($k = 0; $k < $Z; $k++) {
		$T[] = "";
		for ($j = 0; $j < $Y; $j++) {
			$c = ".";
			for ($i = 0; $i < $X; $i++) {
				if ($S[$k][$i][$j] == "#") {
					$c = "#";
					break;
				}
			}
			$T[$k] .= $c;
		}
	}
	
	/* Sink */
	for ($k = $Z - 1; $k >= 0; $k--) {
		echo $T[$k]."\n";
	}
?>
```
- - -
###### Ruby
```rb
# Source
X, Y, Z = gets.split.map(&:to_i)
S = []
Z.times do |k|
	S << []
	X.times do
		S[k] << gets.chomp
	end
	bar = gets
end

# Transform
T = []
Z.times do |k|
	T << ""
	Y.times do |j|
		T[k] += X.times.any?{|i| S[k][i][j] == "#"} ? "#" : "."
	end
end	 

# Sink
(Z - 1).downto(0) do |k|
	puts T[k]
end
```
- - -
###### Java	
```java
import java.util.*;

public class Main {
	public static void main(String[] args) {
		/* Source */
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int Z = sc.nextInt();
		String[][] S = new String[Z][];
		for (int k = 0; k < Z; k++) {
			S[k] = new String[X];
			for (int i = 0; i < X; i++) {
				S[k][i] = sc.next();
			}
			String bar = sc.next();
		}
		sc.close();

		/* Transform */
		String[] T = new String[Z];
		for (int k = 0; k < Z; k++) {
			T[k] = "";
			for (int j = 0; j < Y; j++) {
				char c = '.';
				for (int i = 0; i < X; i++) {
					if (S[k][i].charAt(j) == '#') {
						c = '#';
						break;
					}
				}
				T[k] += c;
			}
		}

		/* Sink */
		for (int k = Z - 1; k >= 0; k--) {
			System.out.println(T[k]);
		}
	}
}
```
- - -
###### Python
```py
# Source
X, Y, Z = map(int, input().split())
S = []
for k in range(Z):
	S.append([])
	for i in range(X):
		S[k].append(input())
	bar = input()

# Transform
T = []
for k in range(Z):
	T.append("")
	for j in range(Y):
		T[k] += "#" if any(S[k][i][j] == "#" for i in range(X)) else "."

# Sink
for k in range(Z - 1, -1, -1):
	print(T[k])
```
- - -
###### C言語
```c
#include <stdio.h>

int main(void) {
	/* Source */
	int X, Y, Z;
	scanf("%d %d %d", &X, &Y, &Z);
	char S[Z][X][Y + 1];
	for (int k = 0; k < Z; k++) {
		for (int i = 0; i < X; i++) {
			scanf("%s", S[k][i]);
		}
		char bar[3];
		scanf("%s", bar);
	}

	/* Transform */
	char T[Z][Y + 1];
	for (int k = 0; k < Z; k++) {
		for (int j = 0; j < Y; j++) {
			T[k][j] = '.';
			for (int i = 0; i < X; i++) {
				if (S[k][i][j] == '#') {
					T[k][j] = '#';
					break;
				}
			}
		}
		T[k][Y] = '\0';
	}

	/* Sink */
	for (int k = Z - 1; k >= 0; k--) {
		puts(T[k]);
	}
	return 0;
}
```
- - -
###### C#
```cs
using System;

class Program
{
	static void Main()
	{
		/* Source */
		int[] XYZ = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
		int X = XYZ[0];
		int Y = XYZ[1];
		int Z = XYZ[2];
		string[][] S = new string[Z][];
		for (int k = 0; k < Z; k++) {
			S[k] = new string[X];
			for (int i = 0; i < X; i++) {
				S[k][i] = Console.ReadLine();
			}
			Console.ReadLine();
		}
		
		/* Transform */
		string[] T = new string[Z];
		for (int k = 0; k < Z; k++) {
			T[k] = "";
			for (int j = 0; j < Y; j++) {
				char c = '.';
				for (int i = 0; i < X; i++) {
					if (S[k][i][j] == '#') {
						c = '#';
						break;
					}
				}
				T[k] += c;
			}
		}

		/* Sink */
		for (int k = Z - 1; k >= 0; k--) {
			Console.WriteLine(T[k]);
		}
	}
}
```
- - -
###### Javascript
```js
lines = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

/* Sink */
row = 0;
const [X, Y, Z] = lines[row++].split(" ");

const S = [];
for (var k = 0; k < Z; k++) {
	S.push([]);
	for (var i = 0; i < X; i++) {
		S[k].push(lines[row++]);
	}
	row++;
}

let T = [];
for (var k = 0; k < Z; k++) {
	T.push("");
	for (var j = 0; j < Y; j++) {
		let c = ".";
		for (var i = 0; i < X; i++) {
			if (S[k][i][j] == "#") {
				c = "#";
				break;
			}
		}
		T[k] += c;
	}
}

for (var k = Z - 1; k >= 0; k--) {
	console.log(T[k]);
}
```

- - -
###### C++
```cpp
#include <iostream>
#include <vector>
using namespace std;

int main(void){
	/* Source */
	int X, Y, Z;
	cin >> X >> Y >> Z;
	vector<vector<string>> S(Z, vector<string>(X));
	for (int k = 0; k < Z; k++) {
		for (int i = 0; i < X; i++) {
			cin >> S[k][i];
		}
		string bar;
		cin >> bar;
	}

	/* Transform */
	vector<string> T(Z);
	for (int k = 0; k < Z; k++) {
		for (int j = 0; j < Y; j++) {
			char c = '.';
			for (int i = 0; i < X; i++) {
				if (S[k][i][j] == '#') {
					c = '#';
					break;
				}
			}
			T[k] += c;
		}
	}

	/* Sink */
	for (int k = Z - 1; k >= 0; k--) {
		cout << T[k] << endl;
	}
	return 0;
}
```
- - -
###### Kotlin
```kotlin
import java.util.*;

fun main() {
	/* Source */
	val sc = Scanner(System.`in`);
	val X = sc.nextInt();
	val Y = sc.nextInt();
	val Z = sc.nextInt();
	val S = Array(Z) { Array(X) { "" } }
	for (k in 0 until Z) {
		for (i in 0 until X) {
			S[k][i] = sc.next();
		}
		sc.next();
	}
	sc.close();

	/* Transform */
	val T = Array(Z) { "" }
	for (k in 0 until Z) {
		for (j in 0 until Y) {
			var c = '.';
			for (i in 0 until X) {
				if (S[k][i][j] == '#') {
					c = '#';
					break;
				}
			}
			T[k] = T[k] + c;
		}
	}

	/* Sink */
	for (k in Z - 1 downTo 0) {
		println(T[k]);
	}
}
```