common_id
stringlengths 5
5
| image
stringlengths 24
24
| code
stringlengths 43
914
|
---|---|---|
11480 | Validation/png/11480.png | # Write a function to remove all the words with k length in the given string.
def remove_length(test_str, K):
temp = test_str.split()
res = [ele for ele in temp if len(ele) != K]
res = " ".join(res)
return res
|
11649 | Validation/png/11649.png | # Write a function to count the elements in a list until an element is a tuple.
def count_elim(num):
count_elim = 0
for n in num:
if isinstance(n, tuple):
break
count_elim += 1
return count_elim
|
11860 | Validation/png/11860.png | def fun178(string, char):
length = len(string)
index = -1
for i in range(length-1, -1, -1):
ch = string[i]
if ch == char:
index = i
return index
|
11502 | Validation/png/11502.png | # Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.
import re
def text_starta_endb(text):
patterns = "a.*?b$"
if re.search(patterns, text):
return "Found a match!"
else:
return "Not matched!"
|
11302 | Validation/png/11302.png | # Write a function to find the difference of first even and odd number of a given list.
def diff_even_odd(list1):
first_even = next((el for el in list1 if el % 2 == 0), -1)
first_odd = next((el for el in list1 if el % 2 != 0), -1)
return first_even - first_odd
|
11337 | Validation/png/11337.png | # Write a python function to find even numbers from a mixed list.
def Split(list):
ev_li = []
for i in list:
if i % 2 == 0:
ev_li.append(i)
return ev_li
|
11780 | Validation/png/11780.png | def fun98(a, b, k):
sum = 0
i = a
while i <= b:
if i % k == 0:
sum = sum + i
i = i + 1
return sum |
11859 | Validation/png/11859.png | def fun177(string, char):
length = len(string)
count = 0
i = 0
while i < length:
ch = string[i]
if ch == char:
count = count + 1
i = i + 1
if count > 0:
return 'Present'
else:
return 'Not Present' |
11652 | Validation/png/11652.png | # Write a function to separate and print the numbers and their position of a given string.
import re
def num_position(text):
for m in re.finditer("\d+", text):
return m.start()
|
11368 | Validation/png/11368.png | # Write a python function to choose points from two ranges such that no point lies in both the ranges.
def find_Points(l1, r1, l2, r2):
x = min(l1, l2) if (l1 != l2) else -1
y = max(r1, r2) if (r1 != r2) else -1
return (x, y)
|
11585 | Validation/png/11585.png | # Write a python function to sort the given string.
def sort_String(str):
str = "".join(sorted(str))
return str
|
11618 | Validation/png/11618.png | # Write a function to validate a gregorian date.
import datetime
def check_date(m, d, y):
try:
m, d, y = map(int, (m, d, y))
datetime.date(y, m, d)
return True
except ValueError:
return False
|
11817 | Validation/png/11817.png | def fun135(N):
sum = 0
for i in range(1, N+1):
sum = sum + i * i * i
return sum |
11605 | Validation/png/11605.png | # Write a python function to check whether the word is present in a given sentence or not.
def is_Word_Present(sentence, word):
s = sentence.split(" ")
for i in s:
if i == word:
return True
return False
|
11420 | Validation/png/11420.png | # Write a function to remove duplicates from a list of lists.
import itertools
def remove_duplicate(list1):
list.sort(list1)
remove_duplicate = list(list1 for list1, _ in itertools.groupby(list1))
return remove_duplicate
|
11296 | Validation/png/11296.png | # Write a python function to find the difference between largest and smallest value in a given array.
def big_diff(nums):
diff = max(nums) - min(nums)
return diff
|
11757 | Validation/png/11757.png | def fun75(N):
pro = 1
i = 1
while i <= N:
pro = pro * i
i = i + 1
return pro |
11688 | Validation/png/11688.png | def fun6(celcius):
fahrenheit = 9 / 5 * celcius + 32
return fahrenheit |
11295 | Validation/png/11295.png | # Write a function to convert a list to a tuple.
def list_tuple(listx):
tuplex = tuple(listx)
return tuplex
|
11598 | Validation/png/11598.png | # Write a python function to find the index of an extra element present in one sorted array.
def find_Extra(arr1, arr2, n):
for i in range(0, n):
if arr1[i] != arr2[i]:
return i
return n
|
11630 | Validation/png/11630.png | # Write a function to find a pair with the highest product from a given array of integers.
def max_product(arr):
arr_len = len(arr)
if arr_len < 2:
return None
x = arr[0]
y = arr[1]
for i in range(0, arr_len):
for j in range(i + 1, arr_len):
if arr[i] * arr[j] > x * y:
x = arr[i]
y = arr[j]
return x, y
|
11874 | Validation/png/11874.png | def fun192(string):
length = len(string)
count = 0
i = 0
while i < length:
ascii = ord(string[i])
if (ascii >= 65 and ascii <= 90) or (ascii >= 97 and ascii <= 122):
count = count + 1
i = i + 1
if count > 0:
return 'Present'
else:
return 'Not Present' |
11687 | Validation/png/11687.png | def fun5(fahrenheit):
celcius = 5 / 9 * (fahrenheit - 32)
return celcius |
11743 | Validation/png/11743.png | def fun61(weight, height):
bmi = weight / (height ** 2)
if bmi >= 30:
return 'Obesity'
elif bmi >= 24.9:
return 'Overweight'
elif bmi >= 18.5:
return 'Healthy'
else:
return 'Underweight' |
11832 | Validation/png/11832.png | def fun150(num):
count = 0
for i in range(1, num+1):
if num % i == 0:
count = count + 1
return count
|
11883 | Validation/png/11883.png | def fun201(num1, num2):
hcf = 0
limit = min(num1, num2)
i = 1
while i <= limit:
if num1 % i == 0 and num2 % i == 0:
hcf = i
i = i + 1
lcm = num1 * num2 / hcf
return lcm
|
11351 | Validation/png/11351.png | # Write a function that matches a word containing 'z', not at the start or end of the word.
import re
def text_match_wordz_middle(text):
patterns = "\Bz\B"
if re.search(patterns, text):
return "Found a match!"
else:
return "Not matched!"
|
11881 | Validation/png/11881.png | def fun199(string):
length = len(string)
new = ''
for i in range(length):
ascii = ord(string[i])
if ascii >= 48 and ascii <= 57:
new = new + string[i]
return new |
11444 | Validation/png/11444.png | # Write a function to locate the left insertion point for a specified value in sorted order.
import bisect
def left_insertion(a, x):
i = bisect.bisect_left(a, x)
return i
|
11750 | Validation/png/11750.png | def fun68(ch):
ascii = ord(ch)
if (ascii >= 65 and ascii <= 90) or (ascii >= 97 and ascii <= 122) or (ascii >= 48 and ascii <= 57):
return 'Not a Special Character'
else:
return 'Special Character' |
11631 | Validation/png/11631.png | # Write a function to find the length of the shortest string that has both str1 and str2 as subsequences.
def super_seq(X, Y, m, n):
if not m:
return n
if not n:
return m
if X[m - 1] == Y[n - 1]:
return 1 + super_seq(X, Y, m - 1, n - 1)
return 1 + min(super_seq(X, Y, m - 1, n), super_seq(X, Y, m, n - 1))
|
11593 | Validation/png/11593.png | # Write a python function to check whether the two given strings are isomorphic to each other or not.
def is_Isomorphic(str1, str2):
dict_str1 = {}
dict_str2 = {}
for i, value in enumerate(str1):
dict_str1[value] = dict_str1.get(value, []) + [i]
for j, value in enumerate(str2):
dict_str2[value] = dict_str2.get(value, []) + [j]
if sorted(dict_str1.values()) == sorted(dict_str2.values()):
return True
else:
return False
|
11718 | Validation/png/11718.png | def fun36(timeperiod):
frequency = 1 / timeperiod
return frequency |
11877 | Validation/png/11877.png | def fun195(string):
length = len(string)
new = ''
for i in range(length):
ascii = ord(string[i])
if ascii >= 65 and ascii <= 90:
new = new + string[i]
return new |
11348 | Validation/png/11348.png | # Write a function to remove the parenthesis area in a string.
import re
def remove_parenthesis(items):
for item in items:
return re.sub(r" ?\([^)]+\)", "", item)
|
11475 | Validation/png/11475.png | # Write a python function to count the number of pairs whose sum is equal to ‘sum’.
def get_Pairs_Count(arr, n, sum):
count = 0
for i in range(0, n):
for j in range(i + 1, n):
if arr[i] + arr[j] == sum:
count += 1
return count
|
11356 | Validation/png/11356.png | # Write a function to exchange the position of every n-th value with (n+1)th value and (n+1)th value with n-th value in a given list.
from itertools import zip_longest, chain, tee
def exchange_elements(lst):
lst1, lst2 = tee(iter(lst), 2)
return list(chain.from_iterable(zip_longest(lst[1::2], lst[::2])))
|
11879 | Validation/png/11879.png | def fun197(string):
length = len(string)
new = ''
for i in range(length):
ascii = ord(string[i])
if ascii >= 97 and ascii <= 122:
new = new + string[i]
return new |
11374 | Validation/png/11374.png | # Write a function to count occurrence of a character in a string.
def count_char(string, char):
count = 0
for i in range(len(string)):
if string[i] == char:
count = count + 1
return count
|
11588 | Validation/png/11588.png | # Write a python function to find number of solutions in quadratic equation.
def Check_Solution(a, b, c):
if ((b * b) - (4 * a * c)) > 0:
return "2 solutions"
elif ((b * b) - (4 * a * c)) == 0:
return "1 solution"
else:
return "No solutions"
|
11360 | Validation/png/11360.png | # Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column.
def matrix_to_list(test_list):
temp = [ele for sub in test_list for ele in sub]
res = list(zip(*temp))
return str(res)
|
11309 | Validation/png/11309.png | # Write a function to find the longest chain which can be formed from the given set of pairs.
class Pair(object):
def __init__(self, a, b):
self.a = a
self.b = b
def max_chain_length(arr, n):
max = 0
mcl = [1 for i in range(n)]
for i in range(1, n):
for j in range(0, i):
if arr[i].a > arr[j].b and mcl[i] < mcl[j] + 1:
mcl[i] = mcl[j] + 1
for i in range(n):
if max < mcl[i]:
max = mcl[i]
return max
|
11580 | Validation/png/11580.png | # Write a function to check if a nested list is a subset of another nested list.
def check_subset(list1, list2):
return all(map(list1.__contains__, list2))
|
11767 | Validation/png/11767.png | def fun85(num):
t = 1
nums = num
while num != 0:
t = t * 10
num = num // 10
t = t // 10
mdigit = nums // t
return mdigit |
11479 | Validation/png/11479.png | # Write a function to check if the given expression is balanced or not.
from collections import deque
def check_expression(exp):
if len(exp) & 1:
return False
stack = deque()
for ch in exp:
if ch == "(" or ch == "{" or ch == "[":
stack.append(ch)
if ch == ")" or ch == "}" or ch == "]":
if not stack:
return False
top = stack.pop()
if (top == "(" and ch != ")") or (
top == "{" and ch != "}" or (top == "[" and ch != "]")
):
return False
return not stack
|
11366 | Validation/png/11366.png | # Write a function to find the item with maximum occurrences in a given list.
def max_occurrences(list1):
max_val = 0
result = list1[0]
for i in list1:
occu = list1.count(i)
if occu > max_val:
max_val = occu
result = i
return result
|
11554 | Validation/png/11554.png | # Write a function to find the minimum number of platforms required for a railway/bus station.
def find_platform(arr, dep, n):
arr.sort()
dep.sort()
plat_needed = 1
result = 1
i = 1
j = 0
while i < n and j < n:
if arr[i] <= dep[j]:
plat_needed += 1
i += 1
elif arr[i] > dep[j]:
plat_needed -= 1
j += 1
if plat_needed > result:
result = plat_needed
return result
|
11396 | Validation/png/11396.png | # Write a function to get the length of a complex number.
import cmath
def len_complex(a, b):
cn = complex(a, b)
length = abs(cn)
return length
|
11308 | Validation/png/11308.png | # Write a python function to check whether the given number is even or not using bitwise operator.
def is_Even(n):
if n ^ 1 == n + 1:
return True
else:
return False
|
11293 | Validation/png/11293.png | # Write a function to find the n - expensive price items from a given dataset using heap queue algorithm.
import heapq
def expensive_items(items, n):
expensive_items = heapq.nlargest(n, items, key=lambda s: s["price"])
return expensive_items
|
11379 | Validation/png/11379.png | # Write a python function to set the right most unset bit.
import math
def get_Pos_Of_Right_most_Set_Bit(n):
return int(math.log2(n & -n) + 1)
def set_Right_most_Unset_Bit(n):
if n == 0:
return 1
if (n & (n + 1)) == 0:
return n
pos = get_Pos_Of_Right_most_Set_Bit(~n)
return (1 << (pos - 1)) | n
|
11694 | Validation/png/11694.png | def fun12(side):
perimeter = 6 * side
return perimeter |
11576 | Validation/png/11576.png | # Write a python function to find the length of the last word in a given string.
def length_Of_Last_Word(a):
l = 0
x = a.strip()
for i in range(len(x)):
if x[i] == " ":
l = 0
else:
l += 1
return l
|
11508 | Validation/png/11508.png | # Write a function to remove all whitespaces from a string.
import re
def remove_all_spaces(text):
return re.sub(r"\s+", "", text)
|
11601 | Validation/png/11601.png | # Write a python function to get the last element of each sublist.
def Extract(lst):
return [item[-1] for item in lst]
|
11634 | Validation/png/11634.png | # Write a function to find n-th rencontres number.
def binomial_coeffi(n, k):
if k == 0 or k == n:
return 1
return binomial_coeffi(n - 1, k - 1) + binomial_coeffi(n - 1, k)
def rencontres_number(n, m):
if n == 0 and m == 0:
return 1
if n == 1 and m == 0:
return 0
if m == 0:
return (n - 1) * (rencontres_number(n - 1, 0) + rencontres_number(n - 2, 0))
return binomial_coeffi(n, m) * rencontres_number(n - m, 0)
|
11646 | Validation/png/11646.png | # Write a function to find three closest elements from three sorted arrays.
import sys
def find_closet(A, B, C, p, q, r):
diff = sys.maxsize
res_i = 0
res_j = 0
res_k = 0
i = 0
j = 0
k = 0
while i < p and j < q and k < r:
minimum = min(A[i], min(B[j], C[k]))
maximum = max(A[i], max(B[j], C[k]))
if maximum - minimum < diff:
res_i = i
res_j = j
res_k = k
diff = maximum - minimum
if diff == 0:
break
if A[i] == minimum:
i = i + 1
elif B[j] == minimum:
j = j + 1
else:
k = k + 1
return A[res_i], B[res_j], C[res_k]
|
11882 | Validation/png/11882.png | def fun200(string):
length = len(string)
new = ''
i = 0
while i < length:
ascii = ord(string[i])
if ascii >= 48 and ascii <= 57:
new = new + string[i]
i = i + 1
return new |
11577 | Validation/png/11577.png | # Write a function to remove sublists from a given list of lists, which are outside a given range.
def remove_list_range(list1, leftrange, rigthrange):
result = [i for i in list1 if (min(i) >= leftrange and max(i) <= rigthrange)]
return result
|
11809 | Validation/png/11809.png | def fun127(N, k):
term = 1
for i in range(1, N):
term = 1 / i * k
return term |
11489 | Validation/png/11489.png | # Write a python function to check whether the count of divisors is even or odd.
import math
def count_Divisors(n):
count = 0
for i in range(1, (int)(math.sqrt(n)) + 2):
if n % i == 0:
if n // i == i:
count = count + 1
else:
count = count + 2
if count % 2 == 0:
return "Even"
else:
return "Odd"
|
11455 | Validation/png/11455.png | # Write a function to find the longest common subsequence for the given three string sequence.
def lcs_of_three(X, Y, Z, m, n, o):
L = [[[0 for i in range(o + 1)] for j in range(n + 1)] for k in range(m + 1)]
for i in range(m + 1):
for j in range(n + 1):
for k in range(o + 1):
if i == 0 or j == 0 or k == 0:
L[i][j][k] = 0
elif X[i - 1] == Y[j - 1] and X[i - 1] == Z[k - 1]:
L[i][j][k] = L[i - 1][j - 1][k - 1] + 1
else:
L[i][j][k] = max(
max(L[i - 1][j][k], L[i][j - 1][k]), L[i][j][k - 1]
)
return L[m][n][o]
|
11534 | Validation/png/11534.png | # Write a python function to find the type of triangle from the given sides.
def check_Type_Of_Triangle(a, b, c):
sqa = pow(a, 2)
sqb = pow(b, 2)
sqc = pow(c, 2)
if sqa == sqa + sqb or sqb == sqa + sqc or sqc == sqa + sqb:
return "Right-angled Triangle"
elif sqa > sqc + sqb or sqb > sqa + sqc or sqc > sqa + sqb:
return "Obtuse-angled Triangle"
else:
return "Acute-angled Triangle"
|
11586 | Validation/png/11586.png | # Write a function to check if the given tuple contains only k elements.
def check_tuples(test_tuple, K):
res = all(ele in K for ele in test_tuple)
return res
|
11353 | Validation/png/11353.png | # Write a function to find the product of it’s kth index in the given tuples.
def get_product(val):
res = 1
for ele in val:
res *= ele
return res
def find_k_product(test_list, K):
res = get_product([sub[K] for sub in test_list])
return res
|
11779 | Validation/png/11779.png | def fun97(a, b, k):
sum = 0
for i in range(a, b+1):
if i % k == 0:
sum = sum + i
return sum |
11619 | Validation/png/11619.png | # Write a function to compute maximum product of three numbers of a given array of integers using heap queue algorithm.
def maximum_product(nums):
import heapq
a, b = heapq.nlargest(3, nums), heapq.nsmallest(2, nums)
return max(a[0] * a[1] * a[2], a[0] * b[0] * b[1])
|
11848 | Validation/png/11848.png | def fun166(string):
length = len(string)
count = 0
for i in range(length):
ascii = ord(string[i])
if ascii == 32:
count = count + 1
count = count + 1
return count |
11737 | Validation/png/11737.png | def fun55(choice, P, R, T):
if choice == 1:
A = P * ((1 + R / 100) ** T)
I = A - P
else:
I = P * R * T / 100
return I
|
11756 | Validation/png/11756.png | def fun74(N):
pro = 1
for i in range(1, N+1):
pro = pro * i
return pro |
11443 | Validation/png/11443.png | # Write a python function to toggle bits of the number except the first and the last bit.
def set_middle_bits(n):
n |= n >> 1
n |= n >> 2
n |= n >> 4
n |= n >> 8
n |= n >> 16
return (n >> 1) ^ 1
def toggle_middle_bits(n):
if n == 1:
return 1
return n ^ set_middle_bits(n)
|
11411 | Validation/png/11411.png | # Write a function to check whether the given key is present in the dictionary or not.
def is_key_present(d, x):
if x in d:
return True
else:
return False
|
11393 | Validation/png/11393.png | # Write a python function to find sum of prime numbers between 1 to n.
def sum_Of_Primes(n):
prime = [True] * (n + 1)
p = 2
while p * p <= n:
if prime[p] == True:
i = p * 2
while i <= n:
prime[i] = False
i += p
p += 1
sum = 0
for i in range(2, n + 1):
if prime[i]:
sum += i
return sum
|
11837 | Validation/png/11837.png | def fun155(string):
length = len(string)
new = ''
i = 0
while i < length:
ch = ord(string[i])
if ch >= 97 and ch <= 122:
new = new + chr(ch - 32)
else:
new = new + chr(ch)
i = i + 1
return new |
11656 | Validation/png/11656.png | # Write a function to get an item of a tuple.
def get_item(tup1, index):
item = tup1[index]
return item
|
11647 | Validation/png/11647.png | # Write a function to sort a list of dictionaries using lambda function.
def sorted_models(models):
sorted_models = sorted(models, key=lambda x: x["color"])
return sorted_models
|
11853 | Validation/png/11853.png | def fun171(string):
length = len(string)
count = 0
i = 0
while i < length:
ch = string[i]
if ch == 'a' or ch == 'e' or ch == 'i' or ch == 'o' or ch == 'u':
count = count + 1
i = i + 1
count = length - count
return count |
11563 | Validation/png/11563.png | # Write a python function to check for even parity of a given number.
def check_Even_Parity(x):
parity = 0
while x != 0:
x = x & (x - 1)
parity += 1
if parity % 2 == 0:
return True
else:
return False
|
11712 | Validation/png/11712.png | def fun30(ms):
kmhr = ms * 18 / 5
return kmhr |
11639 | Validation/png/11639.png | # Write a function to calculate the sum of series 1³+2³+3³+….+n³.
import math
def sum_series(number):
total = 0
total = math.pow((number * (number + 1)) / 2, 2)
return total
|
11747 | Validation/png/11747.png | def fun65(ch):
if ch == 'a' or ch == 'e' or ch == 'i' or ch == 'o' or ch == 'u':
return 'Vowel'
else:
return 'Consonant' |
11636 | Validation/png/11636.png | # Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.
import re
def change_date_format(dt):
return re.sub(r"(\d{4})-(\d{1,2})-(\d{1,2})", "\\3-\\2-\\1", dt)
return change_date_format(dt)
|
11506 | Validation/png/11506.png | # Write a python function to find the sum of an array.
def _sum(arr):
sum = 0
for i in arr:
sum = sum + i
return sum
|
11820 | Validation/png/11820.png | def fun138(num):
if num == 0:
return 'Fibonacci Number'
elif num == 1:
return 'Fibonacci Number'
else:
a = 0
b = 1
c = 0
while c < num:
c = a + b
a = b
b = c
if c == num:
return 'Fibonacci Number'
else:
return 'Not a Fibonacci Number'
|
11797 | Validation/png/11797.png | def fun115(num1, num2):
hcf = 0
limit = min(num1, num2)
i = 1
while i <= limit:
if num1 % i == 0 and num2 % i == 0:
hcf = i
i = i + 1
return hcf |
11573 | Validation/png/11573.png | # Write a function to print n-times a list using map function.
def ntimes_list(nums, n):
result = map(lambda x: n * x, nums)
return list(result)
|
11746 | Validation/png/11746.png | def fun64(ch):
ascii = ord(ch)
if ascii >= 48 and ascii <= 57:
return 'A Digit'
else:
return 'Not a Digit' |
11729 | Validation/png/11729.png | def fun47(num):
if num % 2 == 0:
return 'Odd Number'
else:
return 'Even Number' |
11772 | Validation/png/11772.png | def fun90(num):
res = 0
order = 1
while num != 0:
rem = num % 8
res = rem * order + res
num = num // 8
order = order * 10
return res |
11321 | Validation/png/11321.png | # Write a function to find the maximum value in record list as tuple attribute in the given tuple list.
def maximum_value(test_list):
res = [(key, max(lst)) for key, lst in test_list]
return res
|
11684 | Validation/png/11684.png | def fun2(a, b):
c = a + b * 100
return c |
11611 | Validation/png/11611.png | # Write a python function to count the total unset bits from 1 to n.
def count_Unset_Bits(n):
cnt = 0
for i in range(1, n + 1):
temp = i
while temp:
if temp % 2 == 0:
cnt += 1
temp = temp // 2
return cnt
|
11385 | Validation/png/11385.png | # Write a function to check if the triangle is valid or not.
def validity_triangle(a, b, c):
total = a + b + c
if total == 180:
return True
else:
return False
|
11807 | Validation/png/11807.png | def fun125(N):
term = 1
for i in range(1, N):
term = term * 10 + 1
return term
|
11753 | Validation/png/11753.png | def fun71(num):
pro = 1
while num != 0:
d = num % 10
pro = pro * d
num = num // 10
return pro |
11451 | Validation/png/11451.png | # Write a function to rotate a given list by specified number of items to the right direction.
def rotate_right(list1, m, n):
result = list1[-(m):] + list1[:-(n)]
return result
|
11714 | Validation/png/11714.png | def fun32(distance, time):
velocity = distance / time
return velocity |
11813 | Validation/png/11813.png | def fun131(N, k):
term = 1
sum = 0
for i in range(1, N):
sum = sum + term
term = 1 / i * k
return sum |
11678 | Validation/png/11678.png | # Write a function to find minimum of two numbers.
def min_of_two(x, y):
if x < y:
return x
return y
|
11463 | Validation/png/11463.png | # Write a function to find the second smallest number in a list.
def second_smallest(numbers):
if len(numbers) < 2:
return
if (len(numbers) == 2) and (numbers[0] == numbers[1]):
return
dup_items = set()
uniq_items = []
for x in numbers:
if x not in dup_items:
uniq_items.append(x)
dup_items.add(x)
uniq_items.sort()
return uniq_items[1]
|