Created
November 3, 2022 07:46
-
-
Save katsube/a5197800f2c2f5df394de713578bb781 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
// テトリス盤 | |
// 0:空白 1:ブロック | |
$TETRIS_BOARD = [ | |
[0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 0], | |
[0, 0, 0, 0, 0, 1], | |
[0, 0, 1, 0, 0, 1], | |
[0, 1, 1, 0, 0, 1], | |
[1, 1, 1, 1, 1, 1], | |
[1, 1, 1, 0, 1, 1] | |
]; | |
// 消せるラインがあるかチェック | |
if( isVanishable($TETRIS_BOARD) ){ | |
echo "消せる!\n"; | |
} | |
else{ | |
echo "消せない!\n"; | |
} | |
/** | |
* 消せるラインがあるかチェック | |
*/ | |
function isVanishable($board){ | |
// ★ここを回答する★ | |
} | |
/** | |
* 配列の合計値を計算する | |
*/ | |
function arraySum($arr){ | |
$total = 0; | |
for($i=0; $i<count($arr); $i++){ | |
$total += $arr[$i]; | |
} | |
return($total); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment