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 / 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;
<?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:
@arsho
arsho / Basic_bar_chart_matplotlib.py
Created September 20, 2016 18:06
Basic bar chart using matplotlib
import matplotlib.pyplot as plt
year = [2000,2001,2002,2003]
popu = [1.00,1.50,2.00,2.50]
y_pos = range(len(year))
plt.bar(y_pos,popu,label='Population',color='g', align='center')
plt.xticks(y_pos, year)
plt.legend()
plt.xlabel('year')
plt.ylabel('population')
plt.show()
@arsho
arsho / integer_number_validation.js
Created October 26, 2016 11:30
validation of integer number
// validation for ranging number
$('.subject_mark').on("keyup", function () {
this.value = this.value.replace(/[^0-9]/g, '');
var input_value = parseFloat(this.value);
if (isNaN(input_value)===true) {
$(this).val("0");
} else {
var max_value = parseFloat($(this).attr('max'));
if (input_value > max_value) {
$(this).val(max_value);