This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 <sagittaracc@gmail.com> | |
| */ | |
| // Массив имеет произвольные значения | |
| $array = [-1, 2, 10, 3, -5, 3]; |
This file contains hidden or 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 'Map.php'; | |
| $map = new Map([ | |
| [1, 1, 0, 0, 0, 0, 0, 1], | |
| [0, 1, 0, 0, 1, 1, 1, 0], | |
| [1, 0, 1, 0, 0, 0, 0, 0], | |
| [1, 0, 0, 1, 1, 0, 1, 1], | |
| [0, 0, 1, 1, 1, 0, 0, 1], |
This file contains hidden or 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 translit_folder($folder) | |
| { | |
| $converter = array( | |
| 'а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', | |
| 'е' => 'e', 'ё' => 'e', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', | |
| 'й' => 'y', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', | |
| 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', | |
| 'у' => 'u', 'ф' => 'f', 'х' => 'h', 'ц' => 'c', 'ч' => 'ch', |
This file contains hidden or 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 | |
| $a = [0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1]; | |
| function sag_pack($a) { | |
| $sum = 0; | |
| foreach (array_reverse($a) as $index => $value) { | |
| $sum += $value * (1 << $index); | |
| } |