Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

Commit 44a041a

Browse files
committed
Problems Description
1 parent 6fd2b88 commit 44a041a

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

.DS_Store

0 Bytes
Binary file not shown.

CA1/.DS_Store

0 Bytes
Binary file not shown.

CA1/DS_CA#1.pdf

442 KB
Binary file not shown.

CA1/Question1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ def find_gcd_max(n,k,bags,biggest_bag) :
3535
def main() :
3636
n,k,bags,biggest_bag = read_input()
3737
gcd_max = find_gcd_max(n,k,bags,biggest_bag)
38-
print(gcd_max)
38+
print(gcd_max)
39+
3940
main()

CA1/Question3.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" Calculates prime numbers from 1 to sqrt(n) """
1+
""" Calculating prime numbers from 1 to sqrt(n). You can uncomment this : """
22
# from itertools import compress
33
#n = 10**5
44
# def primes(n):
@@ -40,7 +40,7 @@ def factorization(n, primeslist):
4040
return pf
4141

4242
""" Returns an unsorted list of the divisors of n """
43-
def insert_divisors(n, primeslist, counter_dict):
43+
def insert_divisors(n, primeslist, counter_dict) :
4444
divs = [1]
4545
for p, e in factorization(n, primeslist):
4646
divs += [x*p**k for k in range(1,e+1) for x in divs]
@@ -53,16 +53,18 @@ def count_divisors(query, counter_dict):
5353
return 0
5454
return counter_dict[query]
5555

56-
i = 1
57-
counter_dict = {}
58-
max_lines = int(input())
59-
while i <= max_lines :
56+
def main() :
57+
i = 1
58+
counter_dict = {}
59+
max_lines = int(input())
60+
while i <= max_lines :
6061
a,b = input().split()
6162
a = int(a)
6263
b = int(b)
6364
if a == 1 :
6465
numbers_set = insert_divisors(b, primeslist, counter_dict)
65-
# print('counter_dict', counter_dict)
6666
else :
6767
print(count_divisors(b, counter_dict))
68-
i += 1
68+
i += 1
69+
70+
main()

0 commit comments

Comments
 (0)