### Aspects of building a chess game - Move Bishop level 1

Arrays
Data Types
Logic
Basic Language Features
Fundamentals
Strings

Write a function that takesĀ as a parameter a starting square as a string in formal chess notation and determines the valid squares that the bishop can move to in one move for an empty chess board (only bishop on the board). Must return an array of valid squares in ascending square order.

``````function moveBishop(\$startingSquare)
{
\$result = [];
\$letters = ["a" =>  1, "b" => 2, "c" => 3, "d" => 4, "e" => 5, "f" => 6, "g" => 7, "h" => 8];
\$startSqaureInDigits = \$letters[\$startingSquare[0]] . \$startingSquare[1];

// bishop movement is always two ways at the same time as it moves diagonally at least one space.
// loop over 8 by 8 chessboard
//i loop is for letters
//j loop is for numbers

for(\$i = 1; \$i <= 8; \$i++){
for(\$j=1; \$j <= 8; \$j++)
{
if (\$startSqaureInDigits != \$i.\$j &&  abs(\$startSqaureInDigits[0] - \$i) ==  abs(\$startSqaureInDigits[1] - \$j) )
{
\$result[] = array_search(\$i,\$letters).\$j;
}
}
}
return \$result;
}``````

### Hello Perl!

Strings
Data Types

Hello world! style application, Perl style.

``print "Hello Perl!\n";``