Skip to content

Commit d4995f7

Browse files
committed
Optimized Problems added
1 parent ece64bd commit d4995f7

File tree

3 files changed

+78
-12
lines changed

3 files changed

+78
-12
lines changed

infosys_2.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,31 @@
1515
res = reduce(ior, c)
1616
temp.append(sum(c)/res)
1717
print(math.floor(max(temp)*10000))
18+
19+
20+
import math
21+
from itertools import combinations
22+
23+
24+
# def solution(A):
25+
# m = math.floor(0)
26+
# i = len(A)
27+
# while i >= 0:
28+
# subarrayslist = set(combinations(A, i))
29+
# for array in subarrayslist:
30+
# if array:
31+
# S = sum(array)
32+
# R = array[0]
33+
# for a in range(1, len(array)):
34+
# R = R | array[a]
35+
# beauty = math.floor((S / R)*10000)
36+
# if m < beauty:
37+
# m = beauty
38+
# i -= 1
39+
# print(m)
40+
41+
42+
# A = []
43+
# for _ in range(int(input())):
44+
# A.append(int(input()))
45+
# solution(A)

infosys_3.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
# import itertools
2-
# n = str(1001)
3-
# c =0
4-
# li = []
5-
# for pair in itertools.combinations([c for c in range(1,9)],2):
6-
# # if sum(pair)<=int(n,2):
7-
# # c+=1
8-
# # li.append(pair)
9-
# print(pair)
10-
# print(len(li))
11-
12-
131
from itertools import product
142
intt = int(input())
153
n=input()
@@ -19,3 +7,24 @@
197
res = list(product(*temp))
208
k = sum(r[0]+r[1]==r[0]^r[1] for r in res)
219
print("{}".format(k%((10**9)+7)))
10+
11+
12+
13+
# from itertools import combinations
14+
# def solution(N, S):
15+
# DecimalofS = int(S, 2)
16+
# elements = [i for i in range(1, DecimalofS + 1)]
17+
# pairs = set()
18+
# for i in elements:
19+
# for j in elements:
20+
# pairs.add((i, j))
21+
# count = 0
22+
# for pair in pairs:
23+
# if pair[0] + pair[1] == pair[0] ^ pair[1]:
24+
# count += 1
25+
# print(count)
26+
27+
28+
# N = int(input())
29+
# S = input()
30+
# solution(N, S)

permute_arry.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import random
2+
def twoArrays(k, A, B):
3+
A.sort()
4+
B.sort(reverse=True)
5+
if (any(a+b<k for a,b in zip(A,B))):
6+
return "NO"
7+
else:
8+
return "YES"
9+
10+
A =[84 ,2 ,50 ,51 ,19, 58, 12 ,90 ,81 ,68 ,54 ,73 ,81 ,31 ,79 ,85 ,39 ,2]
11+
B =[53 ,102, 40 ,17 ,33 ,92 ,18 ,79 ,66 ,23 ,84 ,25 ,38 ,43, 27, 55, 8, 19]
12+
K =94
13+
14+
print(twoArrays(K,A,B))
15+
16+
17+
# def twoArrays(k, A, B):
18+
# flg2=0
19+
# for _ in range(500):
20+
# for c in range(len(A)):
21+
# if A[c]+B[c]>=k:
22+
# continue
23+
# flg2=1
24+
# break
25+
# if flg2==0:
26+
# return "YES"
27+
# flg2=0
28+
# random.shuffle(A)
29+
# return "NO"

0 commit comments

Comments
 (0)