Skip to content

Instantly share code, notes, and snippets.

View KarthikMAM's full-sized avatar
💻
Coding

Karthik M A M KarthikMAM

💻
Coding
View GitHub Profile
@KarthikMAM
KarthikMAM / global.scss
Last active November 23, 2018 19:56
Flex Based Grids
html {
box-sizing: border-box;
}
*, *:after, *:before {
box-sizing: inherit;
}

Bash CheatSheet

Delete Merged Git Branches

git branch -vv | grep gone | awk '{print $1}' | tr "\n" " " | xargs git branch -d

Get Changed Files List

from functools import reduce
for _ in range(int(input())):
input()
print(reduce(lambda x, y: x ^ y, list(map(int, input().split()))))
m = {
'0': '_',
'1': '0',
'2': '1',
'3': '2',
'4': '3',
'5': '4',
'6': '5',
'7': '6',
'8': '7',
@KarthikMAM
KarthikMAM / gridcorpus.sh
Created March 28, 2017 08:13
Download the grid corpus dataset and extract it.
#preparing for download
mkdir "gridcorpus"
cd "gridcorpus"
mkdir "raw" "audio" "video"
cd "raw" && mkdir "audio" "video"
for i in `seq $1 $2`
do
printf "\n\n------------------------- Downloading $i th speaker -------------------------\n\n"
@KarthikMAM
KarthikMAM / Ring Rotate.py
Last active November 5, 2018 13:30
Algorithm to rotate an array 'n' times in the anti-clockwise direction
__author__ = "Karthik M A M"
#get the user input
x = [ input().split() for i in range(int(input().split()[0])) ]
c = int(input())
n, m = len(x), len(x[0])
#iterate over each ring
for l in range(min(n, m) // 2):
temp = x[l + 1: n - l - 1]
@KarthikMAM
KarthikMAM / FastPrime.py
Last active April 18, 2016 17:33
Finds the prime numbers faster by checking divisions by prime numbers only
#This algorithm will find the prime numbers
#faster than conventional methods
#by checking only the prime number divisiblity
prime = [2]
for i in range(2, int(input())):
l = int(i ** 0.5) + 1
for j in prime:
if j > l:
prime.append(i)
break
n = int(input()) + 1
x = { i for i in range(2, n) for j in range(2, int(i ** 0.5 + 1)) if i % j == 0 }
print([ i for i in range(2, n) if i not in x ])
@KarthikMAM
KarthikMAM / InfixToPostfix.py
Last active April 18, 2016 17:34
An algorithm to evaluate mathematical expressions by partial postfix conversion optimization
#precedance and the operation of each binary operator
prec = { "**": 3,
"*": 2,
"/": 2,
'%': 2,
"+": 1,
"-": 1,
"$": 0}
operFunc = {'+': lambda a, b: a + b,
'-': lambda a, b: a - b,