Skip to content

Instantly share code, notes, and snippets.

View flymio's full-sized avatar

Roman Borisoglebskyi flymio

View GitHub Profile
<?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++;
}
<?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";
}
<?php
/*
* Complete the getTotalX function below.
*/
function getTotalX($a, $b) {
$f = lcm($a);
$l = gcd($b);
$count = 0;
<?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++;
<?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]);
<?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++;
#!/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;
<body>
<style>
body, html {
background: white;
}
.resizable {
background: transparent;
position: absolute;
}
<?
function lengthOfLongestSubstring($s) {
$a = str_split($s);
$max = '';
$cur = '';
$ch = '';
for($i=0;$i<sizeof($a);$i++){
$g = explode($a[$i],$cur);
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);