Skip to content

Instantly share code, notes, and snippets.

View HoangPV's full-sized avatar

Hoang Phan HoangPV

  • Ho Chi Minh City, Vietnam
View GitHub Profile
@HoangPV
HoangPV / max-words-of-sentences.php
Created July 30, 2017 21:50
return the max words of sentences, which is from a text
<?php
/**
* return the max words of sentences, which is from a text
*
* @param $s
* @return mixed
* @author Phan Vu Hoang <[email protected]>
*/
function solution($s)
@HoangPV
HoangPV / non-descending-order.php
Last active July 30, 2017 21:39
check whether an array can be turn to non-descending order by a single swap 2 elements
<?php
/**
* check whether an array can be turn to non-descending order by a single swap 2 elements
*
* @param array $a
* @return bool
* @author Phan Vu Hoang <[email protected]>
*/
function solution($a)
@HoangPV
HoangPV / contain_all_rots.php
Last active July 30, 2017 17:25
return a boolean true if all rotations of strng are included in arr (C returns 1
<?php
/**
* return a boolean true if all rotations of strng are included in arr (C returns 1)
*
* @param string $s
* @param array $arr
* @return boolean
* @author Phan Vu Hoang <[email protected]>
*/
<?php
/**
* You'll have to translate a string to Pilot's alphabet (NATO phonetic alphabet) wiki.
*
* @author Phan Vu Hoang <[email protected]>
*/
function to_nato($words) {
$lib['a']="Alpha";
@HoangPV
HoangPV / Factory.php
Created July 28, 2017 03:09
have the factory create the Automobile object
<?php
class Automobile
{
private $vehicleMake;
private $vehicleModel;
public function __construct($make, $model)
{
$this->vehicleMake = $make;
@HoangPV
HoangPV / backward_read_primes.php
Created July 27, 2017 23:40
return backward read primes
<?php
/**
* return backward read primes
*
* Find all Backwards Read Primes between two positive given numbers
* (both inclusive), the second one being greater than the first one.
* The resulting array or the resulting string will be ordered
* following the natural order of the prime numbers.
*
@HoangPV
HoangPV / reverse_letters_in_sentence.php
Created July 25, 2017 14:59
Take a string, then for every words we reverse the order of character.
<?php
echo strRevCha("Take a string, then for every words we reverse the order of character.");
/**
* Take a string, then for every words we reverse the order of character.
*
* @param String $str a string
* @return String|null $strOutput
* @author Phan Vu Hoang <[email protected]>