1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

今回は、こちらのプログラミングゲームの解答コードを投稿しよう!の公式イベントの記事になります。

具体的には、paizaの新作プログラミングゲーム「電脳少女プログラミング2088 ─壊レタ君を再構築─」の
「ギャングのアジト」
という問題をPowerShell 5.1で解いてみたいと思います。

問題

答え



# 入力例
$N = [int]::Parse((Read-Host "Enter the size").Trim())
$b = @()
for ($i = 0; $i -lt $N; $i++) {
	$row = (Read-Host "Enter row $($i + 1)").Trim().Split(" ") | ForEach-Object { [int]$_ }
	$b += ,@($row)
}

function IsSymmetric($pixels) {
	for ($i = 0; $i -lt $pixels.Length; $i++) {
		for ($j = 0; $j -lt [math]::Floor($pixels.Length / 2); $j++) {
			if ($pixels[$i][$j] -ne $pixels[$i][$pixel_art.Length - $j - 1]) {
				return $false
			}
		}
	}
	return $true
}

# 判定
if (IsSymmetric $b) {
	Write-Output "Yes"
} else {
	Write-Output "No"
}


最初に入力値を受け取ります。PowerShellの場合、この時点で疲れます。

image.png

シンメトリックの判定はループを回して判定しています。
PaizaのスキルチェックのBランクだそうですが、ちょっと簡単ですね、Cランク相当だと思います。

最後に

このようなイベントをPowerShellでやる人は珍しいと思います。
PowerShellに興味を持った方は応援してね

下のリンク先でも記事を書いています

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?