Skip to content

Instantly share code, notes, and snippets.

@katsube
Created November 3, 2022 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katsube/a5197800f2c2f5df394de713578bb781 to your computer and use it in GitHub Desktop.
Save katsube/a5197800f2c2f5df394de713578bb781 to your computer and use it in GitHub Desktop.
<?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