Results: 1578
Notes
  • Newest first
  • Oldest first
  • Newest first(All)
  • Oldest first(All)
RPS
echo rps("Rock", "Paper")."\n";
echo rps("Scissor", "Paper")."\n";
echo rps("Paper", "Paper")."\n";

function rps($p1, $p2){
	$res= "";
	if ($p1==$p2){
		$res="It's a draw";
	}else if (
		($p1=="Paper" && $p2=="Rock")||
		($p1=="Rock" && $p2=="Scissor")||
		($p1=="Scissor" && $p2=="Paper")
		){
			$res="Player 1 wins";
		}else {
			$res="Player 2 wins";
		}
		return $res;
}
by ვაჟა ტყემალაძე
2 years ago
0
PHP
Problem Solving
Note
php
Problem
0
/*
// a number "n" is automorphic if n^2 ends with "n"
e.g. 5 is automorphic number, because 5^2=25 ends with 5, 6^2=36 and is automorphic as well;
*/

echo "5 - ".isAutomorphic_2(5)."\n";    // 25
echo "8 - ".isAutomorphic_2(8)."\n";    // 64
echo "76 - ".isAutomorphic_2(76)."\n";  // 5,776

function isAutomorphic($num){
	$square=$num*$num;
	
	$result=str_ends_with($square, $num);
	return $result;
}


//using substring function
function isAutomorphic_2($num){
	return substr($num*$num, -1*strlen($num)) === strval($num);
}
by ვაჟა ტყემალაძე
2 years ago
0
PHP
Problem Solving
Note
php
Problem
0
echo validatePIN("1234")."\n";
echo validatePIN("12345")."\n";
echo validatePIN("123456")."\n"; 
echo validatePIN("")."\n";

function validatePIN($pin){
	$len=strlen($pin);
	if (strlen($pin)!=4 && strlen($pin)!=6){
		return "PIN is invalid";
	}
	for ($i=0; $i<$len; $i++)
	$ASCII=ord($pin[$i]);
	if (!(47<$ASCII && $ASCII<58)){
		return "PIN is invalid";
	}
	return "PIN is valid";
}
by ვაჟა ტყემალაძე
2 years ago
0
PHP
Problem Solving
Note
php
Problem
0
git status
git status
` checks basic informations about repository and file directories
by ვაჟა ტყემალაძე
2 years ago
0
Git
Git Tutorial - Learn Command-line Git & GitHub
0
git init
git init
initializes new empty file directory
by ვაჟა ტყემალაძე
2 years ago
0
Git
Git Tutorial - Learn Command-line Git & GitHub
0
Untracked files
Is in red keys
by ვაჟა ტყემალაძე
2 years ago
0
Git
note
Git Tutorial - Learn Command-line Git & GitHub
0
git log
git log
checks if there are some commits
Author: User's name<User's.e-mai@example.com>
by ვაჟა ტყემალაძე
2 years ago
0
Git
note
Git Tutorial - Learn Command-line Git & GitHub
0
changes to be commited
if file is changes, in green keys
by ვაჟა ტყემალაძე
2 years ago
0
Git
note
Git Tutorial - Learn Command-line Git & GitHub
0
git add
command that adds file in directory
by ვაჟა ტყემალაძე
2 years ago
0
Git
note
Git Tutorial - Learn Command-line Git & GitHub
0
git commit -m <file name>
git commit -m <file name>
makes changes in file repository
-m
means new change commit It's command for each new commit
by ვაჟა ტყემალაძე
2 years ago
0
Git
Git Tutorial - Learn Command-line Git & GitHub
0
Results: 1578