Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ab2ca54

Browse files
added more codes
1 parent b35119a commit ab2ca54

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

‎Day 7/common-elements.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
a1 = set(map(int, input('Enter the first array: ').split()))
2+
a2 = set(map(int, input('Enter the second array: ').split()))
3+
4+
commons = a1 & a2 # intersection
5+
print(commons)
6+
7+
not_commons = a1 ^ a2 # symetric difference
8+
print(not_commons)

‎Day 7/missing.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
l = list(map(int, input().split()))
2+
n = len(l) + 1
3+
4+
xor = n
5+
for i in range(1, n):
6+
xor ^= i ^ l[i-1]
7+
8+
print(xor)
9+
10+
xor = n
11+
for i, v in enumerate(l, 1):
12+
xor ^= v ^ i
13+
14+
print(xor)

‎Day 7/pallindrome-substrings.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
s1 = input('Enter the string: ')
2+
n = int(input('Enter a number: '))
3+
4+
def isPalin(s1):
5+
return s1[::-1] == s1
6+
7+
for i in range(0, len(s1) - n + 1):
8+
if(isPalin(s1[i:i+n])):
9+
print(s1[i:i+n])

‎Day 7/ugly-numbers.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
def is_ugly(n):
2+
i = 2
3+
while n != 1:
4+
while n % i == 0:
5+
if i > 5:
6+
return False
7+
n //= i
8+
else:
9+
i += 1
10+
return True
11+
12+
13+
n = int(input('Enter n: '))
14+
i, j = 0, 1
15+
16+
while i != n:
17+
if is_ugly(j):
18+
# print(j)
19+
i += 1
20+
j += 1
21+
22+
print(j - 1)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /