Skip to content

Instantly share code, notes, and snippets.

View iluxonchik's full-sized avatar
😉

Illya Gerasymchuk iluxonchik

😉
View GitHub Profile
@iluxonchik
iluxonchik / binaryGCDrecursive.php
Created April 23, 2014 20:15
Binary GCD implementation in php. Recursive version.
function gcd_recursive($a, $b){
/* computes and returns the greatest common divisor between a and b */
/*
* Binary GCD Algorithm, according to Wikipedia "binary GCD can be about 60%
* more efficient (in terms of the number of bit operations) on average than the Euclidean algorithm".
* More about the Binary GCD Algorithm: http://en.wikipedia.org/wiki/Binary_GCD_algorithm
* Java Implementation: http://introcs.cs.princeton.edu/java/23recursion/BinaryGCD.java.html
* C++ Implementation: https://gist.github.com/cslarsen/1635213
@iluxonchik
iluxonchik / binaryGCDiterative.php
Created April 23, 2014 20:14
Binary GCD algorithm php implementation. Iterative version.
function binary_gcd($a, $b){
/* computes and returns the greatest common divisor between a and b */
/*
* Binary GCD Algorithm, according to Wikipedia "binary GCD can be about 60%
* more efficient (in terms of the number of bit operations) on average than the Euclidean algorithm".
* More about the Binary GCD Algorithm: http://en.wikipedia.org/wiki/Binary_GCD_algorithm
* Java Implementation: http://introcs.cs.princeton.edu/java/23recursion/BinaryGCD.java.html
* C++ Implementation: https://gist.github.com/cslarsen/1635213
function get_User($url){
/*****************************************************************
* Retrieves the user from a paste
* -> This function is a bit hacky and doesn't have the best design
******************************************************************/
$str = file_get_contents($url);
if(strlen($str) > 0){
preg_match('/\<div class="paste_box_line2"\>(.*)\<\/div\>/', $str, $user);
$pieces = explode(' ', $user[1]);
if ($pieces[2]!='guest'){