Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
<?php

var_dump(isOrthogonal([1, 2], [2, -1]))."\n";
var_dump(isOrthogonal([3, -1], [7, 5]))."\n";
var_dump(isOrthogonal([1, 2, 0], [2, -1, 10]))."\n";

function isOrthogonal($arr1, $arr2) {
	$prod = 0;
	$count = count($arr1);
	for ($i = 0; $i < $count; $i++) {
		$prod += $arr1[$i]*$arr2[$i];
	}
	return $prod == 0? true:false;
}
/*
//JS solution:
function isOrthogonal(ar1, arr2){
	let prod=0;
	let count=arr1.length;
	for (i=0; i<count; i++){
		prod+=arr1[i]*arr2[i];
	}
	return prod==0? true; false;
}
*/
by ვაჟა ტყემალაძე
1 year ago
0
PHP
Problem Solving
Note
php
Problem
0
<?php

echo discount(5000, 35)."\n";
echo discount(2000, 50)."\n";
echo discount(1070, 10)."\n"; 
echo discount(670, 3)."\n";

function discount($price, $discount){
	return $price-$price/100*$discount;
}
by ვაჟა ტყემალაძე
1 year ago
0
PHP
Problem Solving
0
echo bcsqrt('2', 4)."\n"; //1.4142

$return=bcsqrt("81");
echo $return."\n";//კვ.ფესვი 9

//გამოკლება
$a='3.45';
$b='4';
echo bcsub($a,$b)."\n";
echo bcsub($a,$b, 6)."\n";
by ვაჟა ტყემალაძე
1 year ago
0
PHP
PHP official doc
0
<?php

echo romanToInt('III')."\n";
echo romanToInt('LVIII')."\n";
echo romanToInt('MCMXCIV')."\n";
/* Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 */ // Converts the roman numeral to an integer
function romanToInt($roman) {
    $res = $next = 0;
// Letters with their value
 $numbers = ['I'=>1, 'V'=>5, 'X'=>10, 'L'=>50, 'C'=>100, 'D'=>500, 'M'=>1000];

    $len = strlen($roman);
// Loops through letters
for ($i = $len-1; $i >= 0; $i--) {

        $num = $numbers[$roman[$i]];
// Subtracts if the left side letter is less
if ($num < $next) {
            $res -= $num;
        } else {
            $res += $num;
        }
        $next = $num;
    }
    return $res;
}
by ვაჟა ტყემალაძე
1 year ago
0
Problem Solving
php
0
Finding item of the array which is represented more than once
<?php

var_dump(containsDuplicate([1,1,2,5,3]));
var_dump(containsduplicate([2,7,7,6,9,0,0]));
var_dump(containsDuplicate([1,4,5,0,7]));
//Using array_count_values
function containsDuplicate($array){
	$counted=array_count_values($array);
	return max($counted)>1;
}
//Using foreach loop
function containsDuplicate_2($array){
	$values=[];
	
	foreach ($array as $item){
		if (array_count_values($array)>1){
			return true;
		}
	}
	return false;
}
//both works well !!
by ვაჟა ტყემალაძე
1 year ago
0
Problem Solving
php
0
<?php

echo strangeCounter(4)."\n";
echo strangeCounter(10)."\n";
echo strangeCounter(21)."\n";

function strangeCounter($t){
	$scnt=3;
// Loops until $scnt is less than $t+2
while ($t+2>=$scnt){
		$scnt*=2;
	}
	// The sum of the number pairs inside the block is 
    // always the same. The sum is less by 2 than 2*$scnt
    return $scnt-$t-2; 
}
by ვაჟა ტყემალაძე
1 year ago
0
Problem Solving
0

var_dump(water("435f")); //result - true
var_dump(water("2c")); //result - false


function water ( $temp ) {
      $x = [ 'c'>=100, 'f'>=212 ];
      
      $y = substr ( $temp, -1 );
     
      $temp = substr_replace ( $temp, " ", -1 );
    
      $z = $temp >= $x[$y];
  
 return $z;    

by Gvanca Gharibashvili
1 year ago
0
PHP
0
Undo changes
დააბრუნებს ცვლილებას, რომელიც განვახორციელეთ ფაილში commit ბრძანებამდე ერთი ფაილისთვის:
git restore <file name>
ყველა ფაილისთვის
git restore .
by Guram Azarashvili
1 year ago
0
Git
Commands
Get started
Git/Github Tutorial
0
find
You can easiely find all repositories you have created, by this command, in git bash, your local computer:
find . -name ".git"
by Guram Azarashvili
1 year ago
0
Git
Commands
0
დაწერეთ ფუნქცია, რომელიც ასახავს ფაილებს მათ გაფართოების სახელებთან-გვეუბნება ჩვენი ამოცანა. ამოცანის ამოხსნის დროს შეგვხვდება:
1)substr- მაგ: echo substr("Hello world",6); გადათვლის 6-ს და მე-7 ადგილიდან რაც იწყება დაგვიბეჭდავს მხოლოდ მაგ სიტყვას, ჩვენ შემთხვევაში-(world)
2)strpos- ამოწმებს რომელ პოზიციაზეა ჩვენს მიერ მითითებული ნებისმიერი რამ- მაგ: echo strpos("hello,world", ",")- მოძებნის სადაც მძიმეა და მძიმის შემდეგ რა სიტყვაც დარჩება დაგვიბეჭდავს იმ სიტყვას, ჩვენ შემთხვევაში- (world)
we have 2 way.

echo file ( file.name );
echo file_2 (there.is.no.file );

1) function file ( $filename ) {
                $x = strpos ( $filename, "." );
                $y = substr ( $filename, $x + 1 );
           
         return $y;
     } 
result- "name"

2) function file_2 ( $filename ) {
                  $x = explode ( ".", $filename );
                  $y = end ($x); //end- დაბეჭდავს ბოლო სიტყვას 
         
          return $y;
      }
result- "file"
by Gvanca Gharibashvili
1 year ago
0
PHP
0
Results: 1578