Skip to content

Instantly share code, notes, and snippets.

View Ram-Aditya's full-sized avatar
🎯
Focusing

Ram Aditya Ram-Aditya

🎯
Focusing
View GitHub Profile
def solution(l,k):
t_sum=0
max_subArrInd=0
for i in range(k):
t_sum+=l[i]
max_sum=t_sum
for i in range(1,len(l)-k+1):
t_sum=t_sum-l[i-1]+l[i+k-1]
if(t_sum>max_sum):
max_sum=t_sum
@Ram-Aditya
Ram-Aditya / w4p1.py
Last active June 7, 2018 07:58
Week-4 CodeBuddy
def mergeArray(a,b):
m=len(b)
n = len(a)-m
for i in range(n//2):
a[i], a[n-1-i] = a[n-1-i], a[i]
k=len(a)-1
i=n-1
j=0
while(i>=0 and j<m):
if(a[i]<b[j]):
@Ram-Aditya
Ram-Aditya / w5p1.py
Last active June 12, 2018 23:18
CodeBuddy Week5
a=input().split()
k=int(input())
for i in range(len(a)):
a[i]=int(a[i])
#a=[-5,-30,20,17,14,-7,-4,-9,11,20,23,42,-38,39,32,-8,-22,-50,-37]
ans=[]
a.sort()
tmin=[10000,-1,-1,-1]
for t in range(len(a)):
i=0
@Ram-Aditya
Ram-Aditya / w6p1.py
Created June 20, 2018 13:35
Week-6 Codebuddy
def getVal(rom):
if (rom=="I"):
return 1
elif (rom=="V"):
return 5
elif (rom=="X"):
return 10
elif (rom=="L"):
return 50
elif (rom=="C"):
@Ram-Aditya
Ram-Aditya / w7p1.py
Last active June 26, 2018 23:42
Week 7 Codebuddy
def checkSubst(integVal):
integVal2=integVal
flag=1
while(integVal>1):
if(integVal%4!=0):
flag=0
break
integVal/=4
if(flag): return True
while(integVal2>1):
@Ram-Aditya
Ram-Aditya / caeser_cipher.py
Created October 18, 2018 16:41
Crypto Mentorship: Caesar Cipher
# To run the file: python3 file_name method_flag (either 1:brute force or 2:frequency analysis)
import sys
cipher=open("cipher.txt","r")
lines=[]
for line in cipher:
lines.append(line)
if(int(sys.argv[1])==1):
#Try shifting and printing
while(True):