Skip to content

Instantly share code, notes, and snippets.

View rjshekar90's full-sized avatar

Raja Shekar rjshekar90

View GitHub Profile
import re
def fun(s):
return re.fullmatch(r'^[a-zA-Z0-9_\-]+[@]{1}[a-zA-Z0-9]+[.]{1}[a-zA-Z]{1,3}$', s)
fib = lambda n: fib(n-1)+fib(n-2) if n>1 else n
print(list(map(lambda x: x**3, [fib(n) for n in range(int(input().strip()))])))
import re
for i in range(int(raw_input())):
try:
if re.compile(raw_input()): print True
except:
print False
for _ in range(int(input())):
try:
a, b = map(int, input().split())
print(a//b)
except (ZeroDivisionError, ValueError) as e:
print("Error Code:", e)
from datetime import datetime
for _ in range(int(input())):
t1=datetime.strptime(input(),'%a %d %b %Y %H:%M:%S %z')
t2=datetime.strptime(input(),'%a %d %b %Y %H:%M:%S %z')
print (int(abs((t1-t2).total_seconds())))
import calendar
m,d,y = map(int, input().split())
print(calendar.day_name[calendar.weekday(y, m, d)].upper())
from itertools import combinations
b=int(input())
a=input().split()
c=int(input())
a=''.join(sorted(a))
a_count=0
for i in combinations(a,c):
if 'a' in i:a_count+=1
print ("%0.3f" %(a_count/len(list(combinations(a,c)))))
from itertools import product
k, m = map(int, input().split())
arrays = [list(map(int, input().split()[1:])) for _ in range(k)]
lst = []
for a in list(product(*arrays)):
lst.append(sum([b ** 2 for b in a]) % m)
print(max(lst))
from itertools import groupby
for k,g in groupby((raw_input()), int):
print (len(list(g)),k),
from itertools import combinations_with_replacement
S,K = raw_input().split()
print "\n".join("".join(i) for i in list(combinations_with_replacement(sorted(S),int(K))))