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 | |
/** | |
* Mehen games test | |
* | |
* @author sagittaracc <[email protected]> | |
*/ | |
// Массив имеет произвольные значения | |
$array = [-1, 2, 10, 3, -5, 3]; |
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 | |
require 'Point.php'; | |
require 'PointArray.php'; | |
require 'Rectangle.php'; | |
$points = new PointArray([ | |
[0, 0], [0, 1], [0, 2], [0, 3], | |
[1, 0], [1, 1], [1, 2], [1, 3], | |
[2, 0], [2, 1], [2, 2], [2, 3], |
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
var houses = [ | |
{ | |
bk: true, | |
mac: false, | |
kfc: false | |
}, | |
{ | |
bk: false, | |
mac: false, | |
kfc: false |
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
var vertexes = [[1], [2], [3]]; | |
var routes = [ | |
[[1], [2]], | |
[[2], [1]], | |
[[2], [3]], | |
[[3], [2]], | |
]; | |
/** |
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
function searchForPairsBySum(sortedArray, sum) { | |
var leftIndex = 0; | |
var rightIndex = sortedArray.length - 1 | |
while (leftIndex !== rightIndex) { | |
if (sortedArray[leftIndex] + sortedArray[rightIndex] === sum) { | |
console.log(sortedArray[leftIndex], sortedArray[rightIndex], "Indexes: ", leftIndex, rightIndex); | |
leftIndex++; | |
rightIndex++; | |
} |
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 | |
class LonelyNumberFilter { | |
private $numbers; | |
private $filtered = []; | |
function __construct($numbers) { | |
$this->numbers = $numbers; | |
} |
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 | |
function frand($min, $max, $decimals = 5) { | |
$scale = pow(10, $decimals); | |
return mt_rand($min * $scale, $max * $scale) / $scale; | |
} | |
function frand_by_sum($sum, $length = 2) { | |
$numbers = []; |
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
class Observer { | |
constructor (name) { | |
this.name = name | |
} | |
subscribe (event) { | |
event.addObserver(this) | |
} | |
notify (event) { |
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
/** | |
* Проверяет выход за границы матрицы при её обходе по рекам | |
* @param array matrix исходная матрица | |
* @param int line позиция по горизонтали в матрице | |
* @param int column позиция по вертикали в матрице | |
* @return boolean | |
*/ | |
function isOffMatrix(matrix, line, column) { | |
return line < 0 | |
|| column < 0 |
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 | |
/** | |
* Возвращает существительное в соответствующей форме по числительному | |
* @param int $number | |
* @param array $cases формы существительного | |
* При склонении по числительному существительное имеет три формы | |
* | |
* Пример: слово "программа" | |
* |