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 | |
function factorial_iterative($n) | |
{ | |
$k = 1; | |
for($i = $n; $i > 1; $i--) | |
{ | |
$k *= $i; | |
} | |
return $k; |
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 | |
/* | |
Sample expected output: | |
getPrimes(5); ⇒ array(2, 3) | |
getPrimes(10); ⇒ array(2, 3, 5, 7) | |
*/ | |
function getPrimes($n) | |
{ | |
if ($n <= 0) throw new InvalidArgumentException("positive integer required"); |
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 | |
function is_pair($open, $close) | |
{ | |
if($open == '(' && $close == ')') return true; | |
elseif($open == '{' && $close == '}') return true; | |
elseif($open == '[' && $close == ']') return true; | |
return false; | |
} | |
function balance($test) | |
{ |
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
Utility.send_exception_to_ga = function() | |
{ | |
if(true || window.settings && window.settings.debug) | |
{ | |
return; | |
} | |
var gOldOnError = window.onerror; | |
window.onerror = function(message, url, line) { | |
var e_obj = [ | |
"_trackEvent" |
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 | |
// Max Integer | |
define('MAX', 1000000); | |
// Create An Array Till MAX | |
$original = range(1, MAX); | |
// Shuffle The Array While Preserving Keys | |
$shuffle = $original; | |
shuffle_assoc($shuffle); |
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 | |
function wp_signon( $credentials = '', $secure_cookie = '' ) { | |
if ( empty($credentials) ) { | |
if ( ! empty($_POST['log']) ) | |
$credentials['user_login'] = $_POST['log']; | |
if ( ! empty($_POST['pwd']) ) | |
$credentials['user_password'] = $_POST['pwd']; | |
if ( ! empty($_POST['rememberme']) ) | |
$credentials['remember'] = $_POST['rememberme']; | |
} |
NewerOlder