Skip to content
Slovenské elektrárne
z=[]
for i in range (2000, 3201):
if i%7 and not i%5:
z = z + [i]
print(z)
def overlapping(A, B):
for i in A:
for j in B:
if i == j:
return True
return False
# exercise
A = [1, 3, 5, 17, 9]
B = [0, 23, 34, 56, 7, 89]
overlapping(A, B)def histogram(A):
for i in range(len(A)):
print('*' * A[i])
# exercise
A = [1, 3, 5, 17, 9]
histogram(A)def solution(A):
# Implement your solution here
pass
if not A:
return None, None
max_val=max(A)+1
num_set = set(A)
missing_val=1
while missing_val in num_set:
missing_val +=1
print(missing_val)
for num in num_set:
if num > max_val:
max_val=num
if max_val > missing_val:
return max_val
else: return max_val
# Exercise
A = [-1, -3]
solution(A)def solution(A):
# Create a set from the list A to remove duplicates and for O(1) lookups
num_set = set(A)
# Start checking from the smallest positive integer
smallest_positive = 1
# Increment smallest_positive until we find a number not in num_set
while smallest_positive in num_set:
smallest_positive += 1
return smallest_positive
# Example usage
A1 = [1, 3, 6, 4, 1, 2]
A2 = [1, 2, 3]
A3 = [-1, -3]
solution(A1) # Should return 5
solution(A2) # Should return 4
solution(A3) # Should return 1