Skip to content

Instantly share code, notes, and snippets.

View arsho's full-sized avatar

Ahmedur Rahman Shovon arsho

View GitHub Profile
@arsho
arsho / diff_two_arrays.js
Created August 7, 2015 03:16
diff two arrays of freecodecamp
function diff(arr1, arr2) {
var newArr = [];
for(var i=0;i<arr1.length;i++){
var check=1;
for(j=0;j<arr2.length;j++){
if(arr1[i]===arr2[j])
check=0;
}
if(check===1)
newArr.push(arr1[i]);
@arsho
arsho / LightOJ 1006 - Hex-a-bonacci.cpp
Created September 5, 2015 05:00
LightOJ 1006 - Hex-a-bonacci
/*
Problem : LightOJ 1006 - Hex-a-bonacci
Link : http://www.lightoj.com/volume_showproblem.php?problem=1006
Author : arsho
Date : 05/09/2015
Source : C++
CPU : 0.008
Memory : 1688
*/
#include <bits/stdc++.h>
@arsho
arsho / SNR_IMPROVEMENT.m
Created September 8, 2015 14:08
Proving SNR Improvement by averaging
% Title : Demonstration of SNR improvement by averaging
% Date : 7/9/2015
% Author : Shovon
clc;
image_object=ones(200,300,3); % (height, width)
image_size_ar=size(image_object);
image_height=image_size_ar(1);
image_width=image_size_ar(2);
@arsho
arsho / LightOJ 1006 - Hex-a-bonacci.java
Created October 22, 2015 19:59
1006 - Hex-a-bonacci LIghtOJ
/*
SUBMISSION TIME : 2015-10-23 01:53:21
USER : Ahmedur Rahman Shovon
PROBLEM : 1006 - Hex-a-bonacci
SOURCE : JAVA
CPU : 0.320
MEMORY : 24100
VERDICT : Accepted
*/
import java.util.Scanner;
@arsho
arsho / Solution.java
Created October 27, 2015 13:02
HackerRank 2D array
package Java2DArray;
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
<?php
$_fp = fopen("php://stdin", "r");
while($line=fgets($_fp)){
$line = strtolower($line);
$line_length = strlen($line);
$char_ar=array();
for ($i=0;$i<$line_length;$i++){
$current_char = $line[$i];
if(preg_match('/^[a-z]$/',$current_char)){
$char_ar[$current_char] = 1;
@arsho
arsho / DigitChecking.py
Last active August 30, 2016 13:57
Function to return the number of matched position of two same length number using recursion. Bonus: Digit Sum Using recursion. (Used Python 3.5)
def digit_checking(a,b):
x = a%10
y = b%10
check_match = 0
if x == y:
check_match=1
a = a//10
b = b//10
if (a == 0) or (b == 0):
return check_match
function sumAll(arr) {
var min = Math.min(arr[0] , arr[1]);
var max = Math.max(arr[0] , arr[1]);
var sum = 0;
for(var i=min ; i<=max ; i++) {
sum+=i;
}
return sum;
}
@arsho
arsho / PDO_Example.php
Last active September 1, 2016 18:53
Insert and Select operation using PDO
<?php
$server_name = 'localhost';
$db_username = 'DB_USERNAME';
$db_password = 'DB_PASSWORD';
$db_name = 'DB_NAME';
try{
$conn = new PDO("mysql:host=$server_name;dbname=$db_name",$db_username,$db_password);
$conn -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@arsho
arsho / TaxCalculator.py
Created September 3, 2016 15:01
Tax calculator as a practice of Online course.
def calculate_tax(income_dict):
tax_dict = dict()
for person_name in income_dict.keys():
person_income = income_dict[person_name]
person_tax = 0
income_limit = [1000,10000,20200,30750,50000]
income_range = [1000,9000,10200,10550,19250]
tax_range = [0,.1,.15,.2,.25]
for i in range(len(income_range)):
if person_income <= 0: