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 | |
// Complete the countApplesAndOranges function below. | |
function countApplesAndOranges($s, $t, $a, $b, $apples, $oranges) { | |
$ap = 0; $or = 0; | |
foreach($apples as $c){ | |
$g = $a+$c; | |
if ($g >= $s && $g <=$t){ | |
$ap++; | |
} |
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 | |
// Complete the kangaroo function below. | |
function kangaroo($x1, $v1, $x2, $v2) { | |
$xc1=$x1; $xc2=$x2; | |
for($i=$x1;$i<$x2;$i++){ | |
$xc1+=$v1; | |
$xc2+=$v2; | |
if ($xc1==$xc2) return "YES"; | |
} |
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 | |
/* | |
* Complete the getTotalX function below. | |
*/ | |
function getTotalX($a, $b) { | |
$f = lcm($a); | |
$l = gcd($b); | |
$count = 0; |
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 | |
// Complete the breakingRecords function below. | |
function breakingRecords($scores) { | |
$max = $scores[0]; $min = $scores[0]; | |
$max_count=0; | |
$min_count=0; | |
foreach($scores as $value){ | |
if ($value>$max){ | |
$max=$value; $max_count++; |
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 | |
// Complete the sockMerchant function below. | |
function sockMerchant($n, $ar) { | |
$arnew = array(); | |
$cnt=0; | |
foreach($ar as $val){ | |
if (isset($arnew[$val])){ | |
$cnt++; | |
unset($arnew[$val]); |
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 | |
// Complete the birthday function below. | |
function birthday($s, $d, $m) { | |
$tot = 0; | |
for($i=0;$i<=sizeof($s)-1;$i++){ | |
$cnt=1;$sum=$s[$i];$ok=0; | |
for($j=$i+1;$j<=sizeof($s)-1;$j++) | |
{ | |
$cnt++; |
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
#!/usr/bin/perl | |
use Data::Dumper; | |
use strict; | |
use warnings; | |
# Complete the divisibleSumPairs function below. | |
sub divisibleSumPairs { | |
my $n = shift; | |
my $k = shift; | |
my $ar = shift; |
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 lengthOfLongestSubstring($s) { | |
$a = str_split($s); | |
$max = ''; | |
$cur = ''; | |
$ch = ''; | |
for($i=0;$i<sizeof($a);$i++){ | |
$g = explode($a[$i],$cur); |
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
sep = Brackets.templateLiteral; | |
// склонение числительных | |
function declOfNum(number, titles) { | |
cases = [2, 0, 1, 1, 1, 2]; | |
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ]; | |
} | |
// всякая херня типа расчета суммы заказа (товары+доставка) и пр. - макросы | |
Brackets.addFilter('priceQ', function (price, quantity) { | |
return (parseFloat(price) * parseFloat(quantity)).toFixed(2); |