Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: freeCodeCampDelhi/algorithms-in-python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: harrypotter0/algorithms-in-python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.

Commits on Jan 18, 2018

  1. Tree root

    harrypotter0 committed Jan 18, 2018
    Copy the full SHA
    bcfb4c7 View commit details
  2. # Problem 6

    harrypotter0 committed Jan 18, 2018
    Copy the full SHA
    ea0e3f1 View commit details
  3. problem 7 update

    harrypotter0 committed Jan 18, 2018
    Copy the full SHA
    856b331 View commit details

Commits on Jan 19, 2018

  1. Copy the full SHA
    91ee4fe View commit details
  2. Copy the full SHA
    93d1dd9 View commit details

Commits on Jan 20, 2018

  1. GST January SRM

    harrypotter0 committed Jan 20, 2018
    Copy the full SHA
    fbf050f View commit details
  2. Copy the full SHA
    2024e14 View commit details

Commits on Jan 21, 2018

  1. Kadane problem

    harrypotter0 committed Jan 21, 2018
    Copy the full SHA
    fc41ada View commit details
  2. partition problem

    harrypotter0 committed Jan 21, 2018
    Copy the full SHA
    49da372 View commit details
  3. keteki quick Match

    harrypotter0 committed Jan 21, 2018
    Copy the full SHA
    ed5563e View commit details
  4. DP # LCS

    harrypotter0 committed Jan 21, 2018
    Copy the full SHA
    602dd86 View commit details
  5. String Merging #JC2018

    harrypotter0 committed Jan 21, 2018
    Copy the full SHA
    9df1bac View commit details
  6. BFS Traversal Problem

    harrypotter0 committed Jan 21, 2018
    Copy the full SHA
    ba8a89c View commit details
  7. # Fix issue

    harrypotter0 committed Jan 21, 2018
    Copy the full SHA
    ad4eb51 View commit details

Commits on Jan 22, 2018

  1. January Cook Off 2018

    harrypotter0 committed Jan 22, 2018
    Copy the full SHA
    fbf0031 View commit details
  2. # Fix issue

    harrypotter0 committed Jan 22, 2018
    Copy the full SHA
    1bca110 View commit details
  3. # An update

    harrypotter0 committed Jan 22, 2018
    Copy the full SHA
    188751e View commit details
  4. # An update 5

    harrypotter0 committed Jan 22, 2018
    Copy the full SHA
    26e420f View commit details

Commits on Jan 23, 2018

  1. Binary Problem

    harrypotter0 committed Jan 23, 2018
    Copy the full SHA
    89779c8 View commit details

Commits on Jan 24, 2018

  1. Graph Based Problem 3

    harrypotter0 committed Jan 24, 2018
    Copy the full SHA
    74713f8 View commit details
  2. Trie ds problem

    harrypotter0 committed Jan 24, 2018
    Copy the full SHA
    1d147f5 View commit details
  3. MAGA Array Problem

    harrypotter0 committed Jan 24, 2018
    Copy the full SHA
    361b400 View commit details
  4. Copy the full SHA
    602e641 View commit details

Commits on Jan 27, 2018

  1. Problem 4 DSU fucked

    harrypotter0 committed Jan 27, 2018
    Copy the full SHA
    a3a254c View commit details

Commits on Jan 28, 2018

  1. Gwalior onsite

    harrypotter0 committed Jan 28, 2018
    Copy the full SHA
    570591f View commit details
  2. Copy the full SHA
    856b42b View commit details
  3. Readme update

    harrypotter0 committed Jan 28, 2018
    Copy the full SHA
    daeb80a View commit details
  4. Copy the full SHA
    07c0d4d View commit details

Commits on Feb 8, 2018

  1. Copy the full SHA
    35c4f16 View commit details

Commits on Feb 13, 2018

  1. Feb Challenge 2018

    harrypotter0 committed Feb 13, 2018
    Copy the full SHA
    7311e7f View commit details

Commits on Feb 14, 2018

  1. CP Season is Back

    harrypotter0 committed Feb 14, 2018
    Copy the full SHA
    ece5f55 View commit details
  2. # Problem 2

    harrypotter0 committed Feb 14, 2018
    Copy the full SHA
    42bcc80 View commit details

Commits on Feb 17, 2018

  1. Codemania

    harrypotter0 committed Feb 17, 2018
    Copy the full SHA
    4174431 View commit details
  2. Codemania

    harrypotter0 committed Feb 17, 2018
    Copy the full SHA
    3b90ba5 View commit details

Commits on Feb 18, 2018

  1. Codemania

    harrypotter0 committed Feb 18, 2018
    Copy the full SHA
    979b4b8 View commit details

Commits on Feb 19, 2018

  1. February Cook-Off 2018

    harrypotter0 committed Feb 19, 2018
    Copy the full SHA
    a078283 View commit details

Commits on Feb 20, 2018

  1. Keteki Power Match 2

    harrypotter0 committed Feb 20, 2018
    Copy the full SHA
    bd60a07 View commit details

Commits on Feb 22, 2018

  1. CSUBSEQ

    harrypotter0 committed Feb 22, 2018
    Copy the full SHA
    cb9f0dd View commit details

Commits on Feb 24, 2018

  1. Hackon Feb

    harrypotter0 committed Feb 24, 2018
    Copy the full SHA
    43e62d7 View commit details
  2. GST February SRM

    harrypotter0 committed Feb 24, 2018
    Copy the full SHA
    49be34e View commit details

Commits on Mar 9, 2018

  1. Hacktivate 2018

    harrypotter0 committed Mar 9, 2018
    Copy the full SHA
    0e9324f View commit details

Commits on Mar 11, 2018

  1. COUT-2K18

    harrypotter0 committed Mar 11, 2018
    Copy the full SHA
    aea869a View commit details
  2. Turing Cup Qualifier 2

    harrypotter0 committed Mar 11, 2018
    Copy the full SHA
    0f8a520 View commit details

Commits on Mar 12, 2018

  1. COUT-2K18

    harrypotter0 committed Mar 12, 2018
    Copy the full SHA
    4f4f6cf View commit details
  2. Keteki Quick Match 8

    harrypotter0 committed Mar 12, 2018
    Copy the full SHA
    3010074 View commit details

Commits on Mar 14, 2018

  1. March Challenge 2018

    harrypotter0 committed Mar 14, 2018
    Copy the full SHA
    9f9be25 View commit details

Commits on Mar 16, 2018

  1. Codenigma

    harrypotter0 committed Mar 16, 2018
    Copy the full SHA
    9d8ab08 View commit details

Commits on Jun 26, 2018

  1. Competitive added

    harrypotter0 committed Jun 26, 2018
    Copy the full SHA
    012c35f View commit details

Commits on Jul 17, 2018

  1. Update

    harrypotter0 committed Jul 17, 2018
    Copy the full SHA
    b37bf08 View commit details

Commits on Oct 11, 2018

  1. Guessing Game

    sakshamjn authored Oct 11, 2018
    Copy the full SHA
    5107d37 View commit details
Showing 1,505 changed files with 94,891 additions and 6,231 deletions.
58 changes: 58 additions & 0 deletions CP/ C Cubed/prob1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import math
import statistics
import itertools

def findsubsets(S,m):
return set(itertools.combinations(S, m))
def readInts():
return list(map(int, input().split()))
def readInt():
return int(input())

n = readInt()
a = []

for __ in range(n):
inp = readInt()
if(inp>=0):
a.append(inp)
n = len(a)
# print(a)

summ = 0

for i in range(1,len(a)+1):
s = []
if(i&1):
s = findsubsets(a,i)
s = list(s)
for j in range(len(s)):
med = statistics.median(s[j])
summ+=med
print(summ)


'''
4
0
1
3
2
9
6
-9
7
2
-2
3
2
0
1
4
1
2
2
-2
'''
59 changes: 59 additions & 0 deletions CP/ C Cubed/prob2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import math
from itertools import combinations

def readInts():
return list(map(int, input().split()))
def readInt():
return int(input())
def readIntsindex0():
return list(map(lambda x: int(x) - 1, input().split()))
def readStr():
return raw_input()
def euclid(x1,y1,x2,y2):
return math.sqrt(pow(x1-x2,2)+pow(y1-y2,2))
def manhat(x1,y1,x2,y2):
return abs(x1-x2)+abs(y1-y2)

n = readInt()
a = []
for i in range(n):
a.append(readInts())
# print(a)
ans =0
count =0
a = combinations(a, 2)
for i in list(a):
# print(i)
count+=1
# print(euclid(i[0][0],i[0][1],i[1][0],i[1][1]),manhat(i[0][0],i[0][1],i[1][0],i[1][1]))
if(euclid(i[0][0],i[0][1],i[1][0],i[1][1])==manhat(i[0][0],i[0][1],i[1][0],i[1][1])):
# print(i[0][0],i[0][1],i[1][0],i[1][1])
ans += 1
print(ans)


'''
Input:
3
1 1
7 5
1 5
Output:
3
Input:
6
0 0
0 1
0 2
-1 1
0 1
1 1
Output:
12
'''
File renamed without changes.
216 changes: 216 additions & 0 deletions CP/ Code-Golf/p1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
# /*
# *
# ********************************************************************************************
# * AUTHOR : AKASH KANDPAL *
# * Language : Python2 *
# * Motto : The master has failed more times than the beginner has even tried. *
# * IDE used: Atom *
# * My Domain : http://harrypotter.tech/ *
# ********************************************************************************************
# *
# */
from fractions import gcd
import math
import itertools
from itertools import permutations
from itertools import combinations
import calendar
from itertools import product
def readInts():
return list(map(int, raw_input().strip().split()))
def readInt():
return int(raw_input())
def readStrs():
return raw_input().split()
def readStr():
return raw_input().strip()
def readarr(n):
return [map(int,list(readStr())) for i in xrange(n)]
def readnumbertolist():
a=[int(i) for i in list(raw_input())]
return a
def strlistTostr(list1):
return ''.join(list1)
def numlistTostr(list1):
return ''.join(str(e) for e in list1)
def strTolist(str):
return str.split()
def strlistTointlist(str):
return map(int, str)
def slicenum(number,x):
return int(str(number)[:x])
def precise(num):
return "{0:.10f}".format(num)
def rsorted(a):
return sorted(a,reverse=True)
def binar(x):
return '{0:031b}'.format(x)
def findpermute(word):
perms = [''.join(p) for p in permutations(word)]
perms = list(set(perms))
return perms
def findsubsets(S,m):
return list(set(itertools.combinations(S, m)))
def sort1(yy,index):
return yy.sort(key = lambda x:x[index])
def reversepair(yy):
return yy[::-1]
def checkint(x):
return (x).is_integer()
def sum_digits(n):
s = 0
while n:
s += n % 10
n //= 10
return s
def vowel_count(str):
count = 0
vowel = set("aeiouAEIOU")
for alphabet in str:
if alphabet in vowel:
count = count + 1
return count
def leapyear(year):
return calendar.isleap(year)
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
def primes_sieve(limit):
limitn = limit+1
not_prime = set()
primes = []

for i in range(2, limitn):
if i in not_prime:
continue

for f in range(i*2, limitn, i):
not_prime.add(f)

primes.append(i)

return primes
def distinctstr(s):
t =''.join(set(s))
return t
def countdict(s):
d ={}
for i in range(len(s)):
if s[i] not in d.keys():
d[s[i]]=1
else:
d[s[i]]+=1
return d
import operator as op
def nck(n, k):
k = min(n-k,k)
result = 1
for i in range(1, k+1):
result = result* (n-i+1) / i
return result
def gcd(a,b):
while b > 0:
a, b = b, a % b
return a
def lcm(a, b):
return a * b / gcd(a, b)
def matrixcheck(x,y):
faadu = []
directions = zip((0,0,1,-1),(1,-1,0,0))
for dx,dy in directions:
if R>x+dx>=0<=y+dy<C and A[x+dx][y+dy]==0:
faadu.append((x+dx,y+dy))
return faadu
def stringcount(s):
return [s.count(i) for i in "abcdefghijklmnopqrstuvwxyz"]
def bubbleSort(arr):
n = len(arr)
for i in range(n):
for j in range(0, n-i-1):
if arr[j] > arr[j+1] :
arr[j], arr[j+1] = arr[j+1], arr[j]
def isSubsetSum(st, n, sm) :
# arr, n, k
subset=[[True] * (sm+1)] * (n+1)
for i in range(0, n+1) :
subset[i][0] = True
for i in range(1, sm + 1) :
subset[0][i] = False
for i in range(1, n+1) :
for j in range(1, sm+1) :
if(j < st[i-1]) :
subset[i][j] = subset[i-1][j]
if (j >= st[i-1]) :
subset[i][j] = subset[i-1][j] or subset[i - 1][j-st[i-1]]
return subset[n][sm];
def decimal_to_octal(dec):
decimal = int(dec)
return oct(decimal)
def decimal_to_binary(dec):
decimal = int(dec)
return bin(decimal)
def decimal_to_hexadecimal(dec):
decimal = int(dec)
return hex(decimal)
def find_duplicate(expr):
stack=[]
char_in_between = 0
f =1
for i in range(0, len(expr)):
if expr[i] == '}' or expr[i] == ')':
pair = '{' if expr[i] == '}' else '('
pop=''
while(len(stack) > 0 and pop != pair):
pop = stack.pop()
if (pop != '{' and pop != '('): char_in_between +=1
if char_in_between == 0:
print "Duplicate"
f =0
break
char_in_between = 0
else:
stack.append(expr[i])
return f
def dictlist(keys,values):
{d.setdefault(key,[]).append(value) for key, value in zip(keys,values)}
return d
def mullistbyconst(my_list,r):
my_new_list = []
for i in my_list:
my_new_list.append(i * r)
return my_new_list
def coinchange(S, m, n):
# (arr,length,sum)
table = [0 for k in range(n+1)]
table[0] = 1
for i in range(0,m):
for j in range(S[i],n+1):
table[j] += table[j-S[i]]
return table[n]

mod = 10 ** 9 + 7
# for i,j in product(xrange(R),xrange(C)):
# print "Case #{}: {}".format(i+1,ans)
p = primes_sieve(100000)
# for __ in range(readInt()):
l,r =readInts()
f = 0
for i in range(l,r+1):
if i in p:
f = 1
break
if f and str(i) == str(i)[::-1]:
print i
else:
print "-1"
'''
100
105
35
87
)101 2)-1
'''
Loading