Skip to content

Instantly share code, notes, and snippets.

View iamshanto's full-sized avatar

Samiul Amin Shanto iamshanto

View GitHub Profile
<?php
class StringBalance {
private $startBrace = "(";
private $endBrace = ")";
public $debug = false;
private $startBraceFound;
private $endBraceFound;
@iamshanto
iamshanto / printPalindromes.php
Last active December 16, 2015 14:29
Find Palindrom from string
<?php
function printPalindromes($str)
{
#$str = strtolower(preg_replace("'\s+'", '', $str));
$str = strtolower(preg_replace("([^A-Za-z0-9])", "", $str));
$length = strlen($str);
$reverse = strrev($str);
$matches = array();
$palindrom = $str;
<?php
function printPalindromes($str)
{
#$str = strtolower(preg_replace("'\s+'", '', $str));
#$str = strtolower(preg_replace("([^A-Za-z0-9])", "", $str));
$palindrom = $str;
$str1 = strtolower($str);
$matches = array();
$str = $str1;
<?php
function getMirrorChar()
{
$data = array(
'A' => 'A',
'E' => '3',
'H' => 'H',
'I' => 'I',
'J' => 'L',
def max_devide(number, factor):
while(number % factor == 0):
number = number / factor
return number
def is_ugly(number):
number = max_devide(number, 2)
number = max_devide(number, 3)
number = max_devide(number, 5)
def max_devide(number, factor):
while(number % factor == 0):
number = number / factor
return number
def is_ugly(number):
number = max_devide(number, 2)
number = max_devide(number, 3)
number = max_devide(number, 5)
<?php
function bcfact($n){
$factorial=$n;
while (--$n > 1) {
$factorial = bcmul($factorial,$n);
}
return $factorial;
}
function getFileContent()
# Require python 2.6
import math
f = open('input.txt')
output = ''
for line in f:
value = math.factorial(int(line))
output += line.strip() + " -> " + str(value).replace("0", "")[-1]+"\n"
writeFile = open('output.txt', 'w+')
<?php
global $triangularNumberOffset, $divisors;
$triangularNumberOffset = 1;
$triangularNumber = 0;
function nextTriangularNumberOffset()
{
global $triangularNumberOffset;
return $triangularNumberOffset++;
@iamshanto
iamshanto / Cookie Helper
Last active December 30, 2015 18:29
A simple reformatted/reusable Cookie helper from W3School.