diff options
997 files changed, 12401 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89f9ac0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +out/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b444d41 --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +JAVAC = javac +ANTLR_COMPLETE = lib/antlr-4.13.1-complete.jar +JAVAC_FLAGS = -cp $(ANTLR_COMPLETE) -Xlint:deprecation -d out +SRC_DIR = src +BIN_DIR = out +MAIN_CLASS = Main +SOURCES = $(wildcard $(SRC_DIR)/*.java) +GRAMMARS = $(SRC_DIR)/Python3Lexer.g4 $(SRC_DIR)/Python3Parser.g4 +ANTLR_OUTPUT = $(SRC_DIR)/Python3Lexer.java $(SRC_DIR)/Python3Parser.java $(SRC_DIR)/Python3ParserListener.java $(SRC_DIR)/Python3ParserBaseListener.java  +DATE = $(shell date +%Y%m%d-%H%M%S) +ARGS =  + +all: $(SOURCES) $(ANTLR_OUTPUT) +	$(JAVAC) $(JAVAC_FLAGS) $^ + +$(ANTLR_OUTPUT): $(GRAMMARS) +	java -jar lib/antlr-4.13.1-complete.jar $^ + +run: +	java -cp $(ANTLR_COMPLETE):$(BIN_DIR) $(MAIN_CLASS) $(ARGS) + +runall: +	java -cp $(ANTLR_COMPLETE):$(BIN_DIR) ParseAll $(ARGS) + +clean: +	rm -rf $(BIN_DIR)/* trees/* + +release: clean +	zip -r ../python3-miniparser-$(DATE).zip . + +.PHONY: all run clean release runall diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..0bcbb1d --- /dev/null +++ b/README.txt @@ -0,0 +1,24 @@ +Python3 Package + +* nella cartella src ci sono lexer e parser per Python3 semplificati per il corso  +di CLP (non ci interessa analizzare qualunque programma Python) + +* sempre nella cartella src ci sono i file Python3LexerBase.java e  +Python3ParserBase.java. Questi non sono nostri e vanno tenuti nella stessa cartella. + +* Attraverso Python3Parser.g4 è possibile generare il parser tramite ANTLR e quindi tutti +i file relativi (Visitor, Listener, etc.) + +* Nella cartella src ci sono 2 file che ha fatto Marco Bertoni per creare l'albero sintattico  +di un programma che si trova in progs/test.py (il file Main.java) oppure per creare gli  +alberi sintattici di tutti i programmi nella cartella progs (il file ParseAll.java). Gli  +alberi sintattici sono visualizzati nella cartella trees che verra` creata eseguendo i +due programmi. Abbiamo usato questi codici perche` ANTLR pare sia rotto su questi codici (non +genera alberi sintattici!) + +* i programmi della cartella progs sono 870. Li abbiamo presi da un database di programmi +semplici e riusciamo a parsarli tutti. Le sottocartelle dont_care e unparsable_programs contengono programmi con feature che lasciam perdere (classi o lambdas) e programmi che +non riusciamo a parsare (abbiamo semplificato la sintassi per avere alberi piu` semplici: non +abbiam capito perche` non riusciamo ad analizzarli...) + +Marco Bertoni, Cosimo Laneve
\ No newline at end of file diff --git a/lib/antlr-4.13.1-complete.jar b/lib/antlr-4.13.1-complete.jar Binary files differnew file mode 100644 index 0000000..f539ab0 --- /dev/null +++ b/lib/antlr-4.13.1-complete.jar diff --git a/progs/a1.py b/progs/a1.py new file mode 100644 index 0000000..e229860 --- /dev/null +++ b/progs/a1.py @@ -0,0 +1,5 @@ +def first_repeated_char(str1):
 +  for index,c in enumerate(str1):
 +    if str1[:index+1].count(c) > 1:
 +      return c 
 +  return "None"
\ No newline at end of file diff --git a/progs/a10.py b/progs/a10.py new file mode 100644 index 0000000..c0e28ad --- /dev/null +++ b/progs/a10.py @@ -0,0 +1,3 @@ +def max_of_nth(test_list, N):
 +  res = max([sub[N] for sub in test_list])
 +  return (res) 
\ No newline at end of file diff --git a/progs/a100.py b/progs/a100.py new file mode 100644 index 0000000..9236c70 --- /dev/null +++ b/progs/a100.py @@ -0,0 +1,9 @@ +def equilibrium_index(arr):
 +  total_sum = sum(arr)
 +  left_sum=0
 +  for i, num in enumerate(arr):
 +    total_sum -= num
 +    if left_sum == total_sum:
 +      return i
 +    left_sum += num
 +  return -1
\ No newline at end of file diff --git a/progs/a101.py b/progs/a101.py new file mode 100644 index 0000000..bb73cd8 --- /dev/null +++ b/progs/a101.py @@ -0,0 +1,24 @@ +def find_ind(key, i, n, 
 +			k, arr):
 +	ind = -1
 +	start = i + 1
 +	end = n - 1;
 +	while (start < end):
 +		mid = int(start +
 +				(end - start) / 2)
 +		if (arr[mid] - key <= k):
 +			ind = mid
 +			start = mid + 1
 +		else:
 +			end = mid
 +	return ind
 +def removals(arr, n, k):
 +	ans = n - 1
 +	arr.sort()
 +	for i in range(0, n):
 +		j = find_ind(arr[i], i, 
 +					n, k, arr)
 +		if (j != -1):
 +			ans = min(ans, n -
 +						(j - i + 1))
 +	return ans
\ No newline at end of file diff --git a/progs/a102.py b/progs/a102.py new file mode 100644 index 0000000..6c6d8b8 --- /dev/null +++ b/progs/a102.py @@ -0,0 +1,5 @@ +def is_key_present(d,x):
 +  if x in d:
 +    return True
 +  else:
 +     return False
\ No newline at end of file diff --git a/progs/a103.py b/progs/a103.py new file mode 100644 index 0000000..aaa3886 --- /dev/null +++ b/progs/a103.py @@ -0,0 +1,5 @@ +def harmonic_sum(n):
 +  if n < 2:
 +    return 1
 +  else:
 +    return 1 / n + (harmonic_sum(n - 1))
\ No newline at end of file diff --git a/progs/a104.py b/progs/a104.py new file mode 100644 index 0000000..ca6d321 --- /dev/null +++ b/progs/a104.py @@ -0,0 +1,4 @@ +def sort_sublists(list1):
 +      list1.sort()  
 +      list1.sort(key=len)
 +      return  list1
\ No newline at end of file diff --git a/progs/a105.py b/progs/a105.py new file mode 100644 index 0000000..8bda3d4 --- /dev/null +++ b/progs/a105.py @@ -0,0 +1,10 @@ +def is_subset(arr1, m, arr2, n): 
 +	hashset = set() 
 +	for i in range(0, m): 
 +		hashset.add(arr1[i]) 
 +	for i in range(0, n): 
 +		if arr2[i] in hashset: 
 +			continue
 +		else: 
 +			return False
 +	return True		
\ No newline at end of file diff --git a/progs/a106.py b/progs/a106.py new file mode 100644 index 0000000..3a78c37 --- /dev/null +++ b/progs/a106.py @@ -0,0 +1,13 @@ +def count_Set_Bits(n) :  
 +    n += 1; 
 +    powerOf2 = 2;   
 +    cnt = n // 2;  
 +    while (powerOf2 <= n) : 
 +        totalPairs = n // powerOf2;  
 +        cnt += (totalPairs // 2) * powerOf2;  
 +        if (totalPairs & 1) : 
 +            cnt += (n % powerOf2) 
 +        else : 
 +            cnt += 0
 +        powerOf2 <<= 1;    
 +    return cnt;  
\ No newline at end of file diff --git a/progs/a107.py b/progs/a107.py new file mode 100644 index 0000000..3393151 --- /dev/null +++ b/progs/a107.py @@ -0,0 +1,3 @@ +def Convert(string): 
 +    li = list(string.split(" ")) 
 +    return li 
\ No newline at end of file diff --git a/progs/a108.py b/progs/a108.py new file mode 100644 index 0000000..2531306 --- /dev/null +++ b/progs/a108.py @@ -0,0 +1,10 @@ +from collections import defaultdict 
 +def get_unique(test_list):
 +  res = defaultdict(list)
 +  for sub in test_list:
 +    res[sub[1]].append(sub[0])
 +  res = dict(res)
 +  res_dict = dict()
 +  for key in res:
 +    res_dict[key] = len(list(set(res[key])))
 +  return (str(res_dict)) 
\ No newline at end of file diff --git a/progs/a109.py b/progs/a109.py new file mode 100644 index 0000000..b1b7c39 --- /dev/null +++ b/progs/a109.py @@ -0,0 +1,3 @@ +def front_and_rear(test_tup):
 +  res = (test_tup[0], test_tup[-1])
 +  return (res) 
\ No newline at end of file diff --git a/progs/a110.py b/progs/a110.py new file mode 100644 index 0000000..09ad2d6 --- /dev/null +++ b/progs/a110.py @@ -0,0 +1,16 @@ +def product_Equal(n): 
 +    if n < 10: 
 +        return False
 +    prodOdd = 1; prodEven = 1
 +    while n > 0: 
 +        digit = n % 10
 +        prodOdd *= digit 
 +        n = n//10
 +        if n == 0: 
 +            break; 
 +        digit = n % 10
 +        prodEven *= digit 
 +        n = n//10
 +    if prodOdd == prodEven: 
 +        return True
 +    return False
\ No newline at end of file diff --git a/progs/a113.py b/progs/a113.py new file mode 100644 index 0000000..39ed034 --- /dev/null +++ b/progs/a113.py @@ -0,0 +1,19 @@ +def count_Fac(n):  
 +    m = n 
 +    count = 0
 +    i = 2
 +    while((i * i) <= m): 
 +        total = 0
 +        while (n % i == 0): 
 +            n /= i 
 +            total += 1 
 +        temp = 0
 +        j = 1
 +        while((temp + j) <= total): 
 +            temp += j 
 +            count += 1
 +            j += 1 
 +        i += 1
 +    if (n != 1): 
 +        count += 1 
 +    return count 
\ No newline at end of file diff --git a/progs/a114.py b/progs/a114.py new file mode 100644 index 0000000..3b13bb4 --- /dev/null +++ b/progs/a114.py @@ -0,0 +1,3 @@ +def str_to_tuple(test_str):
 +  res = tuple(map(int, test_str.split(', ')))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a115.py b/progs/a115.py new file mode 100644 index 0000000..e4aed70 --- /dev/null +++ b/progs/a115.py @@ -0,0 +1,3 @@ +def rombus_perimeter(a):
 +  perimeter=4*a
 +  return perimeter
\ No newline at end of file diff --git a/progs/a116.py b/progs/a116.py new file mode 100644 index 0000000..f9da081 --- /dev/null +++ b/progs/a116.py @@ -0,0 +1,19 @@ +import math
 +import sys
 +def sd_calc(data):
 +    n = len(data)
 +    if n <= 1:
 +        return 0.0
 +    mean, sd = avg_calc(data), 0.0
 +    for el in data:
 +        sd += (float(el) - mean)**2
 +    sd = math.sqrt(sd / float(n-1))
 +    return sd
 +def avg_calc(ls):
 +    n, mean = len(ls), 0.0
 +    if n <= 1:
 +        return ls[0]
 +    for el in ls:
 +        mean = mean + float(el)
 +    mean = mean / float(n)
 +    return mean
\ No newline at end of file diff --git a/progs/a117.py b/progs/a117.py new file mode 100644 index 0000000..d6429ad --- /dev/null +++ b/progs/a117.py @@ -0,0 +1,5 @@ +def alternate_elements(list1):
 +    result=[]
 +    for item in list1[::2]:
 +        result.append(item)
 +    return result 
\ No newline at end of file diff --git a/progs/a118.py b/progs/a118.py new file mode 100644 index 0000000..294bc98 --- /dev/null +++ b/progs/a118.py @@ -0,0 +1,7 @@ +import re
 +def text_match(text):
 +        patterns = 'ab*?'
 +        if re.search(patterns,  text):
 +                return 'Found a match!'
 +        else:
 +                return('Not matched!')
\ No newline at end of file diff --git a/progs/a119.py b/progs/a119.py new file mode 100644 index 0000000..5825608 --- /dev/null +++ b/progs/a119.py @@ -0,0 +1,5 @@ +def add_dict_to_tuple(test_tup, test_dict):
 +  test_tup = list(test_tup)
 +  test_tup.append(test_dict)
 +  test_tup = tuple(test_tup)
 +  return (test_tup) 
\ No newline at end of file diff --git a/progs/a12.py b/progs/a12.py new file mode 100644 index 0000000..8c18cbd --- /dev/null +++ b/progs/a12.py @@ -0,0 +1,3 @@ +def maximum_value(test_list):
 +  res = [(key, max(lst)) for key, lst in test_list]
 +  return (res) 
\ No newline at end of file diff --git a/progs/a120.py b/progs/a120.py new file mode 100644 index 0000000..e094eb3 --- /dev/null +++ b/progs/a120.py @@ -0,0 +1,13 @@ +M = 100
 +def maxAverageOfPath(cost, N): 
 +	dp = [[0 for i in range(N + 1)] for j in range(N + 1)] 
 +	dp[0][0] = cost[0][0] 
 +	for i in range(1, N): 
 +		dp[i][0] = dp[i - 1][0] + cost[i][0] 
 +	for j in range(1, N): 
 +		dp[0][j] = dp[0][j - 1] + cost[0][j] 
 +	for i in range(1, N): 
 +		for j in range(1, N): 
 +			dp[i][j] = max(dp[i - 1][j], 
 +						dp[i][j - 1]) + cost[i][j] 
 +	return dp[N - 1][N - 1] / (2 * N - 1)
\ No newline at end of file diff --git a/progs/a122.py b/progs/a122.py new file mode 100644 index 0000000..584cdc9 --- /dev/null +++ b/progs/a122.py @@ -0,0 +1,4 @@ +from operator import eq
 +def count_same_pair(nums1, nums2):
 +    result = sum(map(eq, nums1, nums2))
 +    return result
\ No newline at end of file diff --git a/progs/a123.py b/progs/a123.py new file mode 100644 index 0000000..118c573 --- /dev/null +++ b/progs/a123.py @@ -0,0 +1,2 @@ +def power_base_sum(base, power):
 +    return sum([int(i) for i in str(pow(base, power))])
\ No newline at end of file diff --git a/progs/a125.py b/progs/a125.py new file mode 100644 index 0000000..bd61056 --- /dev/null +++ b/progs/a125.py @@ -0,0 +1,3 @@ +def multiply_elements(test_tup):
 +  res = tuple(i * j for i, j in zip(test_tup, test_tup[1:]))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a126.py b/progs/a126.py new file mode 100644 index 0000000..f344bda --- /dev/null +++ b/progs/a126.py @@ -0,0 +1,4 @@ +import re 
 +def remove_char(S):
 +  result = re.sub('[\W_]+', '', S) 
 +  return result
\ No newline at end of file diff --git a/progs/a127.py b/progs/a127.py new file mode 100644 index 0000000..ca33f09 --- /dev/null +++ b/progs/a127.py @@ -0,0 +1,3 @@ +def sum_list(lst1,lst2):
 +  res_list = [lst1[i] + lst2[i] for i in range(len(lst1))] 
 +  return res_list
\ No newline at end of file diff --git a/progs/a129.py b/progs/a129.py new file mode 100644 index 0000000..3d0f600 --- /dev/null +++ b/progs/a129.py @@ -0,0 +1,3 @@ +from itertools import groupby
 +def consecutive_duplicates(nums):
 +    return [key for key, group in groupby(nums)] 
\ No newline at end of file diff --git a/progs/a13.py b/progs/a13.py new file mode 100644 index 0000000..30a80e2 --- /dev/null +++ b/progs/a13.py @@ -0,0 +1,3 @@ +def cummulative_sum(test_list):
 +  res = sum(map(sum, test_list))
 +  return (res)
\ No newline at end of file diff --git a/progs/a130.py b/progs/a130.py new file mode 100644 index 0000000..4197e63 --- /dev/null +++ b/progs/a130.py @@ -0,0 +1,5 @@ +import math
 +def lateralsurface_cone(r,h):
 +  l = math.sqrt(r * r + h * h)
 +  LSA = math.pi * r  * l
 +  return LSA
\ No newline at end of file diff --git a/progs/a131.py b/progs/a131.py new file mode 100644 index 0000000..5cebe72 --- /dev/null +++ b/progs/a131.py @@ -0,0 +1,3 @@ +import re
 +def replace_specialchar(text):
 + return (re.sub("[ ,.]", ":", text))
\ No newline at end of file diff --git a/progs/a132.py b/progs/a132.py new file mode 100644 index 0000000..d179c8a --- /dev/null +++ b/progs/a132.py @@ -0,0 +1,13 @@ +def find_first_occurrence(A, x):
 +    (left, right) = (0, len(A) - 1)
 +    result = -1
 +    while left <= right:
 +        mid = (left + right) // 2
 +        if x == A[mid]:
 +            result = mid
 +            right = mid - 1
 +        elif x < A[mid]:
 +            right = mid - 1
 +        else:
 +            left = mid + 1
 +    return result
\ No newline at end of file diff --git a/progs/a133.py b/progs/a133.py new file mode 100644 index 0000000..d2ce961 --- /dev/null +++ b/progs/a133.py @@ -0,0 +1,10 @@ +def sum_Of_Subarray_Prod(arr,n):
 +    ans = 0
 +    res = 0
 +    i = n - 1
 +    while (i >= 0):
 +        incr = arr[i]*(1 + res)
 +        ans += incr
 +        res = incr
 +        i -= 1
 +    return (ans)
\ No newline at end of file diff --git a/progs/a134.py b/progs/a134.py new file mode 100644 index 0000000..d2e1515 --- /dev/null +++ b/progs/a134.py @@ -0,0 +1,11 @@ +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) 
\ No newline at end of file diff --git a/progs/a135.py b/progs/a135.py new file mode 100644 index 0000000..ee2fb40 --- /dev/null +++ b/progs/a135.py @@ -0,0 +1,4 @@ +import bisect
 +def left_insertion(a, x):
 +    i = bisect.bisect_left(a, x)
 +    return i
\ No newline at end of file diff --git a/progs/a136.py b/progs/a136.py new file mode 100644 index 0000000..a1f4adb --- /dev/null +++ b/progs/a136.py @@ -0,0 +1,7 @@ +import re 
 +regex = '^[aeiouAEIOU][A-Za-z0-9_]*'
 +def check_str(string): 
 +	if(re.search(regex, string)): 
 +		return ("Valid") 
 +	else: 
 +		return ("Invalid") 
\ No newline at end of file diff --git a/progs/a137.py b/progs/a137.py new file mode 100644 index 0000000..ff0d667 --- /dev/null +++ b/progs/a137.py @@ -0,0 +1,5 @@ +def geometric_sum(n):
 +  if n < 0:
 +    return 0
 +  else:
 +    return 1 / (pow(2, n)) + geometric_sum(n - 1)
\ No newline at end of file diff --git a/progs/a138.py b/progs/a138.py new file mode 100644 index 0000000..d20a9bb --- /dev/null +++ b/progs/a138.py @@ -0,0 +1,4 @@ +import math 
 +def find_Index(n): 
 +    x = math.sqrt(2 * math.pow(10,(n - 1))); 
 +    return round(x); 
\ No newline at end of file diff --git a/progs/a139.py b/progs/a139.py new file mode 100644 index 0000000..9c0e09c --- /dev/null +++ b/progs/a139.py @@ -0,0 +1,3 @@ +def tuple_to_dict(test_tup):
 +  res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a140.py b/progs/a140.py new file mode 100644 index 0000000..2bdcce2 --- /dev/null +++ b/progs/a140.py @@ -0,0 +1,6 @@ +def all_Characters_Same(s) :
 +    n = len(s)
 +    for i in range(1,n) :
 +        if s[i] != s[0] :
 +            return False
 +    return True
\ No newline at end of file diff --git a/progs/a141.py b/progs/a141.py new file mode 100644 index 0000000..844ffd7 --- /dev/null +++ b/progs/a141.py @@ -0,0 +1,4 @@ +import math
 +def area_tetrahedron(side):
 +  area = math.sqrt(3)*(side*side)
 +  return area
\ No newline at end of file diff --git a/progs/a142.py b/progs/a142.py new file mode 100644 index 0000000..a6ecb35 --- /dev/null +++ b/progs/a142.py @@ -0,0 +1,3 @@ +def rotate_right(list1,m,n):
 +  result =  list1[-(m):]+list1[:-(n)]
 +  return result
\ No newline at end of file diff --git a/progs/a145.py b/progs/a145.py new file mode 100644 index 0000000..9f27291 --- /dev/null +++ b/progs/a145.py @@ -0,0 +1,6 @@ +def sector_area(r,a):
 +    pi=22/7
 +    if a >= 360:
 +        return None
 +    sectorarea = (pi*r**2) * (a/360)
 +    return sectorarea
\ No newline at end of file diff --git a/progs/a146.py b/progs/a146.py new file mode 100644 index 0000000..2db2801 --- /dev/null +++ b/progs/a146.py @@ -0,0 +1,16 @@ +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]
\ No newline at end of file diff --git a/progs/a148.py b/progs/a148.py new file mode 100644 index 0000000..a4c489d --- /dev/null +++ b/progs/a148.py @@ -0,0 +1,4 @@ +def sort_numeric_strings(nums_str):
 +    result = [int(x) for x in nums_str]
 +    result.sort()
 +    return result
\ No newline at end of file diff --git a/progs/a149.py b/progs/a149.py new file mode 100644 index 0000000..1aea7cd --- /dev/null +++ b/progs/a149.py @@ -0,0 +1,3 @@ +def add_tuple(test_list, test_tup):
 +  test_list += test_tup
 +  return (test_list) 
\ No newline at end of file diff --git a/progs/a15.py b/progs/a15.py new file mode 100644 index 0000000..238c18f --- /dev/null +++ b/progs/a15.py @@ -0,0 +1,3 @@ +def tuple_modulo(test_tup1, test_tup2):
 +  res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) 
 +  return (res) 
\ No newline at end of file diff --git a/progs/a150.py b/progs/a150.py new file mode 100644 index 0000000..de203fb --- /dev/null +++ b/progs/a150.py @@ -0,0 +1,7 @@ +def check_min_heap(arr, i):
 +    if 2 * i + 2 > len(arr):
 +        return True
 +    left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap(arr, 2 * i + 1)
 +    right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2] 
 +                                      and check_min_heap(arr, 2 * i + 2))
 +    return left_child and right_child
\ No newline at end of file diff --git a/progs/a151.py b/progs/a151.py new file mode 100644 index 0000000..030c8b6 --- /dev/null +++ b/progs/a151.py @@ -0,0 +1,7 @@ +def jacobsthal_num(n): 
 +	dp = [0] * (n + 1) 
 +	dp[0] = 0
 +	dp[1] = 1
 +	for i in range(2, n+1): 
 +		dp[i] = dp[i - 1] + 2 * dp[i - 2] 
 +	return dp[n]
\ No newline at end of file diff --git a/progs/a153.py b/progs/a153.py new file mode 100644 index 0000000..08d190c --- /dev/null +++ b/progs/a153.py @@ -0,0 +1,6 @@ +def extract_index_list(l1, l2, l3):
 +    result = []
 +    for m, n, o in zip(l1, l2, l3):
 +        if (m == n == o):
 +            result.append(m)
 +    return result
\ No newline at end of file diff --git a/progs/a154.py b/progs/a154.py new file mode 100644 index 0000000..38780bc --- /dev/null +++ b/progs/a154.py @@ -0,0 +1,13 @@ +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] 
\ No newline at end of file diff --git a/progs/a155.py b/progs/a155.py new file mode 100644 index 0000000..d9193e0 --- /dev/null +++ b/progs/a155.py @@ -0,0 +1,7 @@ +import re
 +def text_match_zero_one(text):
 +        patterns = 'ab?'
 +        if re.search(patterns,  text):
 +                return 'Found a match!'
 +        else:
 +                return('Not matched!')
\ No newline at end of file diff --git a/progs/a156.py b/progs/a156.py new file mode 100644 index 0000000..babdcbe --- /dev/null +++ b/progs/a156.py @@ -0,0 +1,4 @@ +def count_reverse_pairs(test_list):
 +  res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len( 
 +	test_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))]) 
 +  return str(res)
\ No newline at end of file diff --git a/progs/a157.py b/progs/a157.py new file mode 100644 index 0000000..9b88c14 --- /dev/null +++ b/progs/a157.py @@ -0,0 +1,7 @@ +def unique_sublists(list1):
 +    result ={}
 +    for l in  list1: 
 +        result.setdefault(tuple(l), list()).append(1) 
 +    for a, b in result.items(): 
 +        result[a] = sum(b)
 +    return result
\ No newline at end of file diff --git a/progs/a159.py b/progs/a159.py new file mode 100644 index 0000000..4a3b4c1 --- /dev/null +++ b/progs/a159.py @@ -0,0 +1,6 @@ +def unique_Element(arr,n):
 +    s = set(arr)
 +    if (len(s) == 1):
 +        return ('YES')
 +    else:
 +        return ('NO')
\ No newline at end of file diff --git a/progs/a16.py b/progs/a16.py new file mode 100644 index 0000000..c458cce --- /dev/null +++ b/progs/a16.py @@ -0,0 +1,12 @@ +def min_Jumps(a, b, d): 
 +    temp = a 
 +    a = min(a, b) 
 +    b = max(temp, b) 
 +    if (d >= b): 
 +        return (d + b - 1) / b 
 +    if (d == 0): 
 +        return 0
 +    if (d == a): 
 +        return 1
 +    else:
 +        return 2
\ No newline at end of file diff --git a/progs/a160.py b/progs/a160.py new file mode 100644 index 0000000..010935e --- /dev/null +++ b/progs/a160.py @@ -0,0 +1,6 @@ +def arc_length(d,a):
 +    pi=22/7
 +    if a >= 360:
 +        return None
 +    arclength = (pi*d) * (a/360)
 +    return arclength
\ No newline at end of file diff --git a/progs/a161.py b/progs/a161.py new file mode 100644 index 0000000..b21de79 --- /dev/null +++ b/progs/a161.py @@ -0,0 +1,5 @@ +def check_monthnumber_number(monthnum3):
 +  if(monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11):
 +    return True
 +  else:
 +    return False
\ No newline at end of file diff --git a/progs/a162.py b/progs/a162.py new file mode 100644 index 0000000..d35782b --- /dev/null +++ b/progs/a162.py @@ -0,0 +1,7 @@ +def find_Min_Diff(arr,n): 
 +    arr = sorted(arr) 
 +    diff = 10**20 
 +    for i in range(n-1): 
 +        if arr[i+1] - arr[i] < diff: 
 +            diff = arr[i+1] - arr[i]  
 +    return diff 
\ No newline at end of file diff --git a/progs/a163.py b/progs/a163.py new file mode 100644 index 0000000..a624d5c --- /dev/null +++ b/progs/a163.py @@ -0,0 +1,5 @@ +def number_ctr(str):
 +      number_ctr= 0
 +      for i in range(len(str)):
 +          if str[i] >= '0' and str[i] <= '9': number_ctr += 1     
 +      return  number_ctr
\ No newline at end of file diff --git a/progs/a164.py b/progs/a164.py new file mode 100644 index 0000000..fae83d9 --- /dev/null +++ b/progs/a164.py @@ -0,0 +1,4 @@ +import math 
 +def is_polite(n): 
 +	n = n + 1
 +	return (int)(n+(math.log((n + math.log(n, 2)), 2))) 
\ No newline at end of file diff --git a/progs/a165.py b/progs/a165.py new file mode 100644 index 0000000..9de2d2f --- /dev/null +++ b/progs/a165.py @@ -0,0 +1,7 @@ +def pair_wise(l1):
 +    temp = []
 +    for i in range(len(l1) - 1):
 +        current_element, next_element = l1[i], l1[i + 1]
 +        x = (current_element, next_element)
 +        temp.append(x)
 +    return temp
\ No newline at end of file diff --git a/progs/a166.py b/progs/a166.py new file mode 100644 index 0000000..effe847 --- /dev/null +++ b/progs/a166.py @@ -0,0 +1,7 @@ +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
\ No newline at end of file diff --git a/progs/a167.py b/progs/a167.py new file mode 100644 index 0000000..1392dac --- /dev/null +++ b/progs/a167.py @@ -0,0 +1,9 @@ +def check_Odd_Parity(x): 
 +    parity = 0
 +    while (x != 0): 
 +        x = x & (x - 1) 
 +        parity += 1
 +    if (parity % 2 == 1): 
 +        return True
 +    else: 
 +        return False
\ No newline at end of file diff --git a/progs/a168.py b/progs/a168.py new file mode 100644 index 0000000..ae6939a --- /dev/null +++ b/progs/a168.py @@ -0,0 +1,3 @@ +def Diff(li1,li2):
 +    return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))
 + 
\ No newline at end of file diff --git a/progs/a169.py b/progs/a169.py new file mode 100644 index 0000000..8b066d5 --- /dev/null +++ b/progs/a169.py @@ -0,0 +1,7 @@ +def odd_Num_Sum(n) : 
 +    j = 0
 +    sm = 0
 +    for i in range(1,n + 1) : 
 +        j = (2*i-1) 
 +        sm = sm + (j*j*j*j)   
 +    return sm 
\ No newline at end of file diff --git a/progs/a170.py b/progs/a170.py new file mode 100644 index 0000000..2c39536 --- /dev/null +++ b/progs/a170.py @@ -0,0 +1,15 @@ +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
\ No newline at end of file diff --git a/progs/a171.py b/progs/a171.py new file mode 100644 index 0000000..64686f7 --- /dev/null +++ b/progs/a171.py @@ -0,0 +1,5 @@ +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) 
\ No newline at end of file diff --git a/progs/a172.py b/progs/a172.py new file mode 100644 index 0000000..aa99281 --- /dev/null +++ b/progs/a172.py @@ -0,0 +1,6 @@ +import re
 +def occurance_substring(text,pattern):
 + for match in re.finditer(pattern, text):
 +    s = match.start()
 +    e = match.end()
 +    return (text[s:e], s, e)
\ No newline at end of file diff --git a/progs/a173.py b/progs/a173.py new file mode 100644 index 0000000..c2e9205 --- /dev/null +++ b/progs/a173.py @@ -0,0 +1,7 @@ +import re 
 +regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$'
 +def check_email(email): 
 +	if(re.search(regex,email)): 
 +		return ("Valid Email") 
 +	else: 
 +		return ("Invalid Email") 
\ No newline at end of file diff --git a/progs/a174.py b/progs/a174.py new file mode 100644 index 0000000..4a8a265 --- /dev/null +++ b/progs/a174.py @@ -0,0 +1,2 @@ +def odd_position(nums):
 +	return all(nums[i]%2==i%2 for i in range(len(nums)))
\ No newline at end of file diff --git a/progs/a175.py b/progs/a175.py new file mode 100644 index 0000000..7376fea --- /dev/null +++ b/progs/a175.py @@ -0,0 +1,11 @@ +def count_vowels(test_str):
 +  res = 0
 +  vow_list = ['a', 'e', 'i', 'o', 'u']
 +  for idx in range(1, len(test_str) - 1):
 +    if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list):
 +      res += 1
 +  if test_str[0] not in vow_list and test_str[1] in vow_list:
 +    res += 1
 +  if test_str[-1] not in vow_list and test_str[-2] in vow_list:
 +    res += 1
 +  return (res) 
\ No newline at end of file diff --git a/progs/a176.py b/progs/a176.py new file mode 100644 index 0000000..52c13ad --- /dev/null +++ b/progs/a176.py @@ -0,0 +1,7 @@ +def find_Sum(arr,n): 
 +    arr.sort() 
 +    sum = arr[0] 
 +    for i in range(0,n-1): 
 +        if (arr[i] != arr[i+1]): 
 +            sum = sum + arr[i+1]   
 +    return sum
\ No newline at end of file diff --git a/progs/a177.py b/progs/a177.py new file mode 100644 index 0000000..8479a42 --- /dev/null +++ b/progs/a177.py @@ -0,0 +1,3 @@ +from itertools import groupby
 +def pack_consecutive_duplicates(list1):
 +    return [list(group) for key, group in groupby(list1)]
\ No newline at end of file diff --git a/progs/a178.py b/progs/a178.py new file mode 100644 index 0000000..6ae8528 --- /dev/null +++ b/progs/a178.py @@ -0,0 +1,7 @@ +def unique_sublists(list1):
 +    result ={}
 +    for l in list1: 
 +        result.setdefault(tuple(l), list()).append(1) 
 +    for a, b in result.items(): 
 +        result[a] = sum(b)
 +    return result
\ No newline at end of file diff --git a/progs/a179.py b/progs/a179.py new file mode 100644 index 0000000..223a67b --- /dev/null +++ b/progs/a179.py @@ -0,0 +1,4 @@ +from itertools import combinations 
 +def find_combinations(test_list):
 +  res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)]
 +  return (res) 
\ No newline at end of file diff --git a/progs/a18.py b/progs/a18.py new file mode 100644 index 0000000..3b6d7ce --- /dev/null +++ b/progs/a18.py @@ -0,0 +1,10 @@ +def move_num(test_str):
 +  res = ''
 +  dig = ''
 +  for ele in test_str:
 +    if ele.isdigit():
 +      dig += ele
 +    else:
 +      res += ele
 +  res += dig
 +  return (res) 
\ No newline at end of file diff --git a/progs/a180.py b/progs/a180.py new file mode 100644 index 0000000..ea41d52 --- /dev/null +++ b/progs/a180.py @@ -0,0 +1,13 @@ +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") 
\ No newline at end of file diff --git a/progs/a181.py b/progs/a181.py new file mode 100644 index 0000000..c03fcfa --- /dev/null +++ b/progs/a181.py @@ -0,0 +1,6 @@ +def Odd_Length_Sum(arr):
 +    Sum = 0
 +    l = len(arr)
 +    for i in range(l):
 +        Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i])
 +    return Sum
\ No newline at end of file diff --git a/progs/a182.py b/progs/a182.py new file mode 100644 index 0000000..2e79b0d --- /dev/null +++ b/progs/a182.py @@ -0,0 +1,19 @@ +def rgb_to_hsv(r, g, b):
 +    r, g, b = r/255.0, g/255.0, b/255.0
 +    mx = max(r, g, b)
 +    mn = min(r, g, b)
 +    df = mx-mn
 +    if mx == mn:
 +        h = 0
 +    elif mx == r:
 +        h = (60 * ((g-b)/df) + 360) % 360
 +    elif mx == g:
 +        h = (60 * ((b-r)/df) + 120) % 360
 +    elif mx == b:
 +        h = (60 * ((r-g)/df) + 240) % 360
 +    if mx == 0:
 +        s = 0
 +    else:
 +        s = (df/mx)*100
 +    v = mx*100
 +    return h, s, v
\ No newline at end of file diff --git a/progs/a183.py b/progs/a183.py new file mode 100644 index 0000000..7086326 --- /dev/null +++ b/progs/a183.py @@ -0,0 +1,4 @@ +def mul_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)
\ No newline at end of file diff --git a/progs/a184.py b/progs/a184.py new file mode 100644 index 0000000..23c6568 --- /dev/null +++ b/progs/a184.py @@ -0,0 +1,3 @@ +def tuple_str_int(test_str):
 +  res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', '))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a185.py b/progs/a185.py new file mode 100644 index 0000000..c372b9e --- /dev/null +++ b/progs/a185.py @@ -0,0 +1,4 @@ +import bisect
 +def right_insertion(a, x):
 +    i = bisect.bisect_right(a, x)
 +    return i
\ No newline at end of file diff --git a/progs/a186.py b/progs/a186.py new file mode 100644 index 0000000..3011e9a --- /dev/null +++ b/progs/a186.py @@ -0,0 +1,7 @@ +import re
 +def text_match_three(text):
 +        patterns = 'ab{3}?'
 +        if re.search(patterns,  text):
 +                return 'Found a match!'
 +        else:
 +                return('Not matched!')
\ No newline at end of file diff --git a/progs/a187.py b/progs/a187.py new file mode 100644 index 0000000..04b8a88 --- /dev/null +++ b/progs/a187.py @@ -0,0 +1,3 @@ +def new_tuple(test_list, test_str):
 +  res = tuple(test_list + [test_str])
 +  return (res) 
\ No newline at end of file diff --git a/progs/a188.py b/progs/a188.py new file mode 100644 index 0000000..aad0579 --- /dev/null +++ b/progs/a188.py @@ -0,0 +1,4 @@ +from math import tan, pi
 +def perimeter_polygon(s,l):
 +  perimeter = s*l
 +  return perimeter
\ No newline at end of file diff --git a/progs/a189.py b/progs/a189.py new file mode 100644 index 0000000..80ca625 --- /dev/null +++ b/progs/a189.py @@ -0,0 +1,2 @@ +def even_position(nums):
 +	return all(nums[i]%2==i%2 for i in range(len(nums)))
\ No newline at end of file diff --git a/progs/a19.py b/progs/a19.py new file mode 100644 index 0000000..25373c1 --- /dev/null +++ b/progs/a19.py @@ -0,0 +1,10 @@ +def largest_subset(a, n):
 +	dp = [0 for i in range(n)]
 +	dp[n - 1] = 1; 
 +	for i in range(n - 2, -1, -1):
 +		mxm = 0;
 +		for j in range(i + 1, n):
 +			if a[j] % a[i] == 0 or a[i] % a[j] == 0:
 +				mxm = max(mxm, dp[j])
 +		dp[i] = 1 + mxm
 +	return max(dp)
\ No newline at end of file diff --git a/progs/a190.py b/progs/a190.py new file mode 100644 index 0000000..ab9ad59 --- /dev/null +++ b/progs/a190.py @@ -0,0 +1,6 @@ +def remove_nested(test_tup):
 +  res = tuple()
 +  for count, ele in enumerate(test_tup):
 +    if not isinstance(ele, tuple):
 +      res = res + (ele, )
 +  return (res) 
\ No newline at end of file diff --git a/progs/a191.py b/progs/a191.py new file mode 100644 index 0000000..712d57c --- /dev/null +++ b/progs/a191.py @@ -0,0 +1,2 @@ +def count_list(input_list): 
 +    return len(input_list)
\ No newline at end of file diff --git a/progs/a192.py b/progs/a192.py new file mode 100644 index 0000000..a8927d6 --- /dev/null +++ b/progs/a192.py @@ -0,0 +1,14 @@ +def last(arr,x,n):
 +    low = 0
 +    high = n - 1
 +    res = -1  
 +    while (low <= high):
 +        mid = (low + high) // 2 
 +        if arr[mid] > x:
 +            high = mid - 1
 +        elif arr[mid] < x:
 +            low = mid + 1
 +        else:
 +            res = mid
 +            low = mid + 1
 +    return res
\ No newline at end of file diff --git a/progs/a193.py b/progs/a193.py new file mode 100644 index 0000000..69fa75d --- /dev/null +++ b/progs/a193.py @@ -0,0 +1,7 @@ +import re
 +def text_starta_endb(text):
 +        patterns = 'a.*?b$'
 +        if re.search(patterns,  text):
 +                return 'Found a match!'
 +        else:
 +                return('Not matched!')
\ No newline at end of file diff --git a/progs/a195.py b/progs/a195.py new file mode 100644 index 0000000..8b1e235 --- /dev/null +++ b/progs/a195.py @@ -0,0 +1,5 @@ +def return_sum(dict):
 +  sum = 0
 +  for i in dict.values():
 +    sum = sum + i
 +  return sum
\ No newline at end of file diff --git a/progs/a196.py b/progs/a196.py new file mode 100644 index 0000000..8787a9c --- /dev/null +++ b/progs/a196.py @@ -0,0 +1,6 @@ +def sum_Odd(n): 
 +    terms = (n + 1)//2
 +    sum1 = terms * terms 
 +    return sum1  
 +def sum_in_Range(l,r): 
 +    return sum_Odd(r) - sum_Odd(l - 1)
\ No newline at end of file diff --git a/progs/a197.py b/progs/a197.py new file mode 100644 index 0000000..5618288 --- /dev/null +++ b/progs/a197.py @@ -0,0 +1,5 @@ +def _sum(arr):  
 +    sum=0
 +    for i in arr: 
 +        sum = sum + i      
 +    return(sum)  
\ No newline at end of file diff --git a/progs/a198.py b/progs/a198.py new file mode 100644 index 0000000..1cfd2a8 --- /dev/null +++ b/progs/a198.py @@ -0,0 +1,3 @@ +INT_BITS = 32
 +def left_Rotate(n,d):   
 +    return (n << d)|(n >> (INT_BITS - d))  
\ No newline at end of file diff --git a/progs/a2.py b/progs/a2.py new file mode 100644 index 0000000..e1620b1 --- /dev/null +++ b/progs/a2.py @@ -0,0 +1,13 @@ +def get_ludic(n):
 +	ludics = []
 +	for i in range(1, n + 1):
 +		ludics.append(i)
 +	index = 1
 +	while(index != len(ludics)):
 +		first_ludic = ludics[index]
 +		remove_index = index + first_ludic
 +		while(remove_index < len(ludics)):
 +			ludics.remove(ludics[remove_index])
 +			remove_index = remove_index + first_ludic - 1
 +		index += 1
 +	return ludics
\ No newline at end of file diff --git a/progs/a20.py b/progs/a20.py new file mode 100644 index 0000000..295d10f --- /dev/null +++ b/progs/a20.py @@ -0,0 +1,3 @@ +def increment_numerics(test_list, K):
 +  res = [str(int(ele) + K) if ele.isdigit() else ele for ele in test_list]
 +  return res 
\ No newline at end of file diff --git a/progs/a200.py b/progs/a200.py new file mode 100644 index 0000000..cab3875 --- /dev/null +++ b/progs/a200.py @@ -0,0 +1,6 @@ +def test_three_equal(x,y,z):
 +  result= set([x,y,z])
 +  if len(result)==3:
 +    return 0
 +  else:
 +    return (4-len(result))
\ No newline at end of file diff --git a/progs/a201.py b/progs/a201.py new file mode 100644 index 0000000..5bccf71 --- /dev/null +++ b/progs/a201.py @@ -0,0 +1,5 @@ +def count_Rotation(arr,n):   
 +    for i in range (1,n): 
 +        if (arr[i] < arr[i - 1]): 
 +            return i  
 +    return 0
\ No newline at end of file diff --git a/progs/a202.py b/progs/a202.py new file mode 100644 index 0000000..a6555a4 --- /dev/null +++ b/progs/a202.py @@ -0,0 +1,7 @@ +def is_Perfect_Square(n) :
 +    i = 1
 +    while (i * i<= n):
 +        if ((n % i == 0) and (n / i == i)):
 +            return True     
 +        i = i + 1
 +    return False
\ No newline at end of file diff --git a/progs/a203.py b/progs/a203.py new file mode 100644 index 0000000..540c84c --- /dev/null +++ b/progs/a203.py @@ -0,0 +1,5 @@ +def is_Product_Even(arr,n): 
 +    for i in range(0,n): 
 +        if ((arr[i] & 1) == 0): 
 +            return True
 +    return False
\ No newline at end of file diff --git a/progs/a204.py b/progs/a204.py new file mode 100644 index 0000000..bc068f3 --- /dev/null +++ b/progs/a204.py @@ -0,0 +1,2 @@ +def max_sum_list(lists):
 + return max(lists, key=sum)
\ No newline at end of file diff --git a/progs/a205.py b/progs/a205.py new file mode 100644 index 0000000..0042207 --- /dev/null +++ b/progs/a205.py @@ -0,0 +1,12 @@ +def max_run_uppercase(test_str):
 +  cnt = 0
 +  res = 0
 +  for idx in range(0, len(test_str)):
 +    if test_str[idx].isupper():
 +      cnt += 1
 +    else:
 +      res = cnt
 +      cnt = 0
 +  if test_str[len(test_str) - 1].isupper():
 +    res = cnt
 +  return (res)
\ No newline at end of file diff --git a/progs/a206.py b/progs/a206.py new file mode 100644 index 0000000..16a664d --- /dev/null +++ b/progs/a206.py @@ -0,0 +1,3 @@ +def first_odd(nums):
 +  first_odd = next((el for el in nums if el%2!=0),-1)
 +  return first_odd
\ No newline at end of file diff --git a/progs/a207.py b/progs/a207.py new file mode 100644 index 0000000..5957ef9 --- /dev/null +++ b/progs/a207.py @@ -0,0 +1,7 @@ +def check_K(test_tup, K):
 +  res = False
 +  for ele in test_tup:
 +    if ele == K:
 +      res = True
 +      break
 +  return (res) 
\ No newline at end of file diff --git a/progs/a208.py b/progs/a208.py new file mode 100644 index 0000000..37d428e --- /dev/null +++ b/progs/a208.py @@ -0,0 +1,3 @@ +def check_smaller(test_tup1, test_tup2):
 +  res = all(x > y for x, y in zip(test_tup1, test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a209.py b/progs/a209.py new file mode 100644 index 0000000..c8c5e95 --- /dev/null +++ b/progs/a209.py @@ -0,0 +1,4 @@ +from collections import Counter
 +def count_variable(a,b,c,d):
 +  c = Counter(p=a, q=b, r=c, s=d)
 +  return list(c.elements())
\ No newline at end of file diff --git a/progs/a21.py b/progs/a21.py new file mode 100644 index 0000000..b9019f5 --- /dev/null +++ b/progs/a21.py @@ -0,0 +1,25 @@ +def get_median(arr1, arr2, n):
 +  i = 0
 +  j = 0
 +  m1 = -1
 +  m2 = -1
 +  count = 0
 +  while count < n + 1:
 +    count += 1
 +    if i == n:
 +      m1 = m2
 +      m2 = arr2[0]
 +      break
 +    elif j == n:
 +      m1 = m2
 +      m2 = arr1[0]
 +      break
 +    if arr1[i] <= arr2[j]:
 +      m1 = m2
 +      m2 = arr1[i]
 +      i += 1
 +    else:
 +      m1 = m2
 +      m2 = arr2[j]
 +      j += 1
 +  return (m1 + m2)/2
\ No newline at end of file diff --git a/progs/a210.py b/progs/a210.py new file mode 100644 index 0000000..4ee2eda --- /dev/null +++ b/progs/a210.py @@ -0,0 +1,3 @@ +def check_identical(test_list1, test_list2):
 +  res = test_list1 == test_list2
 +  return (res) 
\ No newline at end of file diff --git a/progs/a211.py b/progs/a211.py new file mode 100644 index 0000000..ad0906e --- /dev/null +++ b/progs/a211.py @@ -0,0 +1,3 @@ +import re
 +def road_rd(street):
 +  return (re.sub('Road$', 'Rd.', street))
\ No newline at end of file diff --git a/progs/a212.py b/progs/a212.py new file mode 100644 index 0000000..2435e85 --- /dev/null +++ b/progs/a212.py @@ -0,0 +1,5 @@ +def string_length(str1):
 +    count = 0
 +    for char in str1:
 +        count += 1
 +    return count
\ No newline at end of file diff --git a/progs/a213.py b/progs/a213.py new file mode 100644 index 0000000..4647273 --- /dev/null +++ b/progs/a213.py @@ -0,0 +1,3 @@ +def rombus_area(p,q):
 +  area=(p*q)/2
 +  return area
\ No newline at end of file diff --git a/progs/a214.py b/progs/a214.py new file mode 100644 index 0000000..5d645c3 --- /dev/null +++ b/progs/a214.py @@ -0,0 +1,15 @@ +def sort_by_dnf(arr, n):
 +  low=0
 +  mid=0
 +  high=n-1
 +  while mid <= high:
 +    if arr[mid] == 0:
 +      arr[low], arr[mid] = arr[mid], arr[low]
 +      low = low + 1
 +      mid = mid + 1
 +    elif arr[mid] == 1:
 +      mid = mid + 1
 +    else:
 +      arr[mid], arr[high] = arr[high], arr[mid]
 +      high = high - 1
 +  return arr
\ No newline at end of file diff --git a/progs/a215.py b/progs/a215.py new file mode 100644 index 0000000..faafb1d --- /dev/null +++ b/progs/a215.py @@ -0,0 +1,5 @@ +def clear_tuple(test_tup):
 +  temp = list(test_tup)
 +  temp.clear()
 +  test_tup = tuple(temp)
 +  return (test_tup) 
\ No newline at end of file diff --git a/progs/a217.py b/progs/a217.py new file mode 100644 index 0000000..1fa8090 --- /dev/null +++ b/progs/a217.py @@ -0,0 +1,5 @@ +def lower_ctr(str):
 +      lower_ctr= 0
 +      for i in range(len(str)):
 +          if str[i] >= 'a' and str[i] <= 'z': lower_ctr += 1     
 +      return  lower_ctr
\ No newline at end of file diff --git a/progs/a218.py b/progs/a218.py new file mode 100644 index 0000000..96ebefa --- /dev/null +++ b/progs/a218.py @@ -0,0 +1,16 @@ +def count_duplic(lists):
 +    element = []
 +    frequency = []
 +    if not lists:
 +        return element
 +    running_count = 1
 +    for i in range(len(lists)-1):
 +        if lists[i] == lists[i+1]:
 +            running_count += 1
 +        else:
 +            frequency.append(running_count)
 +            element.append(lists[i])
 +            running_count = 1
 +    frequency.append(running_count)
 +    element.append(lists[i+1])
 +    return element,frequency
 diff --git a/progs/a219.py b/progs/a219.py new file mode 100644 index 0000000..86c3447 --- /dev/null +++ b/progs/a219.py @@ -0,0 +1,5 @@ +def check_monthnum_number(monthnum1):
 +  if monthnum1 == 2:
 +    return True
 +  else:
 +    return False
\ No newline at end of file diff --git a/progs/a220.py b/progs/a220.py new file mode 100644 index 0000000..6db4614 --- /dev/null +++ b/progs/a220.py @@ -0,0 +1,4 @@ +import collections as ct
 +def merge_dictionaries(dict1,dict2):
 +    merged_dict = dict(ct.ChainMap({}, dict1, dict2))
 +    return merged_dict
\ No newline at end of file diff --git a/progs/a221.py b/progs/a221.py new file mode 100644 index 0000000..db89f03 --- /dev/null +++ b/progs/a221.py @@ -0,0 +1,23 @@ +import re
 +def pass_validity(p):
 + x = True
 + while x:  
 +    if (len(p)<6 or len(p)>12):
 +        break
 +    elif not re.search("[a-z]",p):
 +        break
 +    elif not re.search("[0-9]",p):
 +        break
 +    elif not re.search("[A-Z]",p):
 +        break
 +    elif not re.search("[$#@]",p):
 +        break
 +    elif re.search("\s",p):
 +        break
 +    else:
 +        return True
 +        x=False
 +        break
 +
 + if x:
 +    return False
\ No newline at end of file diff --git a/progs/a222.py b/progs/a222.py new file mode 100644 index 0000000..84fff5e --- /dev/null +++ b/progs/a222.py @@ -0,0 +1,11 @@ +import re 
 +def check_substring(string, sample) : 
 +  if (sample in string): 
 +      y = "\A" + sample 
 +      x = re.search(y, string) 
 +      if x : 
 +          return ("string starts with the given substring") 
 +      else : 
 +          return ("string doesnt start with the given substring") 
 +  else : 
 +      return ("entered string isnt a substring")
\ No newline at end of file diff --git a/progs/a223.py b/progs/a223.py new file mode 100644 index 0000000..2f01158 --- /dev/null +++ b/progs/a223.py @@ -0,0 +1,5 @@ +def remove_even(l):
 +    for i in l:
 +        if i % 2 == 0:
 +            l.remove(i)
 +    return l
\ No newline at end of file diff --git a/progs/a224.py b/progs/a224.py new file mode 100644 index 0000000..5b3dbe3 --- /dev/null +++ b/progs/a224.py @@ -0,0 +1,3 @@ +def access_elements(nums, list_index):
 +    result = [nums[i] for i in list_index]
 +    return result
\ No newline at end of file diff --git a/progs/a225.py b/progs/a225.py new file mode 100644 index 0000000..4578fb5 --- /dev/null +++ b/progs/a225.py @@ -0,0 +1,10 @@ +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") 
\ No newline at end of file diff --git a/progs/a226.py b/progs/a226.py new file mode 100644 index 0000000..1e92931 --- /dev/null +++ b/progs/a226.py @@ -0,0 +1,3 @@ +def sum_column(list1, C):
 +    result = sum(row[C] for row in list1)
 +    return result
\ No newline at end of file diff --git a/progs/a228.py b/progs/a228.py new file mode 100644 index 0000000..cc8171d --- /dev/null +++ b/progs/a228.py @@ -0,0 +1,9 @@ +from collections import Counter 
 +	
 +def second_frequent(input): 
 +	dict = Counter(input) 
 +	value = sorted(dict.values(), reverse=True)  
 +	second_large = value[1] 
 +	for (key, val) in dict.items(): 
 +		if val == second_large: 
 +			return (key) 
\ No newline at end of file diff --git a/progs/a229.py b/progs/a229.py new file mode 100644 index 0000000..202324e --- /dev/null +++ b/progs/a229.py @@ -0,0 +1,4 @@ +import math
 +def round_up(a, digits):
 +    n = 10**-digits
 +    return round(math.ceil(a / n) * n, digits)
\ No newline at end of file diff --git a/progs/a23.py b/progs/a23.py new file mode 100644 index 0000000..31d0446 --- /dev/null +++ b/progs/a23.py @@ -0,0 +1,2 @@ +def is_upper(string):
 +  return (string.upper())
\ No newline at end of file diff --git a/progs/a230.py b/progs/a230.py new file mode 100644 index 0000000..507faee --- /dev/null +++ b/progs/a230.py @@ -0,0 +1,7 @@ +def count_Pairs(arr,n): 
 +    cnt = 0; 
 +    for i in range(n): 
 +        for j in range(i + 1,n): 
 +            if (arr[i] == arr[j]): 
 +                cnt += 1; 
 +    return cnt; 
\ No newline at end of file diff --git a/progs/a231.py b/progs/a231.py new file mode 100644 index 0000000..76fd7fd --- /dev/null +++ b/progs/a231.py @@ -0,0 +1,5 @@ +import re 
 +def extract_max(input): 
 +	numbers = re.findall('\d+',input) 
 +	numbers = map(int,numbers) 
 +	return max(numbers)
\ No newline at end of file diff --git a/progs/a232.py b/progs/a232.py new file mode 100644 index 0000000..f7e4d3c --- /dev/null +++ b/progs/a232.py @@ -0,0 +1,5 @@ +def get_key(dict): 
 +    list = [] 
 +    for key in dict.keys(): 
 +        list.append(key)           
 +    return list
\ No newline at end of file diff --git a/progs/a233.py b/progs/a233.py new file mode 100644 index 0000000..92bbaa7 --- /dev/null +++ b/progs/a233.py @@ -0,0 +1,29 @@ +def generate_matrix(n):
 +        if n<=0:
 +            return [] 
 +        matrix=[row[:] for row in [[0]*n]*n]        
 +        row_st=0
 +        row_ed=n-1        
 +        col_st=0
 +        col_ed=n-1
 +        current=1        
 +        while (True):
 +            if current>n*n:
 +                break
 +            for c in range (col_st, col_ed+1):
 +                matrix[row_st][c]=current
 +                current+=1
 +            row_st+=1
 +            for r in range (row_st, row_ed+1):
 +                matrix[r][col_ed]=current
 +                current+=1
 +            col_ed-=1
 +            for c in range (col_ed, col_st-1, -1):
 +                matrix[row_ed][c]=current
 +                current+=1
 +            row_ed-=1
 +            for r in range (row_ed, row_st-1, -1):
 +                matrix[r][col_st]=current
 +                current+=1
 +            col_st+=1
 +        return matrix
\ No newline at end of file diff --git a/progs/a234.py b/progs/a234.py new file mode 100644 index 0000000..eaa9fed --- /dev/null +++ b/progs/a234.py @@ -0,0 +1,2 @@ +def slope(x1,y1,x2,y2): 
 +    return (float)(y2-y1)/(x2-x1)  
\ No newline at end of file diff --git a/progs/a235.py b/progs/a235.py new file mode 100644 index 0000000..7f1aeeb --- /dev/null +++ b/progs/a235.py @@ -0,0 +1,17 @@ +from sys import maxsize 
 +def max_sub_array_sum(a,size): 
 +	max_so_far = -maxsize - 1
 +	max_ending_here = 0
 +	start = 0
 +	end = 0
 +	s = 0
 +	for i in range(0,size): 
 +		max_ending_here += a[i] 
 +		if max_so_far < max_ending_here: 
 +			max_so_far = max_ending_here 
 +			start = s 
 +			end = i 
 +		if max_ending_here < 0: 
 +			max_ending_here = 0
 +			s = i+1
 +	return (end - start + 1)
\ No newline at end of file diff --git a/progs/a236.py b/progs/a236.py new file mode 100644 index 0000000..c9e2c41 --- /dev/null +++ b/progs/a236.py @@ -0,0 +1,5 @@ +def cube_Sum(n): 
 +    sum = 0   
 +    for i in range(0,n) : 
 +        sum += (2*i+1)*(2*i+1)*(2*i+1) 
 +    return sum
\ No newline at end of file diff --git a/progs/a237.py b/progs/a237.py new file mode 100644 index 0000000..db0b435 --- /dev/null +++ b/progs/a237.py @@ -0,0 +1,14 @@ +def min_Swaps(s1,s2) :  
 +    c0 = 0; c1 = 0;  
 +    for i in range(len(s1)) :  
 +        if (s1[i] == '0' and s2[i] == '1') : 
 +            c0 += 1;    
 +        elif (s1[i] == '1' and s2[i] == '0') : 
 +            c1 += 1;  
 +    result = c0 // 2 + c1 // 2;  
 +    if (c0 % 2 == 0 and c1 % 2 == 0) : 
 +        return result;  
 +    elif ((c0 + c1) % 2 == 0) : 
 +        return result + 2;  
 +    else : 
 +        return -1;  
\ No newline at end of file diff --git a/progs/a238.py b/progs/a238.py new file mode 100644 index 0000000..33773f6 --- /dev/null +++ b/progs/a238.py @@ -0,0 +1,7 @@ +def sort_tuple(tup): 
 +	n = len(tup) 
 +	for i in range(n): 
 +		for j in range(n-i-1): 
 +			if tup[j][0] > tup[j + 1][0]: 
 +				tup[j], tup[j + 1] = tup[j + 1], tup[j] 
 +	return tup
\ No newline at end of file diff --git a/progs/a239.py b/progs/a239.py new file mode 100644 index 0000000..0e69e4d --- /dev/null +++ b/progs/a239.py @@ -0,0 +1,5 @@ +def Check_Solution(a,b,c):  
 +    if b == 0:  
 +        return ("Yes")  
 +    else: 
 +        return ("No")  
\ No newline at end of file diff --git a/progs/a24.py b/progs/a24.py new file mode 100644 index 0000000..5f8bae7 --- /dev/null +++ b/progs/a24.py @@ -0,0 +1,6 @@ +def swap_List(newList): 
 +    size = len(newList) 
 +    temp = newList[0] 
 +    newList[0] = newList[size - 1] 
 +    newList[size - 1] = temp   
 +    return newList 
\ No newline at end of file diff --git a/progs/a240.py b/progs/a240.py new file mode 100644 index 0000000..a5696ee --- /dev/null +++ b/progs/a240.py @@ -0,0 +1,7 @@ +def get_inv_count(arr, n): 
 +	inv_count = 0
 +	for i in range(n): 
 +		for j in range(i + 1, n): 
 +			if (arr[i] > arr[j]): 
 +				inv_count += 1
 +	return inv_count 
\ No newline at end of file diff --git a/progs/a241.py b/progs/a241.py new file mode 100644 index 0000000..87b4697 --- /dev/null +++ b/progs/a241.py @@ -0,0 +1,9 @@ +def get_odd_occurence(arr, arr_size):
 +  for i in range(0, arr_size):
 +    count = 0
 +    for j in range(0, arr_size):
 +      if arr[i] == arr[j]:
 +        count += 1
 +    if (count % 2 != 0):
 +      return arr[i]
 +  return -1
\ No newline at end of file diff --git a/progs/a243.py b/progs/a243.py new file mode 100644 index 0000000..c928da6 --- /dev/null +++ b/progs/a243.py @@ -0,0 +1,14 @@ +def get_Number(n, k): 
 +    arr = [0] * n; 
 +    i = 0; 
 +    odd = 1; 
 +    while (odd <= n):   
 +        arr[i] = odd; 
 +        i += 1; 
 +        odd += 2;
 +    even = 2; 
 +    while (even <= n): 
 +        arr[i] = even; 
 +        i += 1;
 +        even += 2; 
 +    return arr[k - 1]; 
\ No newline at end of file diff --git a/progs/a244.py b/progs/a244.py new file mode 100644 index 0000000..016971c --- /dev/null +++ b/progs/a244.py @@ -0,0 +1,8 @@ +import math 
 +def find_Digits(n): 
 +    if (n < 0): 
 +        return 0;
 +    if (n <= 1): 
 +        return 1; 
 +    x = ((n * math.log10(n / math.e) + math.log10(2 * math.pi * n) /2.0)); 
 +    return math.floor(x) + 1; 
\ No newline at end of file diff --git a/progs/a245.py b/progs/a245.py new file mode 100644 index 0000000..ec3d8d0 --- /dev/null +++ b/progs/a245.py @@ -0,0 +1,17 @@ +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
\ No newline at end of file diff --git a/progs/a246.py b/progs/a246.py new file mode 100644 index 0000000..bcaf20c --- /dev/null +++ b/progs/a246.py @@ -0,0 +1,2 @@ +def lcopy(xs): +  return xs[:] diff --git a/progs/a247.py b/progs/a247.py new file mode 100644 index 0000000..8b70c3c --- /dev/null +++ b/progs/a247.py @@ -0,0 +1,3 @@ +def area_trapezium(base1,base2,height):
 + area = 0.5 * (base1 + base2) * height
 + return area
\ No newline at end of file diff --git a/progs/a248.py b/progs/a248.py new file mode 100644 index 0000000..7044948 --- /dev/null +++ b/progs/a248.py @@ -0,0 +1,7 @@ +def Sum(N): 
 +    SumOfPrimeDivisors = [0]*(N + 1)   
 +    for i in range(2,N + 1) : 
 +        if (SumOfPrimeDivisors[i] == 0) : 
 +            for j in range(i,N + 1,i) : 
 +                SumOfPrimeDivisors[j] += i           
 +    return SumOfPrimeDivisors[N] 
\ No newline at end of file diff --git a/progs/a249.py b/progs/a249.py new file mode 100644 index 0000000..2bb9109 --- /dev/null +++ b/progs/a249.py @@ -0,0 +1,8 @@ +def is_triangleexists(a,b,c): 
 +    if(a != 0 and b != 0 and c != 0 and (a + b + c)== 180): 
 +        if((a + b)>= c or (b + c)>= a or (a + c)>= b): 
 +            return True 
 +        else:
 +            return False
 +    else:
 +        return False
\ No newline at end of file diff --git a/progs/a25.py b/progs/a25.py new file mode 100644 index 0000000..30674f9 --- /dev/null +++ b/progs/a25.py @@ -0,0 +1,4 @@ +def triangle_area(r) :  
 +    if r < 0 : 
 +        return -1
 +    return r * r 
\ No newline at end of file diff --git a/progs/a250.py b/progs/a250.py new file mode 100644 index 0000000..3065be4 --- /dev/null +++ b/progs/a250.py @@ -0,0 +1,3 @@ +def Sum_of_Inverse_Divisors(N,Sum): 
 +    ans = float(Sum)*1.0 /float(N);  
 +    return round(ans,2); 
\ No newline at end of file diff --git a/progs/a251.py b/progs/a251.py new file mode 100644 index 0000000..d1259bd --- /dev/null +++ b/progs/a251.py @@ -0,0 +1,5 @@ +def remove_negs(num_list): 
 +    for item in num_list: 
 +        if item < 0: 
 +           num_list.remove(item) 
 +    return num_list
\ No newline at end of file diff --git a/progs/a252.py b/progs/a252.py new file mode 100644 index 0000000..7631885 --- /dev/null +++ b/progs/a252.py @@ -0,0 +1,18 @@ +import math
 +def sum_of_odd_Factors(n): 
 +    res = 1
 +    while n % 2 == 0: 
 +        n = n // 2 
 +    for i in range(3,int(math.sqrt(n) + 1)): 
 +        count = 0
 +        curr_sum = 1
 +        curr_term = 1
 +        while n % i == 0: 
 +            count+=1 
 +            n = n // i 
 +            curr_term *= i 
 +            curr_sum += curr_term    
 +        res *= curr_sum  
 +    if n >= 2: 
 +        res *= (1 + n) 
 +    return res 
\ No newline at end of file diff --git a/progs/a253.py b/progs/a253.py new file mode 100644 index 0000000..8a3f4d6 --- /dev/null +++ b/progs/a253.py @@ -0,0 +1,4 @@ +import heapq as hq
 +def raw_heap(rawheap):
 +  hq.heapify(rawheap)
 +  return rawheap
\ No newline at end of file diff --git a/progs/a254.py b/progs/a254.py new file mode 100644 index 0000000..0a18f68 --- /dev/null +++ b/progs/a254.py @@ -0,0 +1,9 @@ +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
\ No newline at end of file diff --git a/progs/a255.py b/progs/a255.py new file mode 100644 index 0000000..5b44c24 --- /dev/null +++ b/progs/a255.py @@ -0,0 +1,12 @@ +def find_Min_Swaps(arr,n) : 
 +    noOfZeroes = [0] * n 
 +    count = 0 
 +    noOfZeroes[n - 1] = 1 - arr[n - 1] 
 +    for i in range(n-2,-1,-1) : 
 +        noOfZeroes[i] = noOfZeroes[i + 1] 
 +        if (arr[i] == 0) : 
 +            noOfZeroes[i] = noOfZeroes[i] + 1
 +    for i in range(0,n) : 
 +        if (arr[i] == 1) : 
 +            count = count + noOfZeroes[i] 
 +    return count 
\ No newline at end of file diff --git a/progs/a256.py b/progs/a256.py new file mode 100644 index 0000000..14349d5 --- /dev/null +++ b/progs/a256.py @@ -0,0 +1,3 @@ +def listify_list(list1):
 +  result = list(map(list,list1)) 
 +  return result 
\ No newline at end of file diff --git a/progs/a257.py b/progs/a257.py new file mode 100644 index 0000000..e8278cd --- /dev/null +++ b/progs/a257.py @@ -0,0 +1,2 @@ +def count_list(input_list): 
 +    return (len(input_list))**2
\ No newline at end of file diff --git a/progs/a258.py b/progs/a258.py new file mode 100644 index 0000000..991e8f6 --- /dev/null +++ b/progs/a258.py @@ -0,0 +1,8 @@ +from itertools import combinations
 +def sub_lists(my_list):
 +	subs = []
 +	for i in range(0, len(my_list)+1):
 +	  temp = [list(x) for x in combinations(my_list, i)]
 +	  if len(temp)>0:
 +	    subs.extend(temp)
 +	return subs
\ No newline at end of file diff --git a/progs/a259.py b/progs/a259.py new file mode 100644 index 0000000..1f54c7a --- /dev/null +++ b/progs/a259.py @@ -0,0 +1,7 @@ +import re 
 +regex = '[a-zA-z0-9]$'
 +def check_alphanumeric(string): 
 +	if(re.search(regex, string)): 
 +		return ("Accept") 
 +	else: 
 +		return ("Discard") 
\ No newline at end of file diff --git a/progs/a26.py b/progs/a26.py new file mode 100644 index 0000000..9a4a36f --- /dev/null +++ b/progs/a26.py @@ -0,0 +1,9 @@ +def find_First_Missing(array,start,end): 
 +    if (start > end): 
 +        return end + 1
 +    if (start != array[start]): 
 +        return start; 
 +    mid = int((start + end) / 2) 
 +    if (array[mid] == mid): 
 +        return find_First_Missing(array,mid+1,end) 
 +    return find_First_Missing(array,start,mid) 
\ No newline at end of file diff --git a/progs/a261.py b/progs/a261.py new file mode 100644 index 0000000..b5592b1 --- /dev/null +++ b/progs/a261.py @@ -0,0 +1,6 @@ +from collections import Counter
 +import re
 +def n_common_words(text,n):
 +  words = re.findall('\w+',text)
 +  n_common_words= Counter(words).most_common(n)
 +  return list(n_common_words)
\ No newline at end of file diff --git a/progs/a262.py b/progs/a262.py new file mode 100644 index 0000000..dd4220b --- /dev/null +++ b/progs/a262.py @@ -0,0 +1,16 @@ +def find_longest_conseq_subseq(arr, n): 
 +	ans = 0
 +	count = 0
 +	arr.sort() 
 +	v = [] 
 +	v.append(arr[0]) 
 +	for i in range(1, n): 
 +		if (arr[i] != arr[i - 1]): 
 +			v.append(arr[i]) 
 +	for i in range(len(v)): 
 +		if (i > 0 and v[i] == v[i - 1] + 1): 
 +			count += 1
 +		else: 
 +			count = 1
 +		ans = max(ans, count) 
 +	return ans 
\ No newline at end of file diff --git a/progs/a265.py b/progs/a265.py new file mode 100644 index 0000000..51972ac --- /dev/null +++ b/progs/a265.py @@ -0,0 +1,5 @@ +def check_monthnumb(monthname2):
 +  if(monthname2=="January" or monthname2=="March"or monthname2=="May" or monthname2=="July" or monthname2=="Augest" or monthname2=="October" or monthname2=="December"):
 +    return True
 +  else:
 +    return False
\ No newline at end of file diff --git a/progs/a266.py b/progs/a266.py new file mode 100644 index 0000000..5712284 --- /dev/null +++ b/progs/a266.py @@ -0,0 +1,8 @@ +def min_Num(arr,n):  
 +    odd = 0
 +    for i in range(n): 
 +        if (arr[i] % 2): 
 +            odd += 1 
 +    if (odd % 2): 
 +        return 1
 +    return 2
\ No newline at end of file diff --git a/progs/a267.py b/progs/a267.py new file mode 100644 index 0000000..6ef029a --- /dev/null +++ b/progs/a267.py @@ -0,0 +1,9 @@ +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 
\ No newline at end of file diff --git a/progs/a268.py b/progs/a268.py new file mode 100644 index 0000000..8ef2850 --- /dev/null +++ b/progs/a268.py @@ -0,0 +1,3 @@ +def remove_list_range(list1, leftrange, rigthrange):
 +   result = [i for i in list1 if (min(i)>=leftrange and max(i)<=rigthrange)]
 +   return result
\ No newline at end of file diff --git a/progs/a27.py b/progs/a27.py new file mode 100644 index 0000000..9ebafac --- /dev/null +++ b/progs/a27.py @@ -0,0 +1,22 @@ +MAX=1000;
 +def replace_spaces(string):
 +  string=string.strip()
 +  i=len(string)
 +  space_count=string.count(' ')
 +  new_length = i + space_count*2
 +  if new_length > MAX:
 +    return -1
 +  index = new_length-1
 +  string=list(string)
 +  for f in range(i-2, new_length-2):
 +    string.append('0')
 +  for j in range(i-1, 0, -1):
 +    if string[j] == ' ':
 +      string[index] = '0'
 +      string[index-1] = '2'
 +      string[index-2] = '%'
 +      index=index-3
 +    else:
 +      string[index] = string[j]
 +      index -= 1
 +  return ''.join(string)
\ No newline at end of file diff --git a/progs/a270.py b/progs/a270.py new file mode 100644 index 0000000..02c486c --- /dev/null +++ b/progs/a270.py @@ -0,0 +1,11 @@ +def are_Rotations(string1,string2): 
 +    size1 = len(string1) 
 +    size2 = len(string2) 
 +    temp = '' 
 +    if size1 != size2: 
 +        return False
 +    temp = string1 + string1 
 +    if (temp.count(string2)> 0): 
 +        return True
 +    else: 
 +        return False
\ No newline at end of file diff --git a/progs/a271.py b/progs/a271.py new file mode 100644 index 0000000..4d762f7 --- /dev/null +++ b/progs/a271.py @@ -0,0 +1,2 @@ +def check_subset(list1,list2): 
 +    return all(map(list1.__contains__,list2)) 
\ No newline at end of file diff --git a/progs/a272.py b/progs/a272.py new file mode 100644 index 0000000..1f59edd --- /dev/null +++ b/progs/a272.py @@ -0,0 +1,5 @@ +def fibonacci(n):
 +  if n == 1 or n == 2:
 +    return 1
 +  else:
 +    return (fibonacci(n - 1) + (fibonacci(n - 2)))
\ No newline at end of file diff --git a/progs/a273.py b/progs/a273.py new file mode 100644 index 0000000..e6682bd --- /dev/null +++ b/progs/a273.py @@ -0,0 +1,9 @@ +def check_Concat(str1,str2):
 +    N = len(str1)
 +    M = len(str2)
 +    if (N % M != 0):
 +        return False
 +    for i in range(N):
 +        if (str1[i] != str2[i % M]):
 +            return False         
 +    return True
\ No newline at end of file diff --git a/progs/a274.py b/progs/a274.py new file mode 100644 index 0000000..bdfbc1d --- /dev/null +++ b/progs/a274.py @@ -0,0 +1,4 @@ +def min_difference(test_list):
 +  temp = [abs(b - a) for a, b in test_list]
 +  res = min(temp)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a275.py b/progs/a275.py new file mode 100644 index 0000000..4d22303 --- /dev/null +++ b/progs/a275.py @@ -0,0 +1,11 @@ +def lcm(x, y):
 +   if x > y:
 +       z = x
 +   else:
 +       z = y
 +   while(True):
 +       if((z % x == 0) and (z % y == 0)):
 +           lcm = z
 +           break
 +       z += 1
 +   return lcm
\ No newline at end of file diff --git a/progs/a276.py b/progs/a276.py new file mode 100644 index 0000000..b0b9702 --- /dev/null +++ b/progs/a276.py @@ -0,0 +1,3 @@ +def sort_String(str) : 
 +    str = ''.join(sorted(str)) 
 +    return (str) 
\ No newline at end of file diff --git a/progs/a277.py b/progs/a277.py new file mode 100644 index 0000000..0f01baa --- /dev/null +++ b/progs/a277.py @@ -0,0 +1,3 @@ +def check_tuples(test_tuple, K):
 +  res = all(ele in K for ele in test_tuple)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a278.py b/progs/a278.py new file mode 100644 index 0000000..f527bc9 --- /dev/null +++ b/progs/a278.py @@ -0,0 +1,7 @@ +import re
 +def text_match(text):
 +  patterns = 'a.*?b$'
 +  if re.search(patterns,  text):
 +    return ('Found a match!')
 +  else:
 +    return ('Not matched!')
\ No newline at end of file diff --git a/progs/a279.py b/progs/a279.py new file mode 100644 index 0000000..11ac149 --- /dev/null +++ b/progs/a279.py @@ -0,0 +1,7 @@ +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") 
\ No newline at end of file diff --git a/progs/a28.py b/progs/a28.py new file mode 100644 index 0000000..36453f9 --- /dev/null +++ b/progs/a28.py @@ -0,0 +1,6 @@ +def Split(list): 
 +    ev_li = [] 
 +    for i in list: 
 +        if (i % 2 == 0): 
 +            ev_li.append(i)  
 +    return ev_li
\ No newline at end of file diff --git a/progs/a280.py b/progs/a280.py new file mode 100644 index 0000000..40eab81 --- /dev/null +++ b/progs/a280.py @@ -0,0 +1,4 @@ +def sum_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)
\ No newline at end of file diff --git a/progs/a281.py b/progs/a281.py new file mode 100644 index 0000000..123fbc8 --- /dev/null +++ b/progs/a281.py @@ -0,0 +1,3 @@ +def parallelogram_perimeter(b,h):
 +  perimeter=2*(b*h)
 +  return perimeter
\ No newline at end of file diff --git a/progs/a283.py b/progs/a283.py new file mode 100644 index 0000000..dc0e112 --- /dev/null +++ b/progs/a283.py @@ -0,0 +1,6 @@ +def all_Bits_Set_In_The_Given_Range(n,l,r): 
 +    num = ((1 << r) - 1) ^ ((1 << (l - 1)) - 1) 
 +    new_num = n & num 
 +    if (num == new_num): 
 +        return True
 +    return False
\ No newline at end of file diff --git a/progs/a284.py b/progs/a284.py new file mode 100644 index 0000000..b69395b --- /dev/null +++ b/progs/a284.py @@ -0,0 +1,11 @@ +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
\ No newline at end of file diff --git a/progs/a285.py b/progs/a285.py new file mode 100644 index 0000000..86ba91e --- /dev/null +++ b/progs/a285.py @@ -0,0 +1,5 @@ +def sum_num(numbers):
 +    total = 0
 +    for x in numbers:
 +        total += x
 +    return total/len(numbers) 
\ No newline at end of file diff --git a/progs/a286.py b/progs/a286.py new file mode 100644 index 0000000..d16a073 --- /dev/null +++ b/progs/a286.py @@ -0,0 +1,5 @@ +def is_odd(n) : 
 +    if (n^1 == n-1) :
 +        return True; 
 +    else :
 +        return False; 
\ No newline at end of file diff --git a/progs/a287.py b/progs/a287.py new file mode 100644 index 0000000..821e927 --- /dev/null +++ b/progs/a287.py @@ -0,0 +1,4 @@ +def substract_elements(test_tup1, test_tup2):
 +  res = tuple(tuple(a - b for a, b in zip(tup1, tup2))
 +   for tup1, tup2 in zip(test_tup1, test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a288.py b/progs/a288.py new file mode 100644 index 0000000..e0b3181 --- /dev/null +++ b/progs/a288.py @@ -0,0 +1,4 @@ +def reverse_list_lists(lists):
 +    for l in lists:
 +        l.sort(reverse = True)
 +    return lists 
\ No newline at end of file diff --git a/progs/a289.py b/progs/a289.py new file mode 100644 index 0000000..058cdca --- /dev/null +++ b/progs/a289.py @@ -0,0 +1,5 @@ +def find_Extra(arr1,arr2,n) : 
 +    for i in range(0, n) : 
 +        if (arr1[i] != arr2[i]) : 
 +            return i 
 +    return n 
\ No newline at end of file diff --git a/progs/a290.py b/progs/a290.py new file mode 100644 index 0000000..98bab92 --- /dev/null +++ b/progs/a290.py @@ -0,0 +1,7 @@ +def same_Length(A,B): 
 +    while (A > 0 and B > 0): 
 +        A = A / 10; 
 +        B = B / 10; 
 +    if (A == 0 and B == 0): 
 +        return True; 
 +    return False; 
\ No newline at end of file diff --git a/progs/a291.py b/progs/a291.py new file mode 100644 index 0000000..9bc037f --- /dev/null +++ b/progs/a291.py @@ -0,0 +1,3 @@ +import re
 +def remove_spaces(text):
 + return (re.sub(' +',' ',text))
\ No newline at end of file diff --git a/progs/a292.py b/progs/a292.py new file mode 100644 index 0000000..3230284 --- /dev/null +++ b/progs/a292.py @@ -0,0 +1,2 @@ +def Extract(lst): 
 +    return [item[-1] for item in lst] 
\ No newline at end of file diff --git a/progs/a293.py b/progs/a293.py new file mode 100644 index 0000000..406a267 --- /dev/null +++ b/progs/a293.py @@ -0,0 +1,3 @@ +def float_to_tuple(test_str):
 +  res = tuple(map(float, test_str.split(', ')))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a294.py b/progs/a294.py new file mode 100644 index 0000000..cafc3e7 --- /dev/null +++ b/progs/a294.py @@ -0,0 +1,11 @@ +def max_sum_subseq(A):
 +    n = len(A)
 +    if n == 1:
 +        return A[0]
 +    look_up = [None] * n
 +    look_up[0] = A[0]
 +    look_up[1] = max(A[0], A[1])
 +    for i in range(2, n):
 +        look_up[i] = max(look_up[i - 1], look_up[i - 2] + A[i])
 +        look_up[i] = max(look_up[i], A[i])
 +    return look_up[n - 1]
\ No newline at end of file diff --git a/progs/a295.py b/progs/a295.py new file mode 100644 index 0000000..7a18a0c --- /dev/null +++ b/progs/a295.py @@ -0,0 +1,4 @@ +def last(n):
 +   return n[-1]
 +def sort_list_last(tuples):
 +  return sorted(tuples, key=last)
\ No newline at end of file diff --git a/progs/a296.py b/progs/a296.py new file mode 100644 index 0000000..b4da731 --- /dev/null +++ b/progs/a296.py @@ -0,0 +1,6 @@ +def is_Word_Present(sentence,word): 
 +    s = sentence.split(" ") 
 +    for i in s:  
 +        if (i == word): 
 +            return True
 +    return False
\ No newline at end of file diff --git a/progs/a297.py b/progs/a297.py new file mode 100644 index 0000000..8fc6032 --- /dev/null +++ b/progs/a297.py @@ -0,0 +1,4 @@ +from itertools import groupby 
 +def extract_elements(numbers, n):
 +    result = [i for i, j in groupby(numbers) if len(list(j)) == n] 
 +    return result
\ No newline at end of file diff --git a/progs/a298.py b/progs/a298.py new file mode 100644 index 0000000..a42caf4 --- /dev/null +++ b/progs/a298.py @@ -0,0 +1,8 @@ +def check(arr,n): 
 +    g = 0 
 +    for i in range(1,n): 
 +        if (arr[i] - arr[i - 1] > 0 and g == 1): 
 +            return False
 +        if (arr[i] - arr[i] < 0): 
 +            g = 1
 +    return True
\ No newline at end of file diff --git a/progs/a3.py b/progs/a3.py new file mode 100644 index 0000000..3938b7a --- /dev/null +++ b/progs/a3.py @@ -0,0 +1,2 @@ +def reverse_words(s):
 +        return ' '.join(reversed(s.split()))
\ No newline at end of file diff --git a/progs/a30.py b/progs/a30.py new file mode 100644 index 0000000..f67ff9e --- /dev/null +++ b/progs/a30.py @@ -0,0 +1,7 @@ +import re
 +text = 'Python Exercises'
 +def replace_spaces(text):
 +  text =text.replace (" ", "_")
 +  return (text)
 +  text =text.replace ("_", " ")
 +  return (text)
\ No newline at end of file diff --git a/progs/a300.py b/progs/a300.py new file mode 100644 index 0000000..46b0b05 --- /dev/null +++ b/progs/a300.py @@ -0,0 +1,12 @@ +def smallest_multiple(n):
 +    if (n<=2):
 +      return n
 +    i = n * 2
 +    factors = [number  for number in range(n, 1, -1) if number * 2 > n]
 +    while True:
 +        for a in factors:
 +            if i % a != 0:
 +                i += n
 +                break
 +            if (a == factors[-1] and i % a == 0):
 +                return i
\ No newline at end of file diff --git a/progs/a301.py b/progs/a301.py new file mode 100644 index 0000000..8585627 --- /dev/null +++ b/progs/a301.py @@ -0,0 +1,4 @@ +from collections import Counter
 +def add_dict(d1,d2):
 +   add_dict = Counter(d1) + Counter(d2)
 +   return add_dict
\ No newline at end of file diff --git a/progs/a302.py b/progs/a302.py new file mode 100644 index 0000000..b8c8c7c --- /dev/null +++ b/progs/a302.py @@ -0,0 +1,9 @@ +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;  
\ No newline at end of file diff --git a/progs/a303.py b/progs/a303.py new file mode 100644 index 0000000..5a68147 --- /dev/null +++ b/progs/a303.py @@ -0,0 +1,5 @@ +def even_num(x):
 +  if x%2==0:
 +     return True
 +  else:
 +    return False
\ No newline at end of file diff --git a/progs/a304.py b/progs/a304.py new file mode 100644 index 0000000..06d4c9b --- /dev/null +++ b/progs/a304.py @@ -0,0 +1,7 @@ +def factorial(start,end): 
 +    res = 1 
 +    for i in range(start,end + 1): 
 +        res *= i      
 +    return res 
 +def sum_of_square(n): 
 +   return int(factorial(n + 1, 2 * n)  /factorial(1, n)) 
\ No newline at end of file diff --git a/progs/a306.py b/progs/a306.py new file mode 100644 index 0000000..bd19290 --- /dev/null +++ b/progs/a306.py @@ -0,0 +1,5 @@ +def lucky_num(n):
 + List=range(-1,n*n+9,2)
 + i=2
 + while List[i:]:List=sorted(set(List)-set(List[List[i]::List[i]]));i+=1
 + return List[1:n+1]
\ No newline at end of file diff --git a/progs/a307.py b/progs/a307.py new file mode 100644 index 0000000..98e7e7e --- /dev/null +++ b/progs/a307.py @@ -0,0 +1,5 @@ +def find_fixed_point(arr, n): 
 +	for i in range(n): 
 +		if arr[i] is i: 
 +			return i 
 +	return -1
\ No newline at end of file diff --git a/progs/a308.py b/progs/a308.py new file mode 100644 index 0000000..dfb3630 --- /dev/null +++ b/progs/a308.py @@ -0,0 +1,4 @@ +def previous_palindrome(num):
 +    for x in range(num-1,0,-1):
 +        if str(x) == str(x)[::-1]:
 +            return x
\ No newline at end of file diff --git a/progs/a31.py b/progs/a31.py new file mode 100644 index 0000000..85a4db1 --- /dev/null +++ b/progs/a31.py @@ -0,0 +1,5 @@ +def move_zero(num_list):
 +    a = [0 for i in range(num_list.count(0))]
 +    x = [ i for i in num_list if i != 0]
 +    x.extend(a)
 +    return (x)
\ No newline at end of file diff --git a/progs/a310.py b/progs/a310.py new file mode 100644 index 0000000..09962eb --- /dev/null +++ b/progs/a310.py @@ -0,0 +1,4 @@ +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])
\ No newline at end of file diff --git a/progs/a311.py b/progs/a311.py new file mode 100644 index 0000000..aafdf9c --- /dev/null +++ b/progs/a311.py @@ -0,0 +1,15 @@ +def binomial_coeff(n, k): 
 +	C = [[0 for j in range(k + 1)] 
 +			for i in range(n + 1)] 
 +	for i in range(0, n + 1): 
 +		for j in range(0, min(i, k) + 1): 
 +			if (j == 0 or j == i): 
 +				C[i][j] = 1
 +			else: 
 +				C[i][j] = (C[i - 1][j - 1] 
 +							+ C[i - 1][j]) 
 +	return C[n][k] 
 +def lobb_num(n, m): 
 +	return (((2 * m + 1) *
 +		binomial_coeff(2 * n, m + n)) 
 +					/ (m + n + 1))
\ No newline at end of file diff --git a/progs/a313.py b/progs/a313.py new file mode 100644 index 0000000..a97767d --- /dev/null +++ b/progs/a313.py @@ -0,0 +1,7 @@ +def is_Two_Alter(s):  
 +    for i in range (len( s) - 2) : 
 +        if (s[i] != s[i + 2]) : 
 +            return False
 +    if (s[0] == s[1]): 
 +        return False
 +    return True
\ No newline at end of file diff --git a/progs/a315.py b/progs/a315.py new file mode 100644 index 0000000..6a79458 --- /dev/null +++ b/progs/a315.py @@ -0,0 +1,8 @@ +def find_triplet_array(A, arr_size, sum): 
 +	for i in range( 0, arr_size-2): 
 +		for j in range(i + 1, arr_size-1): 
 +			for k in range(j + 1, arr_size): 
 +				if A[i] + A[j] + A[k] == sum: 
 +					return  A[i],A[j],A[k] 
 +					return True
 +	return False
\ No newline at end of file diff --git a/progs/a316.py b/progs/a316.py new file mode 100644 index 0000000..728423f --- /dev/null +++ b/progs/a316.py @@ -0,0 +1,7 @@ +import re
 +def text_uppercase_lowercase(text):
 +        patterns = '[A-Z]+[a-z]+$'
 +        if re.search(patterns, text):
 +                return 'Found a match!'
 +        else:
 +                return ('Not matched!')
\ No newline at end of file diff --git a/progs/a317.py b/progs/a317.py new file mode 100644 index 0000000..fd8b236 --- /dev/null +++ b/progs/a317.py @@ -0,0 +1,10 @@ +def coin_change(S, m, n): 
 +    table = [[0 for x in range(m)] for x in range(n+1)] 
 +    for i in range(m): 
 +        table[0][i] = 1
 +    for i in range(1, n+1): 
 +        for j in range(m): 
 +            x = table[i - S[j]][j] if i-S[j] >= 0 else 0
 +            y = table[i][j-1] if j >= 1 else 0 
 +            table[i][j] = x + y   
 +    return table[n][m-1] 
\ No newline at end of file diff --git a/progs/a318.py b/progs/a318.py new file mode 100644 index 0000000..1af0324 --- /dev/null +++ b/progs/a318.py @@ -0,0 +1,5 @@ +def multiply_list(items):
 +    tot = 1
 +    for x in items:
 +        tot *= x
 +    return tot
\ No newline at end of file diff --git a/progs/a319.py b/progs/a319.py new file mode 100644 index 0000000..670d11a --- /dev/null +++ b/progs/a319.py @@ -0,0 +1,3 @@ +def remove_tuple(test_list):
 +  res = [sub for sub in test_list if not all(ele == None for ele in sub)]
 +  return (str(res)) 
\ No newline at end of file diff --git a/progs/a32.py b/progs/a32.py new file mode 100644 index 0000000..a29e4da --- /dev/null +++ b/progs/a32.py @@ -0,0 +1,6 @@ +def pair_OR_Sum(arr,n) : 
 +    ans = 0 
 +    for i in range(0,n) :    
 +        for j in range(i + 1,n) :   
 +            ans = ans + (arr[i] ^ arr[j])          
 +    return ans 
\ No newline at end of file diff --git a/progs/a320.py b/progs/a320.py new file mode 100644 index 0000000..b89f995 --- /dev/null +++ b/progs/a320.py @@ -0,0 +1,3 @@ +def chunk_tuples(test_tup, N):
 +  res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)]
 +  return (res) 
\ No newline at end of file diff --git a/progs/a321.py b/progs/a321.py new file mode 100644 index 0000000..35bcf86 --- /dev/null +++ b/progs/a321.py @@ -0,0 +1,10 @@ +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   
\ No newline at end of file diff --git a/progs/a322.py b/progs/a322.py new file mode 100644 index 0000000..9e70169 --- /dev/null +++ b/progs/a322.py @@ -0,0 +1,8 @@ +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))
\ No newline at end of file diff --git a/progs/a323.py b/progs/a323.py new file mode 100644 index 0000000..d2f04c7 --- /dev/null +++ b/progs/a323.py @@ -0,0 +1,4 @@ +def max_of_two( x, y ):
 +    if x > y:
 +        return x
 +    return y
\ No newline at end of file diff --git a/progs/a324.py b/progs/a324.py new file mode 100644 index 0000000..6c73af4 --- /dev/null +++ b/progs/a324.py @@ -0,0 +1,6 @@ +def mutiple_tuple(nums):
 +    temp = list(nums)
 +    product = 1 
 +    for x in temp:
 +        product *= x
 +    return product
\ No newline at end of file diff --git a/progs/a325.py b/progs/a325.py new file mode 100644 index 0000000..aaf56a5 --- /dev/null +++ b/progs/a325.py @@ -0,0 +1,13 @@ +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))
\ No newline at end of file diff --git a/progs/a328.py b/progs/a328.py new file mode 100644 index 0000000..1092955 --- /dev/null +++ b/progs/a328.py @@ -0,0 +1,3 @@ +def count_tuplex(tuplex,value):  
 +  count = tuplex.count(value)
 +  return count
\ No newline at end of file diff --git a/progs/a329.py b/progs/a329.py new file mode 100644 index 0000000..52e24d9 --- /dev/null +++ b/progs/a329.py @@ -0,0 +1,7 @@ +import re
 +def text_match(text):
 +        patterns = 'ab*?'
 +        if re.search(patterns,  text):
 +                return ('Found a match!')
 +        else:
 +                return ('Not matched!')
\ No newline at end of file diff --git a/progs/a33.py b/progs/a33.py new file mode 100644 index 0000000..77b4c3e --- /dev/null +++ b/progs/a33.py @@ -0,0 +1,6 @@ +def even_Power_Sum(n): 
 +    sum = 0; 
 +    for i in range(1,n + 1): 
 +        j = 2*i; 
 +        sum = sum + (j*j*j*j); 
 +    return sum; 
\ No newline at end of file diff --git a/progs/a330.py b/progs/a330.py new file mode 100644 index 0000000..049a415 --- /dev/null +++ b/progs/a330.py @@ -0,0 +1,5 @@ +import math 
 +def sum_series(number):
 + total = 0
 + total = math.pow((number * (number + 1)) /2, 2)
 + return total
\ No newline at end of file diff --git a/progs/a331.py b/progs/a331.py new file mode 100644 index 0000000..1a150e4 --- /dev/null +++ b/progs/a331.py @@ -0,0 +1,6 @@ +def remove_duplic_list(l):
 +    temp = []
 +    for x in l:
 +        if x not in temp:
 +            temp.append(x)
 +    return temp
\ No newline at end of file diff --git a/progs/a333.py b/progs/a333.py new file mode 100644 index 0000000..aa38d2b --- /dev/null +++ b/progs/a333.py @@ -0,0 +1,4 @@ +def dealnnoy_num(n, m): 
 +	if (m == 0 or n == 0) : 
 +		return 1
 +	return dealnnoy_num(m - 1, n) + dealnnoy_num(m - 1, n - 1) + dealnnoy_num(m, n - 1)
\ No newline at end of file diff --git a/progs/a334.py b/progs/a334.py new file mode 100644 index 0000000..b481a67 --- /dev/null +++ b/progs/a334.py @@ -0,0 +1,4 @@ +def series_sum(number):
 + total = 0
 + total = (number * (number + 1) * (2 * number + 1)) / 6
 + return total
\ No newline at end of file diff --git a/progs/a335.py b/progs/a335.py new file mode 100644 index 0000000..d6baf7d --- /dev/null +++ b/progs/a335.py @@ -0,0 +1,4 @@ +def re_arrange_tuples(test_list, ord_list):
 +  temp = dict(test_list)
 +  res = [(key, temp[key]) for key in ord_list]
 +  return (res) 
\ No newline at end of file diff --git a/progs/a336.py b/progs/a336.py new file mode 100644 index 0000000..7735d02 --- /dev/null +++ b/progs/a336.py @@ -0,0 +1,5 @@ +from collections import Counter 
 +def max_char(str1):
 +    temp = Counter(str1) 
 +    max_char = max(temp, key = temp.get)
 +    return max_char
\ No newline at end of file diff --git a/progs/a337.py b/progs/a337.py new file mode 100644 index 0000000..ca3e3bd --- /dev/null +++ b/progs/a337.py @@ -0,0 +1,27 @@ +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]
\ No newline at end of file diff --git a/progs/a339.py b/progs/a339.py new file mode 100644 index 0000000..9a57403 --- /dev/null +++ b/progs/a339.py @@ -0,0 +1,25 @@ +def heap_sort(arr):
 +    heapify(arr)  
 +    end = len(arr) - 1
 +    while end > 0:
 +        arr[end], arr[0] = arr[0], arr[end]
 +        shift_down(arr, 0, end - 1)
 +        end -= 1
 +    return arr
 +
 +def heapify(arr):
 +    start = len(arr) // 2
 +    while start >= 0:
 +        shift_down(arr, start, len(arr) - 1)
 +        start -= 1
 +def shift_down(arr, start, end):
 +    root = start
 +    while root * 2 + 1 <= end:
 +        child = root * 2 + 1
 +        if child + 1 <= end and arr[child] < arr[child + 1]:
 +            child += 1
 +        if child <= end and arr[root] < arr[child]:
 +            arr[root], arr[child] = arr[child], arr[root]
 +            root = child
 +        else:
 +            return
 diff --git a/progs/a34.py b/progs/a34.py new file mode 100644 index 0000000..b3b4db3 --- /dev/null +++ b/progs/a34.py @@ -0,0 +1,6 @@ +import heapq as hq
 +def heap_sort(iterable):
 +    h = []
 +    for value in iterable:
 +        hq.heappush(h, value)
 +    return [hq.heappop(h) for i in range(len(h))]
\ No newline at end of file diff --git a/progs/a340.py b/progs/a340.py new file mode 100644 index 0000000..1bde7c2 --- /dev/null +++ b/progs/a340.py @@ -0,0 +1,7 @@ +def count_elim(num):
 +  count_elim = 0
 +  for n in num:
 +    if isinstance(n, tuple):
 +        break
 +    count_elim += 1
 +  return count_elim
\ No newline at end of file diff --git a/progs/a341.py b/progs/a341.py new file mode 100644 index 0000000..ab12ee3 --- /dev/null +++ b/progs/a341.py @@ -0,0 +1,7 @@ +def check_element(test_tup, check_list):
 +  res = False
 +  for ele in check_list:
 +    if ele in test_tup:
 +      res = True
 +      break
 +  return (res) 
\ No newline at end of file diff --git a/progs/a342.py b/progs/a342.py new file mode 100644 index 0000000..0d2e9eb --- /dev/null +++ b/progs/a342.py @@ -0,0 +1,4 @@ +from heapq import merge
 +def combine_lists(num1,num2):
 +  combine_lists=list(merge(num1, num2))
 +  return combine_lists
\ No newline at end of file diff --git a/progs/a343.py b/progs/a343.py new file mode 100644 index 0000000..fef1d4f --- /dev/null +++ b/progs/a343.py @@ -0,0 +1,4 @@ +import re
 +def num_position(text):
 + for m in re.finditer("\d+", text):
 +    return m.start()
\ No newline at end of file diff --git a/progs/a344.py b/progs/a344.py new file mode 100644 index 0000000..fdc0102 --- /dev/null +++ b/progs/a344.py @@ -0,0 +1,3 @@ +def tuple_to_set(t):
 +  s = set(t)
 +  return (s) 
\ No newline at end of file diff --git a/progs/a345.py b/progs/a345.py new file mode 100644 index 0000000..97c90fc --- /dev/null +++ b/progs/a345.py @@ -0,0 +1,4 @@ +from collections import Counter 
 +def most_common_elem(s,a):
 +  most_common_elem=Counter(s).most_common(a)
 +  return most_common_elem
\ No newline at end of file diff --git a/progs/a346.py b/progs/a346.py new file mode 100644 index 0000000..d7e0e19 --- /dev/null +++ b/progs/a346.py @@ -0,0 +1,6 @@ +def len_log(list1):
 +    min=len(list1[0])
 +    for i in list1:
 +        if len(i)<min:
 +            min=len(i)
 +    return min
\ No newline at end of file diff --git a/progs/a347.py b/progs/a347.py new file mode 100644 index 0000000..11398c4 --- /dev/null +++ b/progs/a347.py @@ -0,0 +1,3 @@ +def get_item(tup1,index):
 +  item = tup1[index]
 +  return item
\ No newline at end of file diff --git a/progs/a348.py b/progs/a348.py new file mode 100644 index 0000000..8d1cbe4 --- /dev/null +++ b/progs/a348.py @@ -0,0 +1,5 @@ +def count_digs(tup):
 +  return sum([len(str(ele)) for ele in tup ]) 
 +def sort_list(test_list):
 +  test_list.sort(key = count_digs)
 +  return (str(test_list))
\ No newline at end of file diff --git a/progs/a349.py b/progs/a349.py new file mode 100644 index 0000000..a53b049 --- /dev/null +++ b/progs/a349.py @@ -0,0 +1,26 @@ +def chinese_zodiac(year):
 + if (year - 2000) % 12 == 0:
 +     sign = 'Dragon'
 + elif (year - 2000) % 12 == 1:
 +     sign = 'Snake'
 + elif (year - 2000) % 12 == 2:
 +     sign = 'Horse'
 + elif (year - 2000) % 12 == 3:
 +     sign = 'sheep'
 + elif (year - 2000) % 12 == 4:
 +     sign = 'Monkey'
 + elif (year - 2000) % 12 == 5:
 +     sign = 'Rooster'
 + elif (year - 2000) % 12 == 6:
 +     sign = 'Dog'
 + elif (year - 2000) % 12 == 7:
 +     sign = 'Pig'
 + elif (year - 2000) % 12 == 8:
 +     sign = 'Rat'
 + elif (year - 2000) % 12 == 9:
 +     sign = 'Ox'
 + elif (year - 2000) % 12 == 10:
 +     sign = 'Tiger'
 + else:
 +     sign = 'Hare'
 + return sign
\ No newline at end of file diff --git a/progs/a35.py b/progs/a35.py new file mode 100644 index 0000000..582eeb0 --- /dev/null +++ b/progs/a35.py @@ -0,0 +1,5 @@ +def Check_Solution(a,b,c): 
 +    if (a == c): 
 +        return ("Yes"); 
 +    else: 
 +        return ("No"); 
\ No newline at end of file diff --git a/progs/a350.py b/progs/a350.py new file mode 100644 index 0000000..8fec186 --- /dev/null +++ b/progs/a350.py @@ -0,0 +1,4 @@ +def max_similar_indices(test_list1, test_list2):
 +  res = [(max(x[0], y[0]), max(x[1], y[1]))
 +   for x, y in zip(test_list1, test_list2)]
 +  return (res) 
\ No newline at end of file diff --git a/progs/a351.py b/progs/a351.py new file mode 100644 index 0000000..ada06e6 --- /dev/null +++ b/progs/a351.py @@ -0,0 +1,9 @@ +def nCr_mod_p(n, r, p): 
 +	if (r > n- r): 
 +		r = n - r 
 +	C = [0 for i in range(r + 1)] 
 +	C[0] = 1 
 +	for i in range(1, n + 1): 
 +		for j in range(min(i, r), 0, -1): 
 +			C[j] = (C[j] + C[j-1]) % p 
 +	return C[r] 
\ No newline at end of file diff --git a/progs/a352.py b/progs/a352.py new file mode 100644 index 0000000..93b6c11 --- /dev/null +++ b/progs/a352.py @@ -0,0 +1,12 @@ +def subset(ar, n): 
 +    res = 0
 +    ar.sort() 
 +    for i in range(0, n) : 
 +        count = 1
 +        for i in range(n - 1): 
 +            if ar[i] == ar[i + 1]: 
 +                count+=1
 +            else: 
 +                break 
 +        res = max(res, count)  
 +    return res 
\ No newline at end of file diff --git a/progs/a353.py b/progs/a353.py new file mode 100644 index 0000000..4bda5b5 --- /dev/null +++ b/progs/a353.py @@ -0,0 +1,6 @@ +def profit_amount(actual_cost,sale_amount): 
 + if(actual_cost > sale_amount):
 +    amount = actual_cost - sale_amount
 +    return amount
 + else:
 +    return None
\ No newline at end of file diff --git a/progs/a354.py b/progs/a354.py new file mode 100644 index 0000000..e7555e0 --- /dev/null +++ b/progs/a354.py @@ -0,0 +1,3 @@ +def is_abundant(n):
 +    fctrsum = sum([fctr for fctr in range(1, n) if n % fctr == 0])
 +    return fctrsum > n
\ No newline at end of file diff --git a/progs/a355.py b/progs/a355.py new file mode 100644 index 0000000..17669e0 --- /dev/null +++ b/progs/a355.py @@ -0,0 +1,3 @@ +import re
 +def split_list(text):
 +  return (re.findall('[A-Z][^A-Z]*', text))
\ No newline at end of file diff --git a/progs/a356.py b/progs/a356.py new file mode 100644 index 0000000..52071f4 --- /dev/null +++ b/progs/a356.py @@ -0,0 +1,3 @@ +import math
 +def get_First_Set_Bit_Pos(n):
 +     return math.log2(n&-n)+1
\ No newline at end of file diff --git a/progs/a358.py b/progs/a358.py new file mode 100644 index 0000000..9da0de3 --- /dev/null +++ b/progs/a358.py @@ -0,0 +1,2 @@ +def Average(lst): 
 +    return sum(lst) / len(lst) 
\ No newline at end of file diff --git a/progs/a359.py b/progs/a359.py new file mode 100644 index 0000000..e984df9 --- /dev/null +++ b/progs/a359.py @@ -0,0 +1,6 @@ +def get_noOfways(n):
 +    if (n == 0):
 +        return 0;
 +    if (n == 1):
 +        return 1; 
 +    return get_noOfways(n - 1) + get_noOfways(n - 2);
\ No newline at end of file diff --git a/progs/a36.py b/progs/a36.py new file mode 100644 index 0000000..79bef31 --- /dev/null +++ b/progs/a36.py @@ -0,0 +1,5 @@ +def noprofit_noloss(actual_cost,sale_amount): 
 +  if(sale_amount == actual_cost):
 +    return True
 +  else:
 +    return False
\ No newline at end of file diff --git a/progs/a361.py b/progs/a361.py new file mode 100644 index 0000000..e15b5df --- /dev/null +++ b/progs/a361.py @@ -0,0 +1,5 @@ +def sum_Natural(n): 
 +    sum = (n * (n + 1)) 
 +    return int(sum) 
 +def sum_Even(l,r): 
 +    return (sum_Natural(int(r / 2)) - sum_Natural(int((l - 1) / 2))) 
\ No newline at end of file diff --git a/progs/a362.py b/progs/a362.py new file mode 100644 index 0000000..1dec489 --- /dev/null +++ b/progs/a362.py @@ -0,0 +1,8 @@ +def discriminant_value(x,y,z):
 +    discriminant = (y**2) - (4*x*z)
 +    if discriminant > 0:
 +        return ("Two solutions",discriminant)
 +    elif discriminant == 0:
 +        return ("one solution",discriminant)
 +    elif discriminant < 0:
 +        return ("no real solution",discriminant)
\ No newline at end of file diff --git a/progs/a363.py b/progs/a363.py new file mode 100644 index 0000000..e1cd792 --- /dev/null +++ b/progs/a363.py @@ -0,0 +1,7 @@ +def word_len(s): 
 +    s = s.split(' ')   
 +    for word in s:    
 +        if len(word)%2==0: 
 +            return True  
 +        else:
 +          return False
\ No newline at end of file diff --git a/progs/a365.py b/progs/a365.py new file mode 100644 index 0000000..b7866e8 --- /dev/null +++ b/progs/a365.py @@ -0,0 +1,3 @@ +def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]
 +   tuple1 = [t for t in tuple1 if t]
 +   return tuple1
\ No newline at end of file diff --git a/progs/a366.py b/progs/a366.py new file mode 100644 index 0000000..4d08103 --- /dev/null +++ b/progs/a366.py @@ -0,0 +1,5 @@ +def check(string): 
 +  if len(set(string).intersection("AEIOUaeiou"))>=5: 
 +    return ('accepted') 
 +  else: 
 +    return ("not accepted") 
\ No newline at end of file diff --git a/progs/a367.py b/progs/a367.py new file mode 100644 index 0000000..242a737 --- /dev/null +++ b/progs/a367.py @@ -0,0 +1,3 @@ +def floor_Max(A,B,N):
 +    x = min(B - 1,N)
 +    return (A*x) // B
\ No newline at end of file diff --git a/progs/a368.py b/progs/a368.py new file mode 100644 index 0000000..d3171fd --- /dev/null +++ b/progs/a368.py @@ -0,0 +1,9 @@ +def join_tuples(test_list):
 +  res = []
 +  for sub in test_list:
 +    if res and res[-1][0] == sub[0]:
 +      res[-1].extend(sub[1:])
 +    else:
 +      res.append([ele for ele in sub])
 +  res = list(map(tuple, res))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a369.py b/progs/a369.py new file mode 100644 index 0000000..840be06 --- /dev/null +++ b/progs/a369.py @@ -0,0 +1,4 @@ +def min_of_two( x, y ):
 +    if x < y:
 +        return x
 +    return y
\ No newline at end of file diff --git a/progs/a37.py b/progs/a37.py new file mode 100644 index 0000000..384f34a --- /dev/null +++ b/progs/a37.py @@ -0,0 +1,4 @@ +import math
 +def wind_chill(v,t):
 + windchill = 13.12 + 0.6215*t -  11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16)
 + return int(round(windchill, 0))
\ No newline at end of file diff --git a/progs/a370.py b/progs/a370.py new file mode 100644 index 0000000..9747783 --- /dev/null +++ b/progs/a370.py @@ -0,0 +1,15 @@ +def maximum_segments(n, a, b, c) : 
 +	dp = [-1] * (n + 10) 
 +	dp[0] = 0
 +	for i in range(0, n) : 
 +		if (dp[i] != -1) : 
 +			if(i + a <= n ): 
 +				dp[i + a] = max(dp[i] + 1, 
 +							dp[i + a]) 
 +			if(i + b <= n ): 
 +				dp[i + b] = max(dp[i] + 1, 
 +							dp[i + b]) 
 +			if(i + c <= n ): 
 +				dp[i + c] = max(dp[i] + 1, 
 +							dp[i + c]) 
 +	return dp[n]
\ No newline at end of file diff --git a/progs/a371.py b/progs/a371.py new file mode 100644 index 0000000..9b6b257 --- /dev/null +++ b/progs/a371.py @@ -0,0 +1,3 @@ +def concatenate_nested(test_tup1, test_tup2):
 +  res = test_tup1 + test_tup2
 +  return (res) 
\ No newline at end of file diff --git a/progs/a372.py b/progs/a372.py new file mode 100644 index 0000000..c5d6326 --- /dev/null +++ b/progs/a372.py @@ -0,0 +1,3 @@ +def left_rotate(s,d):
 +    tmp = s[d : ] + s[0 : d]
 +    return tmp  
\ No newline at end of file diff --git a/progs/a373.py b/progs/a373.py new file mode 100644 index 0000000..fcf09d1 --- /dev/null +++ b/progs/a373.py @@ -0,0 +1,10 @@ +def min_sum_path(A): 
 +	memo = [None] * len(A) 
 +	n = len(A) - 1
 +	for i in range(len(A[n])): 
 +		memo[i] = A[n][i] 
 +	for i in range(len(A) - 2, -1,-1): 
 +		for j in range( len(A[i])): 
 +			memo[j] = A[i][j] + min(memo[j], 
 +									memo[j + 1]) 
 +	return memo[0]
\ No newline at end of file diff --git a/progs/a374.py b/progs/a374.py new file mode 100644 index 0000000..3b3eabb --- /dev/null +++ b/progs/a374.py @@ -0,0 +1,10 @@ +def remove_Occ(s,ch): 
 +    for i in range(len(s)): 
 +        if (s[i] == ch): 
 +            s = s[0 : i] + s[i + 1:] 
 +            break
 +    for i in range(len(s) - 1,-1,-1):  
 +        if (s[i] == ch): 
 +            s = s[0 : i] + s[i + 1:] 
 +            break
 +    return s 
\ No newline at end of file diff --git a/progs/a375.py b/progs/a375.py new file mode 100644 index 0000000..0323fd4 --- /dev/null +++ b/progs/a375.py @@ -0,0 +1,3 @@ +def sort_matrix(M):
 +    result = sorted(M, key=sum)
 +    return result
\ No newline at end of file diff --git a/progs/a376.py b/progs/a376.py new file mode 100644 index 0000000..f6a1f4e --- /dev/null +++ b/progs/a376.py @@ -0,0 +1,5 @@ +from collections import Counter
 +def count_common(words):
 +  word_counts = Counter(words)
 +  top_four = word_counts.most_common(4)
 +  return (top_four)
 diff --git a/progs/a377.py b/progs/a377.py new file mode 100644 index 0000000..64c506a --- /dev/null +++ b/progs/a377.py @@ -0,0 +1,2 @@ +def find_Volume(l,b,h) : 
 +    return ((l * b * h) / 2) 
\ No newline at end of file diff --git a/progs/a378.py b/progs/a378.py new file mode 100644 index 0000000..7f7dfba --- /dev/null +++ b/progs/a378.py @@ -0,0 +1,3 @@ +import re
 +def split_lowerstring(text):
 + return (re.findall('[a-z][^a-z]*', text))
\ No newline at end of file diff --git a/progs/a379.py b/progs/a379.py new file mode 100644 index 0000000..ebce8a5 --- /dev/null +++ b/progs/a379.py @@ -0,0 +1,7 @@ +import re
 +def text_lowercase_underscore(text):
 +        patterns = '^[a-z]+_[a-z]+$'
 +        if re.search(patterns,  text):
 +                return 'Found a match!'
 +        else:
 +                return('Not matched!')
\ No newline at end of file diff --git a/progs/a380.py b/progs/a380.py new file mode 100644 index 0000000..4b7a5f0 --- /dev/null +++ b/progs/a380.py @@ -0,0 +1,3 @@ +def square_perimeter(a):
 +  perimeter=4*a
 +  return perimeter
\ No newline at end of file diff --git a/progs/a381.py b/progs/a381.py new file mode 100644 index 0000000..40a9fae --- /dev/null +++ b/progs/a381.py @@ -0,0 +1,26 @@ +NO_OF_CHARS = 256
 +def str_to_list(string): 
 +	temp = [] 
 +	for x in string: 
 +		temp.append(x) 
 +	return temp 
 +def lst_to_string(List): 
 +	return ''.join(List) 
 +def get_char_count_array(string): 
 +	count = [0] * NO_OF_CHARS 
 +	for i in string: 
 +		count[ord(i)] += 1
 +	return count 
 +def remove_dirty_chars(string, second_string): 
 +	count = get_char_count_array(second_string) 
 +	ip_ind = 0
 +	res_ind = 0
 +	temp = '' 
 +	str_list = str_to_list(string) 
 +	while ip_ind != len(str_list): 
 +		temp = str_list[ip_ind] 
 +		if count[ord(temp)] == 0: 
 +			str_list[res_ind] = str_list[ip_ind] 
 +			res_ind += 1
 +		ip_ind+=1
 +	return lst_to_string(str_list[0:res_ind]) 
\ No newline at end of file diff --git a/progs/a382.py b/progs/a382.py new file mode 100644 index 0000000..f67bc9c --- /dev/null +++ b/progs/a382.py @@ -0,0 +1,3 @@ +def test_duplicate(arraynums):
 +    nums_set = set(arraynums)    
 +    return len(arraynums) != len(nums_set)     
\ No newline at end of file diff --git a/progs/a383.py b/progs/a383.py new file mode 100644 index 0000000..ce92ee2 --- /dev/null +++ b/progs/a383.py @@ -0,0 +1,13 @@ +def is_woodall(x): 
 +	if (x % 2 == 0): 
 +		return False
 +	if (x == 1): 
 +		return True
 +	x = x + 1 
 +	p = 0
 +	while (x % 2 == 0): 
 +		x = x/2
 +		p = p + 1
 +		if (p == x): 
 +			return True
 +	return False
\ No newline at end of file diff --git a/progs/a384.py b/progs/a384.py new file mode 100644 index 0000000..2d39a92 --- /dev/null +++ b/progs/a384.py @@ -0,0 +1,3 @@ +def multiples_of_num(m,n): 
 +    multiples_of_num= list(range(n,(m+1)*n, n)) 
 +    return list(multiples_of_num)
\ No newline at end of file diff --git a/progs/a385.py b/progs/a385.py new file mode 100644 index 0000000..eed88cc --- /dev/null +++ b/progs/a385.py @@ -0,0 +1,12 @@ +def find_first_duplicate(nums):
 +    num_set = set()
 +    no_duplicate = -1
 +
 +    for i in range(len(nums)):
 +
 +        if nums[i] in num_set:
 +            return nums[i]
 +        else:
 +            num_set.add(nums[i])
 +
 +    return no_duplicate
\ No newline at end of file diff --git a/progs/a386.py b/progs/a386.py new file mode 100644 index 0000000..b04ae1f --- /dev/null +++ b/progs/a386.py @@ -0,0 +1,8 @@ +def maximum_Sum(list1): 
 +    maxi = -100000
 +    for x in list1: 
 +        sum = 0 
 +        for y in x: 
 +            sum+= y      
 +        maxi = max(sum,maxi)     
 +    return maxi 
\ No newline at end of file diff --git a/progs/a387.py b/progs/a387.py new file mode 100644 index 0000000..1d36bf4 --- /dev/null +++ b/progs/a387.py @@ -0,0 +1,9 @@ +def binary_to_decimal(binary): 
 +    binary1 = binary 
 +    decimal, i, n = 0, 0, 0
 +    while(binary != 0): 
 +        dec = binary % 10
 +        decimal = decimal + dec * pow(2, i) 
 +        binary = binary//10
 +        i += 1
 +    return (decimal)
\ No newline at end of file diff --git a/progs/a388.py b/progs/a388.py new file mode 100644 index 0000000..e1d9298 --- /dev/null +++ b/progs/a388.py @@ -0,0 +1,7 @@ +def find_Product(arr,n): 
 +    arr.sort() 
 +    prod = 1
 +    for i in range(0,n,1): 
 +        if (arr[i - 1] != arr[i]): 
 +            prod = prod * arr[i] 
 +    return prod; 
\ No newline at end of file diff --git a/progs/a389.py b/progs/a389.py new file mode 100644 index 0000000..2cfa22e --- /dev/null +++ b/progs/a389.py @@ -0,0 +1,7 @@ +def check_k_elements(test_list, K):
 +  res = True
 +  for tup in test_list:
 +    for ele in tup:
 +      if ele != K:
 +        res = False
 +  return (res) 
\ No newline at end of file diff --git a/progs/a390.py b/progs/a390.py new file mode 100644 index 0000000..75e1bfa --- /dev/null +++ b/progs/a390.py @@ -0,0 +1,5 @@ +import re  
 +def remove(list): 
 +    pattern = '[0-9]'
 +    list = [re.sub(pattern, '', i) for i in list] 
 +    return list
\ No newline at end of file diff --git a/progs/a391.py b/progs/a391.py new file mode 100644 index 0000000..997ab6c --- /dev/null +++ b/progs/a391.py @@ -0,0 +1,6 @@ +def binomial_Coeff(n,k): 
 +    if k > n : 
 +       return 0
 +    if k==0 or k ==n : 
 +        return 1 
 +    return binomial_Coeff(n-1,k-1) + binomial_Coeff(n-1,k) 
\ No newline at end of file diff --git a/progs/a392.py b/progs/a392.py new file mode 100644 index 0000000..0c8da47 --- /dev/null +++ b/progs/a392.py @@ -0,0 +1,9 @@ +def get_Odd_Occurrence(arr,arr_size):   
 +    for i in range(0,arr_size): 
 +        count = 0
 +        for j in range(0,arr_size): 
 +            if arr[i] == arr[j]: 
 +                count+=1     
 +        if (count % 2 != 0): 
 +            return arr[i]     
 +    return -1
\ No newline at end of file diff --git a/progs/a393.py b/progs/a393.py new file mode 100644 index 0000000..721bc6e --- /dev/null +++ b/progs/a393.py @@ -0,0 +1,10 @@ +def check_Equality(s): 
 +    return (ord(s[0]) == ord(s[len(s) - 1])); 
 +def count_Substring_With_Equal_Ends(s): 
 +    result = 0; 
 +    n = len(s); 
 +    for i in range(n): 
 +        for j in range(1,n-i+1):  
 +            if (check_Equality(s[i:i+j])): 
 +                result+=1; 
 +    return result; 
\ No newline at end of file diff --git a/progs/a394.py b/progs/a394.py new file mode 100644 index 0000000..4fe6e47 --- /dev/null +++ b/progs/a394.py @@ -0,0 +1,22 @@ +def func(nums, k):
 +    import collections
 +    d = collections.defaultdict(int)
 +    for row in nums:
 +        for i in row:
 +            d[i] += 1
 +    temp = []
 +    import heapq
 +    for key, v in d.items():
 +        if len(temp) < k:
 +            temp.append((v, key))
 +            if len(temp) == k:
 +                heapq.heapify(temp)
 +        else:
 +            if v > temp[0][0]:
 +                heapq.heappop(temp)
 +                heapq.heappush(temp, (v, key))
 +    result = []
 +    while temp:
 +        v, key = heapq.heappop(temp)
 +        result.append(key)
 +    return result
\ No newline at end of file diff --git a/progs/a395.py b/progs/a395.py new file mode 100644 index 0000000..1ca6298 --- /dev/null +++ b/progs/a395.py @@ -0,0 +1,13 @@ +import math 
 +def max_Prime_Factors (n): 
 +    maxPrime = -1 
 +    while n%2 == 0: 
 +        maxPrime = 2
 +        n >>= 1    
 +    for i in range(3,int(math.sqrt(n))+1,2): 
 +        while n % i == 0: 
 +            maxPrime = i 
 +            n = n / i 
 +    if n > 2: 
 +        maxPrime = n  
 +    return int(maxPrime)
\ No newline at end of file diff --git a/progs/a396.py b/progs/a396.py new file mode 100644 index 0000000..0d03f17 --- /dev/null +++ b/progs/a396.py @@ -0,0 +1,10 @@ +def decimal_To_Binary(N): 
 +    B_Number = 0
 +    cnt = 0
 +    while (N != 0): 
 +        rem = N % 2
 +        c = pow(10,cnt)  
 +        B_Number += rem*c  
 +        N //= 2 
 +        cnt += 1
 +    return B_Number  
\ No newline at end of file diff --git a/progs/a397.py b/progs/a397.py new file mode 100644 index 0000000..34f81a5 --- /dev/null +++ b/progs/a397.py @@ -0,0 +1,13 @@ +def find_missing(ar,N): 
 +    l = 0
 +    r = N - 1
 +    while (l <= r):  
 +        mid = (l + r) / 2
 +        mid= int (mid) 
 +        if (ar[mid] != mid + 1 and ar[mid - 1] == mid): 
 +            return (mid + 1)  
 +        elif (ar[mid] != mid + 1): 
 +            r = mid - 1 
 +        else: 
 +            l = mid + 1
 +    return (-1) 
\ No newline at end of file diff --git a/progs/a398.py b/progs/a398.py new file mode 100644 index 0000000..7e9dd85 --- /dev/null +++ b/progs/a398.py @@ -0,0 +1,2 @@ +def find_rect_num(n):
 +  return n*(n + 1) 
\ No newline at end of file diff --git a/progs/a399.py b/progs/a399.py new file mode 100644 index 0000000..c15f0ed --- /dev/null +++ b/progs/a399.py @@ -0,0 +1,7 @@ +def find_Nth_Digit(p,q,N) :  
 +    while (N > 0) : 
 +        N -= 1;  
 +        p *= 10;  
 +        res = p // q;  
 +        p %= q;  
 +    return res;  
\ No newline at end of file diff --git a/progs/a4.py b/progs/a4.py new file mode 100644 index 0000000..7d5f1e2 --- /dev/null +++ b/progs/a4.py @@ -0,0 +1,9 @@ +def prime_num(num):
 +  if num >=1:
 +   for i in range(2, num//2):
 +     if (num % i) == 0:
 +                return False
 +     else:
 +                return True
 +  else:
 +          return False
\ No newline at end of file diff --git a/progs/a40.py b/progs/a40.py new file mode 100644 index 0000000..3cbfc16 --- /dev/null +++ b/progs/a40.py @@ -0,0 +1,2 @@ +def is_nonagonal(n): 
 +	return int(n * (7 * n - 5) / 2) 
\ No newline at end of file diff --git a/progs/a400.py b/progs/a400.py new file mode 100644 index 0000000..164e635 --- /dev/null +++ b/progs/a400.py @@ -0,0 +1,4 @@ +def sort_mixed_list(mixed_list):
 +    int_part = sorted([i for i in mixed_list if type(i) is int])
 +    str_part = sorted([i for i in mixed_list if type(i) is str])
 +    return int_part + str_part
\ No newline at end of file diff --git a/progs/a401.py b/progs/a401.py new file mode 100644 index 0000000..7c2f8f0 --- /dev/null +++ b/progs/a401.py @@ -0,0 +1,4 @@ +def div_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)
\ No newline at end of file diff --git a/progs/a402.py b/progs/a402.py new file mode 100644 index 0000000..c45fd00 --- /dev/null +++ b/progs/a402.py @@ -0,0 +1,16 @@ +import heapq
 +from collections import Counter
 +def rearange_string(S):
 +    ctr = Counter(S)
 +    heap = [(-value, key) for key, value in ctr.items()]
 +    heapq.heapify(heap)
 +    if (-heap[0][0]) * 2 > len(S) + 1: 
 +        return ""
 +    ans = []
 +    while len(heap) >= 2:
 +        nct1, char1 = heapq.heappop(heap)
 +        nct2, char2 = heapq.heappop(heap)
 +        ans.extend([char1, char2])
 +        if nct1 + 1: heapq.heappush(heap, (nct1 + 1, char1))
 +        if nct2 + 1: heapq.heappush(heap, (nct2 + 1, char2))
 +    return "".join(ans) + (heap[0][1] if heap else "")
\ No newline at end of file diff --git a/progs/a403.py b/progs/a403.py new file mode 100644 index 0000000..18c84b2 --- /dev/null +++ b/progs/a403.py @@ -0,0 +1,5 @@ +from collections import Counter
 +from itertools import chain
 +def freq_element(nums):
 +  result = Counter(chain.from_iterable(nums))
 +  return result
\ No newline at end of file diff --git a/progs/a405.py b/progs/a405.py new file mode 100644 index 0000000..bec4015 --- /dev/null +++ b/progs/a405.py @@ -0,0 +1,2 @@ +def find_Sum(arr,n): 
 +    return sum([x for x in arr if arr.count(x) > 1])
\ No newline at end of file diff --git a/progs/a406.py b/progs/a406.py new file mode 100644 index 0000000..4ae612e --- /dev/null +++ b/progs/a406.py @@ -0,0 +1,7 @@ +import re
 +def text_match(text):
 +  patterns = '^[a-z]+_[a-z]+$'
 +  if re.search(patterns,  text):
 +    return ('Found a match!')
 +  else:
 +    return ('Not matched!')
\ No newline at end of file diff --git a/progs/a407.py b/progs/a407.py new file mode 100644 index 0000000..9ebe1a9 --- /dev/null +++ b/progs/a407.py @@ -0,0 +1,7 @@ +import re
 +def text_match_string(text):
 +        patterns = '^\w+'
 +        if re.search(patterns,  text):
 +                return 'Found a match!'
 +        else:
 +                return 'Not matched!'
\ No newline at end of file diff --git a/progs/a408.py b/progs/a408.py new file mode 100644 index 0000000..69e579a --- /dev/null +++ b/progs/a408.py @@ -0,0 +1,11 @@ +def find_gcd(x, y): 
 +	while(y): 
 +		x, y = y, x % y 
 +	return x 
 +def get_gcd(l):
 +  num1 = l[0]
 +  num2 = l[1]
 +  gcd = find_gcd(num1, num2)
 +  for i in range(2, len(l)):
 +    gcd = find_gcd(gcd, l[i])
 +  return gcd
\ No newline at end of file diff --git a/progs/a409.py b/progs/a409.py new file mode 100644 index 0000000..5a821b3 --- /dev/null +++ b/progs/a409.py @@ -0,0 +1,5 @@ +def test_distinct(data):
 +  if len(data) == len(set(data)):
 +    return True
 +  else:
 +    return False;
\ No newline at end of file diff --git a/progs/a41.py b/progs/a41.py new file mode 100644 index 0000000..fc3c61b --- /dev/null +++ b/progs/a41.py @@ -0,0 +1,3 @@ +def remove_similar_row(test_list):
 +  res = set(sorted([tuple(sorted(set(sub))) for sub in test_list]))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a410.py b/progs/a410.py new file mode 100644 index 0000000..b6dd166 --- /dev/null +++ b/progs/a410.py @@ -0,0 +1,10 @@ +def compute_Last_Digit(A,B): 
 +    variable = 1
 +    if (A == B): 
 +        return 1
 +    elif ((B - A) >= 5):  
 +        return 0
 +    else:   
 +        for i in range(A + 1,B + 1): 
 +            variable = (variable * (i % 10)) % 10
 +        return variable % 10
\ No newline at end of file diff --git a/progs/a411.py b/progs/a411.py new file mode 100644 index 0000000..d854594 --- /dev/null +++ b/progs/a411.py @@ -0,0 +1,8 @@ +def odd_bit_set_number(n):
 +    count = 0;res = 0;temp = n
 +    while temp > 0:
 +        if count % 2 == 0:
 +            res |= (1 << count)
 +        count += 1
 +        temp >>= 1
 +    return (n | res)
\ No newline at end of file diff --git a/progs/a412_mod.py b/progs/a412_mod.py new file mode 100644 index 0000000..8b35459 --- /dev/null +++ b/progs/a412_mod.py @@ -0,0 +1,3 @@ +def specified_element(nums, N):
 +    result = [i[N] for i in nums]
 +    return result
 diff --git a/progs/a414.py b/progs/a414.py new file mode 100644 index 0000000..13dedc3 --- /dev/null +++ b/progs/a414.py @@ -0,0 +1,5 @@ +def check_equilateral(x,y,z):
 +  if x == y == z:
 +	   return True
 +  else:
 +     return False
\ No newline at end of file diff --git a/progs/a415.py b/progs/a415.py new file mode 100644 index 0000000..1e6e9bd --- /dev/null +++ b/progs/a415.py @@ -0,0 +1,3 @@ +def parallelogram_area(b,h):
 +  area=b*h
 +  return area
\ No newline at end of file diff --git a/progs/a416.py b/progs/a416.py new file mode 100644 index 0000000..a3cd347 --- /dev/null +++ b/progs/a416.py @@ -0,0 +1,5 @@ +def check_Equality(str):
 +  if (str[0] == str[-1]):  
 +    return ("Equal") 
 +  else:  
 +    return ("Not Equal") 
\ No newline at end of file diff --git a/progs/a417.py b/progs/a417.py new file mode 100644 index 0000000..fa68691 --- /dev/null +++ b/progs/a417.py @@ -0,0 +1,14 @@ +def counting_sort(my_list):
 +    max_value = 0
 +    for i in range(len(my_list)):
 +        if my_list[i] > max_value:
 +            max_value = my_list[i]
 +    buckets = [0] * (max_value + 1)
 +    for i in my_list:
 +        buckets[i] += 1
 +    i = 0
 +    for j in range(max_value + 1):
 +         for a in range(buckets[j]):
 +             my_list[i] = j
 +             i += 1
 +    return my_list
\ No newline at end of file diff --git a/progs/a418.py b/progs/a418.py new file mode 100644 index 0000000..233dcc1 --- /dev/null +++ b/progs/a418.py @@ -0,0 +1,4 @@ +import math
 +def tn_gp(a,n,r):
 +  tn = a * (math.pow(r, n - 1))
 +  return tn
\ No newline at end of file diff --git a/progs/a419.py b/progs/a419.py new file mode 100644 index 0000000..1af5189 --- /dev/null +++ b/progs/a419.py @@ -0,0 +1,8 @@ +def rev(num):    
 +    rev_num = 0
 +    while (num > 0):  
 +        rev_num = (rev_num * 10 + num % 10) 
 +        num = num // 10  
 +    return rev_num  
 +def check(n):    
 +    return (2 * rev(n) == n + 1)  
\ No newline at end of file diff --git a/progs/a42.py b/progs/a42.py new file mode 100644 index 0000000..1bc88f2 --- /dev/null +++ b/progs/a42.py @@ -0,0 +1,7 @@ +import re
 +def text_match_wordz_middle(text):
 +        patterns = '\Bz\B'
 +        if re.search(patterns,  text):
 +                return 'Found a match!'
 +        else:
 +                return('Not matched!')
\ No newline at end of file diff --git a/progs/a420.py b/progs/a420.py new file mode 100644 index 0000000..1c47c83 --- /dev/null +++ b/progs/a420.py @@ -0,0 +1,6 @@ +def find_Max_Num(arr,n) : 
 +    arr.sort(reverse = True) 
 +    num = arr[0] 
 +    for i in range(1,n) : 
 +        num = num * 10 + arr[i] 
 +    return num 
\ No newline at end of file diff --git a/progs/a421.py b/progs/a421.py new file mode 100644 index 0000000..481c5db --- /dev/null +++ b/progs/a421.py @@ -0,0 +1,2 @@ +def opposite_Signs(x,y): 
 +    return ((x ^ y) < 0); 
\ No newline at end of file diff --git a/progs/a422.py b/progs/a422.py new file mode 100644 index 0000000..d1db25f --- /dev/null +++ b/progs/a422.py @@ -0,0 +1,2 @@ +def is_octagonal(n): 
 +	return 3 * n * n - 2 * n 
\ No newline at end of file diff --git a/progs/a423.py b/progs/a423.py new file mode 100644 index 0000000..4bd6530 --- /dev/null +++ b/progs/a423.py @@ -0,0 +1,13 @@ +def max_len_sub( arr, n): 
 +	mls=[] 
 +	max = 0
 +	for i in range(n): 
 +		mls.append(1) 
 +	for i in range(n): 
 +		for j in range(i): 
 +			if (abs(arr[i] - arr[j]) <= 1 and mls[i] < mls[j] + 1): 
 +				mls[i] = mls[j] + 1
 +	for i in range(n): 
 +		if (max < mls[i]): 
 +			max = mls[i] 
 +	return max
\ No newline at end of file diff --git a/progs/a425.py b/progs/a425.py new file mode 100644 index 0000000..00c5c34 --- /dev/null +++ b/progs/a425.py @@ -0,0 +1,2 @@ +def smallest_num(xs): +  return min(xs) diff --git a/progs/a426.py b/progs/a426.py new file mode 100644 index 0000000..8e88ba9 --- /dev/null +++ b/progs/a426.py @@ -0,0 +1,4 @@ +def max_difference(test_list):
 +  temp = [abs(b - a) for a, b in test_list]
 +  res = max(temp)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a428.py b/progs/a428.py new file mode 100644 index 0000000..191b908 --- /dev/null +++ b/progs/a428.py @@ -0,0 +1,8 @@ +def recursive_list_sum(data_list):
 +	total = 0
 +	for element in data_list:
 +		if type(element) == type([]):
 +			total = total + recursive_list_sum(element)
 +		else:
 +			total = total + element
 +	return total
\ No newline at end of file diff --git a/progs/a429.py b/progs/a429.py new file mode 100644 index 0000000..3fad1cc --- /dev/null +++ b/progs/a429.py @@ -0,0 +1,6 @@ +def pos_count(list):
 +  pos_count= 0
 +  for num in list: 
 +    if num >= 0: 
 +      pos_count += 1
 +  return pos_count 
\ No newline at end of file diff --git a/progs/a43.py b/progs/a43.py new file mode 100644 index 0000000..0205358 --- /dev/null +++ b/progs/a43.py @@ -0,0 +1,2 @@ +def reverse_Array_Upto_K(input, k): 
 +  return (input[k-1::-1] + input[k:]) 
\ No newline at end of file diff --git a/progs/a430.py b/progs/a430.py new file mode 100644 index 0000000..2a69036 --- /dev/null +++ b/progs/a430.py @@ -0,0 +1,8 @@ +def bell_number(n):   
 +    bell = [[0 for i in range(n+1)] for j in range(n+1)] 
 +    bell[0][0] = 1
 +    for i in range(1, n+1): 
 +        bell[i][0] = bell[i-1][i-1]  
 +        for j in range(1, i+1): 
 +            bell[i][j] = bell[i-1][j-1] + bell[i][j-1]   
 +    return bell[n][0] 
\ No newline at end of file diff --git a/progs/a431.py b/progs/a431.py new file mode 100644 index 0000000..9a8a7de --- /dev/null +++ b/progs/a431.py @@ -0,0 +1,3 @@ +def is_Monotonic(A): 
 +    return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or
 +            all(A[i] >= A[i + 1] for i in range(len(A) - 1))) 
\ No newline at end of file diff --git a/progs/a432.py b/progs/a432.py new file mode 100644 index 0000000..9a05310 --- /dev/null +++ b/progs/a432.py @@ -0,0 +1,17 @@ +def is_sublist(l, s):
 +	sub_set = False
 +	if s == []:
 +		sub_set = True
 +	elif s == l:
 +		sub_set = True
 +	elif len(s) > len(l):
 +		sub_set = False
 +	else:
 +		for i in range(len(l)):
 +			if l[i] == s[0]:
 +				n = 1
 +				while (n < len(s)) and (l[i+n] == s[n]):
 +					n += 1				
 +				if n == len(s):
 +					sub_set = True
 +	return sub_set
\ No newline at end of file diff --git a/progs/a433.py b/progs/a433.py new file mode 100644 index 0000000..7fa3f4f --- /dev/null +++ b/progs/a433.py @@ -0,0 +1,12 @@ +def find_equal_tuple(Input, k):
 +  flag = 1
 +  for tuple in Input:
 +    if len(tuple) != k:
 +      flag = 0
 +      break
 +  return flag
 +def get_equal(Input, k):
 +  if find_equal_tuple(Input, k) == 1:
 +    return ("All tuples have same length")
 +  else:
 +    return ("All tuples do not have same length")
\ No newline at end of file diff --git a/progs/a434.py b/progs/a434.py new file mode 100644 index 0000000..6cb4081 --- /dev/null +++ b/progs/a434.py @@ -0,0 +1,15 @@ +def comb_sort(nums):
 +    shrink_fact = 1.3
 +    gaps = len(nums)
 +    swapped = True
 +    i = 0
 +    while gaps > 1 or swapped:
 +        gaps = int(float(gaps) / shrink_fact)
 +        swapped = False
 +        i = 0
 +        while gaps + i < len(nums):
 +            if nums[i] > nums[i+gaps]:
 +                nums[i], nums[i+gaps] = nums[i+gaps], nums[i]
 +                swapped = True
 +            i += 1
 +    return nums
\ No newline at end of file diff --git a/progs/a435.py b/progs/a435.py new file mode 100644 index 0000000..d24665b --- /dev/null +++ b/progs/a435.py @@ -0,0 +1,4 @@ +def dif_Square(n): 
 +    if (n % 4 != 2): 
 +        return True
 +    return False
\ No newline at end of file diff --git a/progs/a436.py b/progs/a436.py new file mode 100644 index 0000000..28ae1ca --- /dev/null +++ b/progs/a436.py @@ -0,0 +1,3 @@ +import re
 +def multiple_split(text):
 +  return (re.split('; |, |\*|\n',text))
\ No newline at end of file diff --git a/progs/a437.py b/progs/a437.py new file mode 100644 index 0000000..764cde7 --- /dev/null +++ b/progs/a437.py @@ -0,0 +1,26 @@ +def is_samepatterns(colors, patterns):    
 +    if len(colors) != len(patterns):
 +        return False    
 +    sdict = {}
 +    pset = set()
 +    sset = set()    
 +    for i in range(len(patterns)):
 +        pset.add(patterns[i])
 +        sset.add(colors[i])
 +        if patterns[i] not in sdict.keys():
 +            sdict[patterns[i]] = []
 +
 +        keys = sdict[patterns[i]]
 +        keys.append(colors[i])
 +        sdict[patterns[i]] = keys
 +
 +    if len(pset) != len(sset):
 +        return False   
 +
 +    for values in sdict.values():
 +
 +        for i in range(len(values) - 1):
 +            if values[i] != values[i+1]:
 +                return False
 +
 +    return True
\ No newline at end of file diff --git a/progs/a438.py b/progs/a438.py new file mode 100644 index 0000000..05fe371 --- /dev/null +++ b/progs/a438.py @@ -0,0 +1,3 @@ +def find_tuples(test_list, K):
 +  res = [sub for sub in test_list if all(ele % K == 0 for ele in sub)]
 +  return (str(res)) 
\ No newline at end of file diff --git a/progs/a439.py b/progs/a439.py new file mode 100644 index 0000000..2ed5b62 --- /dev/null +++ b/progs/a439.py @@ -0,0 +1,6 @@ +def count_Squares(m,n):
 +    if(n < m):
 +        temp = m
 +        m = n
 +        n = temp
 +    return ((m * (m + 1) * (2 * m + 1) / 6 + (n - m) * m * (m + 1) / 2))
\ No newline at end of file diff --git a/progs/a44.py b/progs/a44.py new file mode 100644 index 0000000..60eb2f5 --- /dev/null +++ b/progs/a44.py @@ -0,0 +1,8 @@ +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) 
\ No newline at end of file diff --git a/progs/a440.py b/progs/a440.py new file mode 100644 index 0000000..c62731c --- /dev/null +++ b/progs/a440.py @@ -0,0 +1,2 @@ +def is_Diff(n): 
 +    return (n % 11 == 0) 
\ No newline at end of file diff --git a/progs/a441.py b/progs/a441.py new file mode 100644 index 0000000..59eaae8 --- /dev/null +++ b/progs/a441.py @@ -0,0 +1,8 @@ +def count_With_Odd_SetBits(n): 
 +    if (n % 2 != 0): 
 +        return (n + 1) / 2
 +    count = bin(n).count('1') 
 +    ans = n / 2
 +    if (count % 2 != 0): 
 +        ans += 1
 +    return ans 
\ No newline at end of file diff --git a/progs/a442.py b/progs/a442.py new file mode 100644 index 0000000..67eda76 --- /dev/null +++ b/progs/a442.py @@ -0,0 +1,7 @@ +def word_len(s): 
 +    s = s.split(' ')   
 +    for word in s:    
 +        if len(word)%2!=0: 
 +            return True  
 +        else:
 +          return False
\ No newline at end of file diff --git a/progs/a443.py b/progs/a443.py new file mode 100644 index 0000000..5daabfe --- /dev/null +++ b/progs/a443.py @@ -0,0 +1,2 @@ +def tetrahedral_number(n): 
 +	return (n * (n + 1) * (n + 2)) / 6
\ No newline at end of file diff --git a/progs/a444.py b/progs/a444.py new file mode 100644 index 0000000..0e6873c --- /dev/null +++ b/progs/a444.py @@ -0,0 +1,5 @@ +def zip_tuples(test_tup1, test_tup2):
 +  res = []
 +  for i, j in enumerate(test_tup1):
 +    res.append((j, test_tup2[i % len(test_tup2)])) 
 +  return (res) 
\ No newline at end of file diff --git a/progs/a445.py b/progs/a445.py new file mode 100644 index 0000000..c59c605 --- /dev/null +++ b/progs/a445.py @@ -0,0 +1,4 @@ +import math
 +def volume_sphere(r):
 +  volume=(4/3)*math.pi*r*r*r
 +  return volume
\ No newline at end of file diff --git a/progs/a446.py b/progs/a446.py new file mode 100644 index 0000000..249ddb3 --- /dev/null +++ b/progs/a446.py @@ -0,0 +1,9 @@ +def get_Char(strr):  
 +    summ = 0
 +    for i in range(len(strr)): 
 +        summ += (ord(strr[i]) - ord('a') + 1)  
 +    if (summ % 26 == 0): 
 +        return ord('z') 
 +    else: 
 +        summ = summ % 26
 +        return chr(ord('a') + summ - 1)
\ No newline at end of file diff --git a/progs/a447.py b/progs/a447.py new file mode 100644 index 0000000..3ccb78f --- /dev/null +++ b/progs/a447.py @@ -0,0 +1,5 @@ +def sequence(n): 
 +	if n == 1 or n == 2: 
 +		return 1
 +	else: 
 +		return sequence(sequence(n-1)) + sequence(n-sequence(n-1))
\ No newline at end of file diff --git a/progs/a448.py b/progs/a448.py new file mode 100644 index 0000000..fe5f19a --- /dev/null +++ b/progs/a448.py @@ -0,0 +1,4 @@ +import math
 +def surfacearea_sphere(r):
 +  surfacearea=4*math.pi*r*r
 +  return surfacearea
\ No newline at end of file diff --git a/progs/a449.py b/progs/a449.py new file mode 100644 index 0000000..3b5e7a2 --- /dev/null +++ b/progs/a449.py @@ -0,0 +1,2 @@ +def centered_hexagonal_number(n):
 +  return 3 * n * (n - 1) + 1
\ No newline at end of file diff --git a/progs/a45.py b/progs/a45.py new file mode 100644 index 0000000..ec3200b --- /dev/null +++ b/progs/a45.py @@ -0,0 +1,5 @@ +def No_of_cubes(N,K):
 +    No = 0
 +    No = (N - K + 1)
 +    No = pow(No, 3)
 +    return No
\ No newline at end of file diff --git a/progs/a450.py b/progs/a450.py new file mode 100644 index 0000000..21ab356 --- /dev/null +++ b/progs/a450.py @@ -0,0 +1,4 @@ +import collections as ct
 +def merge_dictionaries_three(dict1,dict2, dict3):
 +    merged_dict = dict(ct.ChainMap({},dict1,dict2,dict3))
 +    return merged_dict
\ No newline at end of file diff --git a/progs/a451.py b/progs/a451.py new file mode 100644 index 0000000..9c8d310 --- /dev/null +++ b/progs/a451.py @@ -0,0 +1,4 @@ +import collections
 +def freq_count(list1):
 +  freq_count= collections.Counter(list1)
 +  return freq_count
\ No newline at end of file diff --git a/progs/a452.py b/progs/a452.py new file mode 100644 index 0000000..75efc4f --- /dev/null +++ b/progs/a452.py @@ -0,0 +1,2 @@ +def closest_num(N):
 +  return (N - 1)
\ No newline at end of file diff --git a/progs/a453.py b/progs/a453.py new file mode 100644 index 0000000..ddef225 --- /dev/null +++ b/progs/a453.py @@ -0,0 +1,6 @@ +def len_log(list1):
 +    max=len(list1[0])
 +    for i in list1:
 +        if len(i)>max:
 +            max=len(i)
 +    return max
\ No newline at end of file diff --git a/progs/a454.py b/progs/a454.py new file mode 100644 index 0000000..45ac7c8 --- /dev/null +++ b/progs/a454.py @@ -0,0 +1,4 @@ +def find_substring(str1, sub_str):
 +   if any(sub_str in s for s in str1):
 +       return True
 +   return False
\ No newline at end of file diff --git a/progs/a455.py b/progs/a455.py new file mode 100644 index 0000000..45278b7 --- /dev/null +++ b/progs/a455.py @@ -0,0 +1,7 @@ +def is_undulating(n): 
 +	if (len(n) <= 2): 
 +		return False
 +	for i in range(2, len(n)): 
 +		if (n[i - 2] != n[i]): 
 +			return False
 +	return True
\ No newline at end of file diff --git a/progs/a456.py b/progs/a456.py new file mode 100644 index 0000000..bb16096 --- /dev/null +++ b/progs/a456.py @@ -0,0 +1,9 @@ +def power(a,b):
 +	if b==0:
 +		return 1
 +	elif a==0:
 +		return 0
 +	elif b==1:
 +		return a
 +	else:
 +		return a*power(a,b-1)
\ No newline at end of file diff --git a/progs/a457.py b/progs/a457.py new file mode 100644 index 0000000..c2e58db --- /dev/null +++ b/progs/a457.py @@ -0,0 +1,4 @@ +from operator import itemgetter 
 +def index_minimum(test_list):
 +  res = min(test_list, key = itemgetter(1))[0]
 +  return (res) 
\ No newline at end of file diff --git a/progs/a458.py b/progs/a458.py new file mode 100644 index 0000000..a0e1d24 --- /dev/null +++ b/progs/a458.py @@ -0,0 +1,3 @@ +def Find_Min_Length(lst):  
 +    minLength = min(len(x) for x in lst )
 +    return minLength 
\ No newline at end of file diff --git a/progs/a459.py b/progs/a459.py new file mode 100644 index 0000000..0ea51a8 --- /dev/null +++ b/progs/a459.py @@ -0,0 +1,4 @@ +def divisor(n):
 +  for i in range(n):
 +    x = len([i for i in range(1,n+1) if not n % i])
 +  return x
\ No newline at end of file diff --git a/progs/a46.py b/progs/a46.py new file mode 100644 index 0000000..82c0f10 --- /dev/null +++ b/progs/a46.py @@ -0,0 +1,3 @@ +import re
 +def split_upperstring(text):
 + return (re.findall('[A-Z][^A-Z]*', text))
\ No newline at end of file diff --git a/progs/a460.py b/progs/a460.py new file mode 100644 index 0000000..35bb40d --- /dev/null +++ b/progs/a460.py @@ -0,0 +1,11 @@ +def frequency_lists(list1):
 +    list1 = [item for sublist in list1 for item in sublist]
 +    dic_data = {}
 +    for num in list1:
 +        if num in dic_data.keys():
 +            dic_data[num] += 1
 +        else:
 +            key = num
 +            value = 1
 +            dic_data[key] = value
 +    return dic_data
 diff --git a/progs/a461.py b/progs/a461.py new file mode 100644 index 0000000..7ca6e42 --- /dev/null +++ b/progs/a461.py @@ -0,0 +1,5 @@ +def multiply_num(numbers):  
 +    total = 1
 +    for x in numbers:
 +        total *= x  
 +    return total/len(numbers) 
\ No newline at end of file diff --git a/progs/a462.py b/progs/a462.py new file mode 100644 index 0000000..6cdb173 --- /dev/null +++ b/progs/a462.py @@ -0,0 +1,2 @@ +def decimal_to_binary(n): 
 +    return bin(n).replace("0b","") 
\ No newline at end of file diff --git a/progs/a463.py b/progs/a463.py new file mode 100644 index 0000000..3cb6533 --- /dev/null +++ b/progs/a463.py @@ -0,0 +1,6 @@ +import sys
 +def next_smallest_palindrome(num):
 +    numstr = str(num)
 +    for i in range(num+1,sys.maxsize):
 +        if str(i) == str(i)[::-1]:
 +            return i
\ No newline at end of file diff --git a/progs/a465.py b/progs/a465.py new file mode 100644 index 0000000..cfd850d --- /dev/null +++ b/progs/a465.py @@ -0,0 +1,3 @@ +def snake_to_camel(word):
 +        import re
 +        return ''.join(x.capitalize() or '_' for x in word.split('_'))
\ No newline at end of file diff --git a/progs/a466.py b/progs/a466.py new file mode 100644 index 0000000..5206c2a --- /dev/null +++ b/progs/a466.py @@ -0,0 +1,6 @@ +def eulerian_num(n, m): 
 +	if (m >= n or n == 0): 
 +		return 0 
 +	if (m == 0): 
 +		return 1 
 +	return ((n - m) * eulerian_num(n - 1, m - 1) +(m + 1) * eulerian_num(n - 1, m))
\ No newline at end of file diff --git a/progs/a468.py b/progs/a468.py new file mode 100644 index 0000000..d01e068 --- /dev/null +++ b/progs/a468.py @@ -0,0 +1,2 @@ +def count(lst):   
 +    return sum(lst) 
\ No newline at end of file diff --git a/progs/a469.py b/progs/a469.py new file mode 100644 index 0000000..c6ed4a5 --- /dev/null +++ b/progs/a469.py @@ -0,0 +1,3 @@ +def add_lists(test_list, test_tup):
 +  res = tuple(list(test_tup) + test_list)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a47.py b/progs/a47.py new file mode 100644 index 0000000..94c3374 --- /dev/null +++ b/progs/a47.py @@ -0,0 +1,4 @@ +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])))
\ No newline at end of file diff --git a/progs/a470.py b/progs/a470.py new file mode 100644 index 0000000..54ca055 --- /dev/null +++ b/progs/a470.py @@ -0,0 +1,12 @@ +def count_Hexadecimal(L,R) :  
 +    count = 0;  
 +    for i in range(L,R + 1) : 
 +        if (i >= 10 and i <= 15) : 
 +            count += 1;  
 +        elif (i > 15) : 
 +            k = i;  
 +            while (k != 0) :  
 +                if (k % 16 >= 10) : 
 +                    count += 1;  
 +                k = k // 16;  
 +    return count;  
\ No newline at end of file diff --git a/progs/a471.py b/progs/a471.py new file mode 100644 index 0000000..f15b77d --- /dev/null +++ b/progs/a471.py @@ -0,0 +1,7 @@ +import heapq
 +def merge_sorted_list(num1,num2,num3):
 +  num1=sorted(num1)
 +  num2=sorted(num2)
 +  num3=sorted(num3)
 +  result = heapq.merge(num1,num2,num3)
 +  return list(result)
\ No newline at end of file diff --git a/progs/a472.py b/progs/a472.py new file mode 100644 index 0000000..625f1c5 --- /dev/null +++ b/progs/a472.py @@ -0,0 +1,6 @@ +def odd_Equivalent(s,n): 
 +    count=0
 +    for i in range(0,n): 
 +        if (s[i] == '1'): 
 +            count = count + 1
 +    return count 
\ No newline at end of file diff --git a/progs/a473.py b/progs/a473.py new file mode 100644 index 0000000..d82695d --- /dev/null +++ b/progs/a473.py @@ -0,0 +1,9 @@ +def extract_missing(test_list, strt_val, stop_val):
 +  res = []
 +  for sub in test_list:
 +    if sub[0] > strt_val:
 +      res.append((strt_val, sub[0]))
 +      strt_val = sub[1]
 +    if strt_val < stop_val:
 +      res.append((strt_val, stop_val))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a475.py b/progs/a475.py new file mode 100644 index 0000000..c4df169 --- /dev/null +++ b/progs/a475.py @@ -0,0 +1,2 @@ +def perimeter(diameter,height) : 
 +    return 2*(diameter+height)  
\ No newline at end of file diff --git a/progs/a476.py b/progs/a476.py new file mode 100644 index 0000000..7c1b0b6 --- /dev/null +++ b/progs/a476.py @@ -0,0 +1,12 @@ +def check_integer(text):
 + text = text.strip()
 + if len(text) < 1:
 +    return None
 + else:
 +     if all(text[i] in "0123456789" for i in range(len(text))):
 +          return True
 +     elif (text[0] in "+-") and \
 +         all(text[i] in "0123456789" for i in range(1,len(text))):
 +         return True
 +     else:
 +        return False
\ No newline at end of file diff --git a/progs/a478.py b/progs/a478.py new file mode 100644 index 0000000..3315dc2 --- /dev/null +++ b/progs/a478.py @@ -0,0 +1,3 @@ +def empty_dit(list1):
 + empty_dit=all(not d for d in list1)
 + return empty_dit
\ No newline at end of file diff --git a/progs/a479.py b/progs/a479.py new file mode 100644 index 0000000..d6bc98e --- /dev/null +++ b/progs/a479.py @@ -0,0 +1,3 @@ +def tuple_to_int(nums):
 +    result = int(''.join(map(str,nums)))
 +    return result
\ No newline at end of file diff --git a/progs/a48.py b/progs/a48.py new file mode 100644 index 0000000..736523b --- /dev/null +++ b/progs/a48.py @@ -0,0 +1,5 @@ +def sum_Range_list(nums, m, n):                                                                                                                                                                                                
 +    sum_range = 0                                                                                                                                                                                                         
 +    for i in range(m, n+1, 1):                                                                                                                                                                                        
 +        sum_range += nums[i]                                                                                                                                                                                                  
 +    return sum_range   
\ No newline at end of file diff --git a/progs/a480.py b/progs/a480.py new file mode 100644 index 0000000..7d8db7d --- /dev/null +++ b/progs/a480.py @@ -0,0 +1,11 @@ +def list_to_float(test_list):
 +  res = []
 +  for tup in test_list:
 +    temp = []
 +    for ele in tup:
 +      if ele.isalpha():
 +        temp.append(ele)
 +      else:
 +        temp.append(float(ele))
 +    res.append((temp[0],temp[1])) 
 +  return (str(res)) 
\ No newline at end of file diff --git a/progs/a481.py b/progs/a481.py new file mode 100644 index 0000000..7d9cf51 --- /dev/null +++ b/progs/a481.py @@ -0,0 +1,3 @@ +def string_to_list(string): 
 +    lst = list(string.split(" ")) 
 +    return lst
\ No newline at end of file diff --git a/progs/a482.py b/progs/a482.py new file mode 100644 index 0000000..da6fe1f --- /dev/null +++ b/progs/a482.py @@ -0,0 +1,5 @@ +def search(arr,n) :
 +    XOR = 0
 +    for i in range(n) :
 +        XOR = XOR ^ arr[i]
 +    return (XOR)
\ No newline at end of file diff --git a/progs/a483.py b/progs/a483.py new file mode 100644 index 0000000..16fd15d --- /dev/null +++ b/progs/a483.py @@ -0,0 +1,3 @@ +def max_product_tuple(list1):
 +    result_max = max([abs(x * y) for x, y in list1] )
 +    return result_max
\ No newline at end of file diff --git a/progs/a484.py b/progs/a484.py new file mode 100644 index 0000000..00ed320 --- /dev/null +++ b/progs/a484.py @@ -0,0 +1,7 @@ +def check_triplet(A, n, sum, count):
 +    if count == 3 and sum == 0:
 +        return True
 +    if count == 3 or n == 0 or sum < 0:
 +        return False
 +    return check_triplet(A, n - 1, sum - A[n - 1], count + 1) or\
 +           check_triplet(A, n - 1, sum, count)
\ No newline at end of file diff --git a/progs/a485.py b/progs/a485.py new file mode 100644 index 0000000..20165f4 --- /dev/null +++ b/progs/a485.py @@ -0,0 +1,15 @@ +MAX = 3000 
 +def smartNumber(n): 
 +	primes = [0] * MAX 
 +	result = [] 
 +	for i in range(2, MAX): 
 +		if (primes[i] == 0): 
 +			primes[i] = 1 
 +			j = i * 2 
 +			while (j < MAX): 
 +				primes[j] -= 1 
 +				if ( (primes[j] + 3) == 0): 
 +					result.append(j) 
 +				j = j + i 
 +	result.sort() 
 +	return result[n - 1] 
\ No newline at end of file diff --git a/progs/a486.py b/progs/a486.py new file mode 100644 index 0000000..e0ef697 --- /dev/null +++ b/progs/a486.py @@ -0,0 +1,15 @@ +def amicable_numbers_sum(limit):
 +    if not isinstance(limit, int):
 +        return "Input is not an integer!"
 +    if limit < 1:
 +        return "Input must be bigger than 0!"
 +    amicables = set()
 +    for num in range(2, limit+1):
 +        if num in amicables:
 +            continue
 +        sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])
 +        sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])
 +        if num == sum_fact2 and num != sum_fact:
 +            amicables.add(num)
 +            amicables.add(sum_fact2)
 +    return sum(amicables)
\ No newline at end of file diff --git a/progs/a487.py b/progs/a487.py new file mode 100644 index 0000000..01efda1 --- /dev/null +++ b/progs/a487.py @@ -0,0 +1,5 @@ +import cmath
 +def angle_complex(a,b):
 +  cn=complex(a,b)
 +  angle=cmath.phase(a+b)
 +  return angle
\ No newline at end of file diff --git a/progs/a488.py b/progs/a488.py new file mode 100644 index 0000000..c5865d6 --- /dev/null +++ b/progs/a488.py @@ -0,0 +1,9 @@ +def find_length(string, n): 
 +	current_sum = 0
 +	max_sum = 0
 +	for i in range(n): 
 +		current_sum += (1 if string[i] == '0' else -1) 
 +		if current_sum < 0: 
 +			current_sum = 0
 +		max_sum = max(current_sum, max_sum) 
 +	return max_sum if max_sum else 0
\ No newline at end of file diff --git a/progs/a489.py b/progs/a489.py new file mode 100644 index 0000000..ac17fc0 --- /dev/null +++ b/progs/a489.py @@ -0,0 +1,6 @@ +def sum(a,b): 
 +    sum = 0
 +    for i in range (1,min(a,b)): 
 +        if (a % i == 0 and b % i == 0): 
 +            sum += i 
 +    return sum
\ No newline at end of file diff --git a/progs/a49.py b/progs/a49.py new file mode 100644 index 0000000..4039ae5 --- /dev/null +++ b/progs/a49.py @@ -0,0 +1,9 @@ +def are_Equal(arr1,arr2,n,m):
 +    if (n != m):
 +        return False
 +    arr1.sort()
 +    arr2.sort()
 +    for i in range(0,n - 1):
 +        if (arr1[i] != arr2[i]):
 +            return False
 +    return True
\ No newline at end of file diff --git a/progs/a490.py b/progs/a490.py new file mode 100644 index 0000000..c802fcc --- /dev/null +++ b/progs/a490.py @@ -0,0 +1,9 @@ +def multiply_int(x, y):
 +    if y < 0:
 +        return -multiply_int(x, -y)
 +    elif y == 0:
 +        return 0
 +    elif y == 1:
 +        return x
 +    else:
 +        return x + multiply_int(x, y - 1)
\ No newline at end of file diff --git a/progs/a491.py b/progs/a491.py new file mode 100644 index 0000000..d4be952 --- /dev/null +++ b/progs/a491.py @@ -0,0 +1,7 @@ +def long_words(n, str):
 +    word_len = []
 +    txt = str.split(" ")
 +    for x in txt:
 +        if len(x) > n:
 +            word_len.append(x)
 +    return word_len	
\ No newline at end of file diff --git a/progs/a492.py b/progs/a492.py new file mode 100644 index 0000000..3e1b9c3 --- /dev/null +++ b/progs/a492.py @@ -0,0 +1,17 @@ +def magic_square_test(my_matrix):
 +    iSize = len(my_matrix[0])
 +    sum_list = []
 +    sum_list.extend([sum (lines) for lines in my_matrix])   
 +    for col in range(iSize):
 +        sum_list.append(sum(row[col] for row in my_matrix))
 +    result1 = 0
 +    for i in range(0,iSize):
 +        result1 +=my_matrix[i][i]
 +    sum_list.append(result1)      
 +    result2 = 0
 +    for i in range(iSize-1,-1,-1):
 +        result2 +=my_matrix[i][i]
 +    sum_list.append(result2)
 +    if len(set(sum_list))>1:
 +        return False
 +    return True
\ No newline at end of file diff --git a/progs/a494.py b/progs/a494.py new file mode 100644 index 0000000..a37dd5f --- /dev/null +++ b/progs/a494.py @@ -0,0 +1,13 @@ +def reverse_vowels(str1):
 +	vowels = ""
 +	for char in str1:
 +		if char in "aeiouAEIOU":
 +			vowels += char
 +	result_string = ""
 +	for char in str1:
 +		if char in "aeiouAEIOU":
 +			result_string += vowels[-1]
 +			vowels = vowels[:-1]
 +		else:
 +			result_string += char
 +	return result_string
\ No newline at end of file diff --git a/progs/a495.py b/progs/a495.py new file mode 100644 index 0000000..0fd80d1 --- /dev/null +++ b/progs/a495.py @@ -0,0 +1,3 @@ +def tup_string(tup1):
 +  str =  ''.join(tup1)
 +  return str
\ No newline at end of file diff --git a/progs/a497.py b/progs/a497.py new file mode 100644 index 0000000..c268e81 --- /dev/null +++ b/progs/a497.py @@ -0,0 +1,11 @@ +def check_last (arr,n,p): 
 +    _sum = 0
 +    for i in range(n): 
 +        _sum = _sum + arr[i] 
 +    if p == 1: 
 +        if _sum % 2 == 0: 
 +            return "ODD"
 +        else: 
 +            return "EVEN"
 +    return "EVEN"
 +      
 diff --git a/progs/a498.py b/progs/a498.py new file mode 100644 index 0000000..728f1cb --- /dev/null +++ b/progs/a498.py @@ -0,0 +1,2 @@ +def hexagonal_num(n): 
 +	return n*(2*n - 1) 
\ No newline at end of file diff --git a/progs/a499.py b/progs/a499.py new file mode 100644 index 0000000..8d1a2cb --- /dev/null +++ b/progs/a499.py @@ -0,0 +1,15 @@ +def cal_electbill(units):
 + if(units < 50):
 +    amount = units * 2.60
 +    surcharge = 25
 + elif(units <= 100):
 +    amount = 130 + ((units - 50) * 3.25)
 +    surcharge = 35
 + elif(units <= 200):
 +    amount = 130 + 162.50 + ((units - 100) * 5.26)
 +    surcharge = 45
 + else:
 +    amount = 130 + 162.50 + 526 + ((units - 200) * 8.45)
 +    surcharge = 75
 + total = amount + surcharge
 + return total
\ No newline at end of file diff --git a/progs/a5.py b/progs/a5.py new file mode 100644 index 0000000..f34be68 --- /dev/null +++ b/progs/a5.py @@ -0,0 +1,4 @@ +import math
 +def radian_degree(degree):
 + radian = degree*(math.pi/180)
 + return radian
\ No newline at end of file diff --git a/progs/a50.py b/progs/a50.py new file mode 100644 index 0000000..89cc540 --- /dev/null +++ b/progs/a50.py @@ -0,0 +1,3 @@ +def check_subset(test_tup1, test_tup2):
 +  res = set(test_tup2).issubset(test_tup1)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a500.py b/progs/a500.py new file mode 100644 index 0000000..3c60a5d --- /dev/null +++ b/progs/a500.py @@ -0,0 +1,10 @@ +from array import array
 +def zero_count(nums):
 +    n = len(nums)
 +    n1 = 0
 +    for x in nums:
 +        if x == 0:
 +            n1 += 1
 +        else:
 +          None
 +    return round(n1/n,2)
\ No newline at end of file diff --git a/progs/a501.py b/progs/a501.py new file mode 100644 index 0000000..bbcc4db --- /dev/null +++ b/progs/a501.py @@ -0,0 +1,5 @@ +def is_Sum_Of_Powers_Of_Two(n): 
 +    if (n % 2 == 1): 
 +        return False
 +    else: 
 +        return True
\ No newline at end of file diff --git a/progs/a502.py b/progs/a502.py new file mode 100644 index 0000000..6c17031 --- /dev/null +++ b/progs/a502.py @@ -0,0 +1,3 @@ +def circle_circumference(r):
 +  perimeter=2*3.1415*r
 +  return perimeter
\ No newline at end of file diff --git a/progs/a503.py b/progs/a503.py new file mode 100644 index 0000000..5046f85 --- /dev/null +++ b/progs/a503.py @@ -0,0 +1,9 @@ +def extract_singly(test_list):
 +  res = []
 +  temp = set()
 +  for inner in test_list:
 +    for ele in inner:
 +      if not ele in temp:
 +        temp.add(ele)
 +        res.append(ele)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a504.py b/progs/a504.py new file mode 100644 index 0000000..fac440a --- /dev/null +++ b/progs/a504.py @@ -0,0 +1,8 @@ +def pancake_sort(nums):
 +    arr_len = len(nums)
 +    while arr_len > 1:
 +        mi = nums.index(max(nums[0:arr_len]))
 +        nums = nums[mi::-1] + nums[mi+1:len(nums)]
 +        nums = nums[arr_len-1::-1] + nums[arr_len:len(nums)]
 +        arr_len -= 1
 +    return nums
\ No newline at end of file diff --git a/progs/a505.py b/progs/a505.py new file mode 100644 index 0000000..60cf63e --- /dev/null +++ b/progs/a505.py @@ -0,0 +1,3 @@ +def count_samepair(list1,list2,list3):
 +    result = sum(m == n == o for m, n, o in zip(list1,list2,list3))
 +    return result
\ No newline at end of file diff --git a/progs/a506.py b/progs/a506.py new file mode 100644 index 0000000..4104ad8 --- /dev/null +++ b/progs/a506.py @@ -0,0 +1,5 @@ +def find_lists(Input): 
 +	if isinstance(Input, list): 
 +		return 1
 +	else: 
 +		return len(Input) 
\ No newline at end of file diff --git a/progs/a507.py b/progs/a507.py new file mode 100644 index 0000000..ac38919 --- /dev/null +++ b/progs/a507.py @@ -0,0 +1,5 @@ +def sum_Pairs(arr,n): 
 +    sum = 0
 +    for i in range(n - 1,-1,-1): 
 +        sum += i*arr[i] - (n-1-i) * arr[i] 
 +    return sum
\ No newline at end of file diff --git a/progs/a508.py b/progs/a508.py new file mode 100644 index 0000000..646d681 --- /dev/null +++ b/progs/a508.py @@ -0,0 +1,7 @@ +def max_Abs_Diff(arr,n): 
 +    minEle = arr[0] 
 +    maxEle = arr[0] 
 +    for i in range(1, n): 
 +        minEle = min(minEle,arr[i]) 
 +        maxEle = max(maxEle,arr[i]) 
 +    return (maxEle - minEle) 
\ No newline at end of file diff --git a/progs/a509.py b/progs/a509.py new file mode 100644 index 0000000..f90181a --- /dev/null +++ b/progs/a509.py @@ -0,0 +1,3 @@ +def ascii_value_string(str1):
 +  for i in range(len(str1)):
 +   return ord(str1[i])
\ No newline at end of file diff --git a/progs/a510.py b/progs/a510.py new file mode 100644 index 0000000..ca69f29 --- /dev/null +++ b/progs/a510.py @@ -0,0 +1,8 @@ +def max_path_sum(tri, m, n): 
 +	for i in range(m-1, -1, -1): 
 +		for j in range(i+1): 
 +			if (tri[i+1][j] > tri[i+1][j+1]): 
 +				tri[i][j] += tri[i+1][j] 
 +			else: 
 +				tri[i][j] += tri[i+1][j+1] 
 +	return tri[0][0]
\ No newline at end of file diff --git a/progs/a511.py b/progs/a511.py new file mode 100644 index 0000000..8855ae1 --- /dev/null +++ b/progs/a511.py @@ -0,0 +1,14 @@ +def sum_digits_single(x) : 
 +    ans = 0
 +    while x : 
 +        ans += x % 10
 +        x //= 10  
 +    return ans 
 +def closest(x) : 
 +    ans = 0
 +    while (ans * 10 + 9 <= x) : 
 +        ans = ans * 10 + 9  
 +    return ans   
 +def sum_digits_twoparts(N) : 
 +    A = closest(N)  
 +    return sum_digits_single(A) + sum_digits_single(N - A) 
\ No newline at end of file diff --git a/progs/a512.py b/progs/a512.py new file mode 100644 index 0000000..d2be437 --- /dev/null +++ b/progs/a512.py @@ -0,0 +1,11 @@ +def longest_subseq_with_diff_one(arr, n): 
 +	dp = [1 for i in range(n)] 
 +	for i in range(n): 
 +		for j in range(i): 
 +			if ((arr[i] == arr[j]+1) or (arr[i] == arr[j]-1)): 
 +				dp[i] = max(dp[i], dp[j]+1) 
 +	result = 1
 +	for i in range(n): 
 +		if (result < dp[i]): 
 +			result = dp[i] 
 +	return result
\ No newline at end of file diff --git a/progs/a513.py b/progs/a513.py new file mode 100644 index 0000000..6d316ab --- /dev/null +++ b/progs/a513.py @@ -0,0 +1,6 @@ +def does_Contain_B(a,b,c): 
 +    if (a == b): 
 +        return True
 +    if ((b - a) * c > 0 and (b - a) % c == 0): 
 +        return True
 +    return False
\ No newline at end of file diff --git a/progs/a514.py b/progs/a514.py new file mode 100644 index 0000000..9e850e6 --- /dev/null +++ b/progs/a514.py @@ -0,0 +1,6 @@ +def gcd(p,q):
 +    while q != 0:
 +        p, q = q,p%q
 +    return p
 +def is_coprime(x,y):
 +    return gcd(x,y) == 1
\ No newline at end of file diff --git a/progs/a515.py b/progs/a515.py new file mode 100644 index 0000000..b57466d --- /dev/null +++ b/progs/a515.py @@ -0,0 +1,22 @@ +def merge(a,b):
 +    c = []
 +    while len(a) != 0 and len(b) != 0:
 +        if a[0] < b[0]:
 +            c.append(a[0])
 +            a.remove(a[0])
 +        else:
 +            c.append(b[0])
 +            b.remove(b[0])
 +    if len(a) == 0:
 +        c += b
 +    else:
 +        c += a
 +    return c
 +def merge_sort(x):
 +    if len(x) == 0 or len(x) == 1:
 +        return x
 +    else:
 +        middle = len(x)//2
 +        a = merge_sort(x[:middle])
 +        b = merge_sort(x[middle:])
 +        return merge(a,b)
 diff --git a/progs/a516.py b/progs/a516.py new file mode 100644 index 0000000..c3be567 --- /dev/null +++ b/progs/a516.py @@ -0,0 +1,3 @@ +def parabola_vertex(a, b, c): 
 +  vertex=(((-b / (2 * a)),(((4 * a * c) - (b * b)) / (4 * a))))
 +  return vertex
\ No newline at end of file diff --git a/progs/a517.py b/progs/a517.py new file mode 100644 index 0000000..3fa6364 --- /dev/null +++ b/progs/a517.py @@ -0,0 +1,3 @@ +def specified_element(nums, N):
 +    result = [i[N] for i in nums]
 +    return result
\ No newline at end of file diff --git a/progs/a518.py b/progs/a518.py new file mode 100644 index 0000000..0eda7da --- /dev/null +++ b/progs/a518.py @@ -0,0 +1,8 @@ +def even_bit_toggle_number(n) : 
 +    res = 0; count = 0; temp = n 
 +    while (temp > 0) :     
 +        if (count % 2 == 1) : 
 +            res = res | (1 << count)      
 +        count = count + 1
 +        temp >>= 1 
 +    return n ^ res 
\ No newline at end of file diff --git a/progs/a519.py b/progs/a519.py new file mode 100644 index 0000000..04b5055 --- /dev/null +++ b/progs/a519.py @@ -0,0 +1,3 @@ +def tuple_int_str(tuple_str):
 +    result = tuple((int(x[0]), int(x[1])) for x in tuple_str)
 +    return result
\ No newline at end of file diff --git a/progs/a52.py b/progs/a52.py new file mode 100644 index 0000000..4a0b33a --- /dev/null +++ b/progs/a52.py @@ -0,0 +1,6 @@ +from collections import defaultdict
 +def grouping_dictionary(l):
 +    d = defaultdict(list)
 +    for k, v in l:
 +        d[k].append(v)
 +    return d
\ No newline at end of file diff --git a/progs/a520.py b/progs/a520.py new file mode 100644 index 0000000..6ec2c1f --- /dev/null +++ b/progs/a520.py @@ -0,0 +1,3 @@ +from itertools import groupby
 +def encode_list(list1):
 +    return [[len(list(group)), key] for key, group in groupby(list1)]
\ No newline at end of file diff --git a/progs/a521.py b/progs/a521.py new file mode 100644 index 0000000..3e59623 --- /dev/null +++ b/progs/a521.py @@ -0,0 +1,9 @@ +def min_Ops(arr,n,k): 
 +    max1 = max(arr) 
 +    res = 0
 +    for i in range(0,n):  
 +        if ((max1 - arr[i]) % k != 0): 
 +            return -1 
 +        else: 
 +            res += (max1 - arr[i]) / k 
 +    return int(res) 
\ No newline at end of file diff --git a/progs/a522.py b/progs/a522.py new file mode 100644 index 0000000..031a5db --- /dev/null +++ b/progs/a522.py @@ -0,0 +1,22 @@ +def month_season(month,days):
 + if month in ('January', 'February', 'March'):
 +	 season = 'winter'
 + elif month in ('April', 'May', 'June'):
 +	 season = 'spring'
 + elif month in ('July', 'August', 'September'):
 +	 season = 'summer'
 + else:
 +	 season = 'autumn'
 + if (month == 'March') and (days > 19):
 +	 season = 'spring'
 + elif (month == 'June') and (days > 20):
 +	 season = 'summer'
 + elif (month == 'September') and (days > 21):
 +	 season = 'autumn'
 + elif (month == 'October') and (days > 21):
 +	 season = 'autumn'
 + elif (month == 'November') and (days > 21):
 +	 season = 'autumn'
 + elif (month == 'December') and (days > 20):
 +	 season = 'winter'
 + return season
\ No newline at end of file diff --git a/progs/a523.py b/progs/a523.py new file mode 100644 index 0000000..d83e1fc --- /dev/null +++ b/progs/a523.py @@ -0,0 +1,9 @@ +def solution (a, b, n): 
 +	i = 0
 +	while i * a <= n: 
 +		if (n - (i * a)) % b == 0: 
 +			return ("x = ",i ,", y = ", 
 +			int((n - (i * a)) / b)) 
 +			return 0
 +		i = i + 1
 +	return ("No solution") 
\ No newline at end of file diff --git a/progs/a524.py b/progs/a524.py new file mode 100644 index 0000000..8b32314 --- /dev/null +++ b/progs/a524.py @@ -0,0 +1,3 @@ +def remove_elements(list1, list2):
 +    result = [x for x in list1 if x not in list2]
 +    return result
\ No newline at end of file diff --git a/progs/a525.py b/progs/a525.py new file mode 100644 index 0000000..06cd0a5 --- /dev/null +++ b/progs/a525.py @@ -0,0 +1,5 @@ +def sum_series(n):
 +  if n < 1:
 +    return 0
 +  else:
 +    return n + sum_series(n - 2)
\ No newline at end of file diff --git a/progs/a526.py b/progs/a526.py new file mode 100644 index 0000000..acf2c66 --- /dev/null +++ b/progs/a526.py @@ -0,0 +1,4 @@ +from math import tan, pi
 +def area_polygon(s,l):
 +  area = s * (l ** 2) / (4 * tan(pi / s))
 +  return area
\ No newline at end of file diff --git a/progs/a527.py b/progs/a527.py new file mode 100644 index 0000000..1096645 --- /dev/null +++ b/progs/a527.py @@ -0,0 +1,11 @@ +import math 
 +def divSum(n): 
 +    sum = 1; 
 +    i = 2; 
 +    while(i * i <= n): 
 +        if (n % i == 0): 
 +            sum = (sum + i +math.floor(n / i)); 
 +        i += 1; 
 +    return sum; 
 +def areEquivalent(num1,num2): 
 +    return divSum(num1) == divSum(num2); 
\ No newline at end of file diff --git a/progs/a528.py b/progs/a528.py new file mode 100644 index 0000000..e6f7c73 --- /dev/null +++ b/progs/a528.py @@ -0,0 +1,7 @@ +def count_char_position(str1): 
 +    count_chars = 0
 +    for i in range(len(str1)):
 +        if ((i == ord(str1[i]) - ord('A')) or 
 +            (i == ord(str1[i]) - ord('a'))): 
 +            count_chars += 1
 +    return count_chars 
\ No newline at end of file diff --git a/progs/a529.py b/progs/a529.py new file mode 100644 index 0000000..b4acdbc --- /dev/null +++ b/progs/a529.py @@ -0,0 +1,7 @@ +def find_even_Pair(A,N): 
 +    evenPair = 0
 +    for i in range(0,N): 
 +        for j in range(i+1,N): 
 +            if ((A[i] ^ A[j]) % 2 == 0): 
 +                evenPair+=1
 +    return evenPair; 
\ No newline at end of file diff --git a/progs/a53.py b/progs/a53.py new file mode 100644 index 0000000..e27892f --- /dev/null +++ b/progs/a53.py @@ -0,0 +1,3 @@ +def rectangle_perimeter(l,b):
 +  perimeter=2*(l+b)
 +  return perimeter
\ No newline at end of file diff --git a/progs/a530.py b/progs/a530.py new file mode 100644 index 0000000..fb9221a --- /dev/null +++ b/progs/a530.py @@ -0,0 +1,8 @@ +def next_Power_Of_2(n): 
 +    count = 0; 
 +    if (n and not(n & (n - 1))): 
 +        return n   
 +    while( n != 0): 
 +        n >>= 1
 +        count += 1
 +    return 1 << count; 
\ No newline at end of file diff --git a/progs/a531.py b/progs/a531.py new file mode 100644 index 0000000..b87291e --- /dev/null +++ b/progs/a531.py @@ -0,0 +1,5 @@ +def frequency(a,x): 
 +    count = 0  
 +    for i in a: 
 +        if i == x: count += 1
 +    return count 
\ No newline at end of file diff --git a/progs/a532.py b/progs/a532.py new file mode 100644 index 0000000..dc8e817 --- /dev/null +++ b/progs/a532.py @@ -0,0 +1,10 @@ +def get_pell(n): 
 +	if (n <= 2): 
 +		return n 
 +	a = 1
 +	b = 2
 +	for i in range(3, n+1): 
 +		c = 2 * b + a 
 +		a = b 
 +		b = c 
 +	return b 
\ No newline at end of file diff --git a/progs/a533.py b/progs/a533.py new file mode 100644 index 0000000..968f72d --- /dev/null +++ b/progs/a533.py @@ -0,0 +1,5 @@ +def sum_range_list(list1, m, n):                                                                                                                                                                                                
 +    sum_range = 0                                                                                                                                                                                                         
 +    for i in range(m, n+1, 1):                                                                                                                                                                                        
 +        sum_range += list1[i]                                                                                                                                                                                                  
 +    return sum_range   
\ No newline at end of file diff --git a/progs/a534.py b/progs/a534.py new file mode 100644 index 0000000..5ce269b --- /dev/null +++ b/progs/a534.py @@ -0,0 +1,4 @@ +import math
 +def perimeter_pentagon(a):
 +  perimeter=(5*a)
 +  return perimeter
\ No newline at end of file diff --git a/progs/a535.py b/progs/a535.py new file mode 100644 index 0000000..f72fd65 --- /dev/null +++ b/progs/a535.py @@ -0,0 +1,6 @@ +def count_occurance(s):
 +  count=0
 +  for i in range(len(s)):
 +    if (s[i]== 's' and s[i+1]=='t' and s[i+2]== 'd'):
 +      count = count + 1
 +  return count
\ No newline at end of file diff --git a/progs/a536.py b/progs/a536.py new file mode 100644 index 0000000..84f7628 --- /dev/null +++ b/progs/a536.py @@ -0,0 +1,4 @@ +import re
 +def remove_splchar(text): 
 + pattern = re.compile('[\W_]+')
 + return (pattern.sub('', text))
\ No newline at end of file diff --git a/progs/a537.py b/progs/a537.py new file mode 100644 index 0000000..f1b2e6a --- /dev/null +++ b/progs/a537.py @@ -0,0 +1,5 @@ +def group_keyvalue(l):
 +    result = {}
 +    for k, v in l:
 +         result.setdefault(k, []).append(v)
 +    return result
\ No newline at end of file diff --git a/progs/a539.py b/progs/a539.py new file mode 100644 index 0000000..f497de7 --- /dev/null +++ b/progs/a539.py @@ -0,0 +1,3 @@ +def perimeter_triangle(a,b,c):
 +  perimeter=a+b+c
 +  return perimeter
\ No newline at end of file diff --git a/progs/a54.py b/progs/a54.py new file mode 100644 index 0000000..e6dbb1e --- /dev/null +++ b/progs/a54.py @@ -0,0 +1,5 @@ +def fifth_Power_Sum(n) : 
 +    sm = 0 
 +    for i in range(1,n+1) : 
 +        sm = sm + (i*i*i*i*i) 
 +    return sm 
\ No newline at end of file diff --git a/progs/a540.py b/progs/a540.py new file mode 100644 index 0000000..ebc10f0 --- /dev/null +++ b/progs/a540.py @@ -0,0 +1,5 @@ +def answer(L,R): 
 +    if (2 * L <= R): 
 +        return (L ,2*L)
 +    else: 
 +        return (-1) 
\ No newline at end of file diff --git a/progs/a541.py b/progs/a541.py new file mode 100644 index 0000000..c814a57 --- /dev/null +++ b/progs/a541.py @@ -0,0 +1,7 @@ +import re
 +def string_literals(patterns,text):
 +  for pattern in patterns:
 +     if re.search(pattern,  text):
 +       return ('Matched!')
 +     else:
 +       return ('Not Matched!')
\ No newline at end of file diff --git a/progs/a542.py b/progs/a542.py new file mode 100644 index 0000000..a254bee --- /dev/null +++ b/progs/a542.py @@ -0,0 +1,18 @@ +def is_num_keith(x): 
 +	terms = [] 
 +	temp = x 
 +	n = 0 
 +	while (temp > 0): 
 +		terms.append(temp % 10) 
 +		temp = int(temp / 10) 
 +		n+=1 
 +	terms.reverse() 
 +	next_term = 0 
 +	i = n 
 +	while (next_term < x): 
 +		next_term = 0 
 +		for j in range(1,n+1): 
 +			next_term += terms[i - j] 
 +		terms.append(next_term) 
 +		i+=1 
 +	return (next_term == x) 
\ No newline at end of file diff --git a/progs/a543.py b/progs/a543.py new file mode 100644 index 0000000..d8b8305 --- /dev/null +++ b/progs/a543.py @@ -0,0 +1,4 @@ +from math import radians, sin, cos, acos
 +def distance_lat_long(slat,slon,elat,elon):
 + dist = 6371.01 * acos(sin(slat)*sin(elat) + cos(slat)*cos(elat)*cos(slon - elon))
 + return dist
\ No newline at end of file diff --git a/progs/a544.py b/progs/a544.py new file mode 100644 index 0000000..aaa2438 --- /dev/null +++ b/progs/a544.py @@ -0,0 +1,18 @@ +def common_prefix_util(str1, str2): 
 +	result = ""; 
 +	n1 = len(str1) 
 +	n2 = len(str2) 
 +	i = 0
 +	j = 0
 +	while i <= n1 - 1 and j <= n2 - 1: 
 +		if (str1[i] != str2[j]): 
 +			break
 +		result += str1[i] 
 +		i += 1
 +		j += 1
 +	return (result) 
 +def common_prefix (arr, n): 
 +	prefix = arr[0] 
 +	for i in range (1, n): 
 +		prefix = common_prefix_util(prefix, arr[i]) 
 +	return (prefix) 
\ No newline at end of file diff --git a/progs/a546.py b/progs/a546.py new file mode 100644 index 0000000..4b9bbc9 --- /dev/null +++ b/progs/a546.py @@ -0,0 +1,7 @@ +def count_pairs(arr, n, k):
 +  count=0;
 +  for i in range(0,n):
 +    for j in range(i+1, n):
 +      if arr[i] - arr[j] == k or arr[j] - arr[i] == k:
 +        count += 1
 +  return count
\ No newline at end of file diff --git a/progs/a547.py b/progs/a547.py new file mode 100644 index 0000000..e22fcb5 --- /dev/null +++ b/progs/a547.py @@ -0,0 +1,3 @@ +def greater_specificnum(list,num):
 + greater_specificnum=all(x >= num for x in list)
 + return greater_specificnum
\ No newline at end of file diff --git a/progs/a548.py b/progs/a548.py new file mode 100644 index 0000000..0345db2 --- /dev/null +++ b/progs/a548.py @@ -0,0 +1,3 @@ +def parabola_focus(a, b, c): 
 +  focus= (((-b / (2 * a)),(((4 * a * c) - (b * b) + 1) / (4 * a))))
 +  return focus
\ No newline at end of file diff --git a/progs/a549.py b/progs/a549.py new file mode 100644 index 0000000..4bc1643 --- /dev/null +++ b/progs/a549.py @@ -0,0 +1,7 @@ +import re
 +def check_literals(text, patterns):
 +  for pattern in patterns:
 +    if re.search(pattern,  text):
 +        return ('Matched!')
 +    else:
 +        return ('Not Matched!')
\ No newline at end of file diff --git a/progs/a55.py b/progs/a55.py new file mode 100644 index 0000000..219b207 --- /dev/null +++ b/progs/a55.py @@ -0,0 +1,7 @@ +def find_Min_Sum(a,b,n): 
 +    a.sort() 
 +    b.sort() 
 +    sum = 0  
 +    for i in range(n): 
 +        sum = sum + abs(a[i] - b[i]) 
 +    return sum
\ No newline at end of file diff --git a/progs/a550.py b/progs/a550.py new file mode 100644 index 0000000..222f51e --- /dev/null +++ b/progs/a550.py @@ -0,0 +1,7 @@ +def longest_common_subsequence(X, Y, m, n): 
 +    if m == 0 or n == 0: 
 +       return 0 
 +    elif X[m-1] == Y[n-1]: 
 +       return 1 + longest_common_subsequence(X, Y, m-1, n-1) 
 +    else: 
 +       return max(longest_common_subsequence(X, Y, m, n-1), longest_common_subsequence(X, Y, m-1, n))
\ No newline at end of file diff --git a/progs/a551.py b/progs/a551.py new file mode 100644 index 0000000..6a39745 --- /dev/null +++ b/progs/a551.py @@ -0,0 +1,7 @@ +def prod_Square(n):
 +    for i in range(2,(n) + 1):
 +        if (i*i < (n+1)):
 +            for j in range(2,n + 1):
 +                if ((i*i*j*j) == n):
 +                    return True;
 +    return False;
\ No newline at end of file diff --git a/progs/a552.py b/progs/a552.py new file mode 100644 index 0000000..5d11019 --- /dev/null +++ b/progs/a552.py @@ -0,0 +1,17 @@ +def first_Missing_Positive(arr,n): 
 +    ptr = 0
 +    for i in range(n):
 +        if arr[i] == 1:
 +            ptr = 1
 +            break
 +    if ptr == 0:
 +        return(1)
 +    for i in range(n):
 +        if arr[i] <= 0 or arr[i] > n:
 +            arr[i] = 1
 +    for i in range(n):
 +        arr[(arr[i] - 1) % n] += n
 +    for i in range(n):
 +        if arr[i] <= n:
 +            return(i + 1)
 +    return(n + 1)
\ No newline at end of file diff --git a/progs/a553.py b/progs/a553.py new file mode 100644 index 0000000..ab5fbc4 --- /dev/null +++ b/progs/a553.py @@ -0,0 +1,2 @@ +def count_Intgral_Points(x1,y1,x2,y2): 
 +    return ((y2 - y1 - 1) * (x2 - x1 - 1)) 
\ No newline at end of file diff --git a/progs/a554.py b/progs/a554.py new file mode 100644 index 0000000..bc6feab --- /dev/null +++ b/progs/a554.py @@ -0,0 +1,5 @@ +def check_monthnumber(monthname3):
 +  if monthname3 =="April" or monthname3== "June" or monthname3== "September" or monthname3== "November":
 +    return True
 +  else:
 +    return False
\ No newline at end of file diff --git a/progs/a555.py b/progs/a555.py new file mode 100644 index 0000000..449ca5d --- /dev/null +++ b/progs/a555.py @@ -0,0 +1,9 @@ +def check_String(str): 
 +    flag_l = False
 +    flag_n = False
 +    for i in str: 
 +        if i.isalpha(): 
 +            flag_l = True  
 +        if i.isdigit(): 
 +            flag_n = True
 +    return flag_l and flag_n 
\ No newline at end of file diff --git a/progs/a556.py b/progs/a556.py new file mode 100644 index 0000000..1ae9d58 --- /dev/null +++ b/progs/a556.py @@ -0,0 +1,3 @@ +def remove_tuple(test_tup):
 +  res = tuple(set(test_tup))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a557.py b/progs/a557.py new file mode 100644 index 0000000..47ccf9d --- /dev/null +++ b/progs/a557.py @@ -0,0 +1,11 @@ +def octal_To_Decimal(n):  
 +    num = n; 
 +    dec_value = 0; 
 +    base = 1; 
 +    temp = num; 
 +    while (temp): 
 +        last_digit = temp % 10; 
 +        temp = int(temp / 10); 
 +        dec_value += last_digit*base; 
 +        base = base * 8; 
 +    return dec_value; 
\ No newline at end of file diff --git a/progs/a558.py b/progs/a558.py new file mode 100644 index 0000000..804d9d5 --- /dev/null +++ b/progs/a558.py @@ -0,0 +1,14 @@ +def first(arr,x,n): 
 +    low = 0
 +    high = n - 1
 +    res = -1  
 +    while (low <= high):
 +        mid = (low + high) // 2 
 +        if arr[mid] > x:
 +            high = mid - 1
 +        elif arr[mid] < x:
 +            low = mid + 1
 +        else:
 +            res = mid
 +            high = mid - 1
 +    return res
\ No newline at end of file diff --git a/progs/a559.py b/progs/a559.py new file mode 100644 index 0000000..c782fab --- /dev/null +++ b/progs/a559.py @@ -0,0 +1,3 @@ +def remove_tuples(test_list, K):
 +  res = [ele for ele in test_list if len(ele) != K]
 +  return (res) 
\ No newline at end of file diff --git a/progs/a56.py b/progs/a56.py new file mode 100644 index 0000000..2594f60 --- /dev/null +++ b/progs/a56.py @@ -0,0 +1,10 @@ +import math 
 +def first_Digit(n) : 
 +    fact = 1
 +    for i in range(2,n + 1) : 
 +        fact = fact * i 
 +        while (fact % 10 == 0) :  
 +            fact = int(fact / 10) 
 +    while (fact >= 10) : 
 +        fact = int(fact / 10) 
 +    return math.floor(fact) 
\ No newline at end of file diff --git a/progs/a560.py b/progs/a560.py new file mode 100644 index 0000000..8b1b46e --- /dev/null +++ b/progs/a560.py @@ -0,0 +1,3 @@ +def find_exponentio(test_tup1, test_tup2):
 +  res = tuple(ele1 ** ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
 +  return (res)
 diff --git a/progs/a561.py b/progs/a561.py new file mode 100644 index 0000000..72aba95 --- /dev/null +++ b/progs/a561.py @@ -0,0 +1,6 @@ +import math
 +def largest_triangle(a,b): 
 +    if (a < 0 or b < 0): 
 +        return -1 
 +    area = (3 * math.sqrt(3) * pow(a, 2)) / (4 * b);  
 +    return area 
\ No newline at end of file diff --git a/progs/a562.py b/progs/a562.py new file mode 100644 index 0000000..9cf91d4 --- /dev/null +++ b/progs/a562.py @@ -0,0 +1,7 @@ +def highest_Power_of_2(n): 
 +    res = 0; 
 +    for i in range(n, 0, -1):  
 +        if ((i & (i - 1)) == 0): 
 +            res = i; 
 +            break;      
 +    return res; 
\ No newline at end of file diff --git a/progs/a563.py b/progs/a563.py new file mode 100644 index 0000000..a8fd5d1 --- /dev/null +++ b/progs/a563.py @@ -0,0 +1,4 @@ +def position_max(list1):
 +    max_val = max(list1)
 +    max_result = [i for i, j in enumerate(list1) if j == max_val]
 +    return max_result
\ No newline at end of file diff --git a/progs/a564.py b/progs/a564.py new file mode 100644 index 0000000..4a5b5c3 --- /dev/null +++ b/progs/a564.py @@ -0,0 +1,2 @@ +def chkList(lst): 
 +    return len(set(lst)) == 1
\ No newline at end of file diff --git a/progs/a565.py b/progs/a565.py new file mode 100644 index 0000000..2322588 --- /dev/null +++ b/progs/a565.py @@ -0,0 +1,6 @@ +def remove_even(str1):
 + str2 = ''
 + for i in range(1, len(str1) + 1):
 +    if(i % 2 != 0):
 +        str2 = str2 + str1[i - 1]
 + return str2
\ No newline at end of file diff --git a/progs/a566.py b/progs/a566.py new file mode 100644 index 0000000..4ff8329 --- /dev/null +++ b/progs/a566.py @@ -0,0 +1,7 @@ +def hamming_Distance(n1,n2) : 
 +    x = n1 ^ n2  
 +    setBits = 0
 +    while (x > 0) : 
 +        setBits += x & 1
 +        x >>= 1
 +    return setBits  
\ No newline at end of file diff --git a/progs/a567.py b/progs/a567.py new file mode 100644 index 0000000..5caf29d --- /dev/null +++ b/progs/a567.py @@ -0,0 +1,6 @@ +def count(s,c) : 
 +    res = 0 
 +    for i in range(len(s)) : 
 +        if (s[i] == c): 
 +            res = res + 1
 +    return res 
\ No newline at end of file diff --git a/progs/a569.py b/progs/a569.py new file mode 100644 index 0000000..226ffd8 --- /dev/null +++ b/progs/a569.py @@ -0,0 +1,3 @@ +def concatenate_elements(test_tup):
 +  res = tuple(i + j for i, j in zip(test_tup, test_tup[1:]))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a57.py b/progs/a57.py new file mode 100644 index 0000000..92aa257 --- /dev/null +++ b/progs/a57.py @@ -0,0 +1,9 @@ +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
\ No newline at end of file diff --git a/progs/a570.py b/progs/a570.py new file mode 100644 index 0000000..40d8888 --- /dev/null +++ b/progs/a570.py @@ -0,0 +1,10 @@ +def find_longest_repeating_subseq(str): 
 +	n = len(str) 
 +	dp = [[0 for k in range(n+1)] for l in range(n+1)] 
 +	for i in range(1, n+1): 
 +		for j in range(1, n+1): 
 +			if (str[i-1] == str[j-1] and i != j): 
 +				dp[i][j] = 1 + dp[i-1][j-1] 
 +			else: 
 +				dp[i][j] = max(dp[i][j-1], dp[i-1][j]) 
 +	return dp[n][n]
\ No newline at end of file diff --git a/progs/a572.py b/progs/a572.py new file mode 100644 index 0000000..d8b4fb6 --- /dev/null +++ b/progs/a572.py @@ -0,0 +1,5 @@ +import heapq as hq
 +def heap_replace(heap,a):
 +  hq.heapify(heap)
 +  hq.heapreplace(heap, a)
 +  return heap
\ No newline at end of file diff --git a/progs/a574.py b/progs/a574.py new file mode 100644 index 0000000..9d385a3 --- /dev/null +++ b/progs/a574.py @@ -0,0 +1,5 @@ +def count_Num(n): 
 +    if (n == 1): 
 +        return 1
 +    count = pow(2,n - 2) 
 +    return count 
\ No newline at end of file diff --git a/progs/a575.py b/progs/a575.py new file mode 100644 index 0000000..9fa7638 --- /dev/null +++ b/progs/a575.py @@ -0,0 +1,6 @@ +import math  
 +def fourth_Power_Sum(n): 
 +    sum = 0
 +    for i in range(1,n+1) : 
 +        sum = sum + (i*i*i*i) 
 +    return sum
\ No newline at end of file diff --git a/progs/a576.py b/progs/a576.py new file mode 100644 index 0000000..c7c8e19 --- /dev/null +++ b/progs/a576.py @@ -0,0 +1,3 @@ +def concatenate_strings(test_tup1, test_tup2):
 +  res = tuple(ele1 + ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a577.py b/progs/a577.py new file mode 100644 index 0000000..3c79047 --- /dev/null +++ b/progs/a577.py @@ -0,0 +1,4 @@ +import math
 +def degree_radian(radian):
 + degree = radian*(180/math.pi)
 + return degree
\ No newline at end of file diff --git a/progs/a578.py b/progs/a578.py new file mode 100644 index 0000000..f8802cf --- /dev/null +++ b/progs/a578.py @@ -0,0 +1,7 @@ +def decode_list(alist):
 +    def aux(g):
 +        if isinstance(g, list):
 +            return [(g[1], range(g[0]))]
 +        else:
 +            return [(g, [0])]
 +    return [x for g in alist for x, R in aux(g) for i in R]
\ No newline at end of file diff --git a/progs/a579.py b/progs/a579.py new file mode 100644 index 0000000..675ecc1 --- /dev/null +++ b/progs/a579.py @@ -0,0 +1,7 @@ +def check_subset_list(list1, list2): 
 +    l1, l2 = list1[0], list2[0] 
 +    exist = True
 +    for i in list2: 
 +        if i not in list1: 
 +            exist = False
 +    return exist 
\ No newline at end of file diff --git a/progs/a58.py b/progs/a58.py new file mode 100644 index 0000000..fa05089 --- /dev/null +++ b/progs/a58.py @@ -0,0 +1,9 @@ +def Repeat(x): 
 +    _size = len(x) 
 +    repeated = [] 
 +    for i in range(_size): 
 +        k = i + 1
 +        for j in range(k, _size): 
 +            if x[i] == x[j] and x[i] not in repeated: 
 +                repeated.append(x[i]) 
 +    return repeated 
\ No newline at end of file diff --git a/progs/a580.py b/progs/a580.py new file mode 100644 index 0000000..3bc645a --- /dev/null +++ b/progs/a580.py @@ -0,0 +1,8 @@ +def first_Repeated_Char(str): 
 +    h = {}
 +    for ch in str:
 +        if ch in h: 
 +            return ch;
 +        else: 
 +            h[ch] = 0
 +    return '\0'
\ No newline at end of file diff --git a/progs/a581.py b/progs/a581.py new file mode 100644 index 0000000..e6a3359 --- /dev/null +++ b/progs/a581.py @@ -0,0 +1,6 @@ +import math   
 +def min_Operations(A,B):  
 +    if (A > B): 
 +        swap(A,B)  
 +    B = B // math.gcd(A,B);  
 +    return B - 1
\ No newline at end of file diff --git a/progs/a582.py b/progs/a582.py new file mode 100644 index 0000000..ac44fae --- /dev/null +++ b/progs/a582.py @@ -0,0 +1,10 @@ +
 +def extract_min_max(test_tup, K):
 +  res = []
 +  test_tup = list(test_tup)
 +  temp = sorted(test_tup)
 +  for idx, val in enumerate(temp):
 +    if idx < K or idx >= len(temp) - K:
 +      res.append(val)
 +  res = tuple(res)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a583.py b/progs/a583.py new file mode 100644 index 0000000..d9f40c7 --- /dev/null +++ b/progs/a583.py @@ -0,0 +1,3 @@ +import re
 +def replace_max_specialchar(text,n):
 + return (re.sub("[ ,.]", ":", text, n))
\ No newline at end of file diff --git a/progs/a584.py b/progs/a584.py new file mode 100644 index 0000000..0833cd2 --- /dev/null +++ b/progs/a584.py @@ -0,0 +1,3 @@ +def first_even(nums):
 +    first_even = next((el for el in nums if el%2==0),-1)
 +    return first_even
\ No newline at end of file diff --git a/progs/a585.py b/progs/a585.py new file mode 100644 index 0000000..64aa5b2 --- /dev/null +++ b/progs/a585.py @@ -0,0 +1,7 @@ +def check_type(test_tuple):
 +  res = True
 +  for ele in test_tuple:
 +    if not isinstance(ele, type(test_tuple[0])):
 +      res = False
 +      break
 +  return (res) 
\ No newline at end of file diff --git a/progs/a586.py b/progs/a586.py new file mode 100644 index 0000000..d22252b --- /dev/null +++ b/progs/a586.py @@ -0,0 +1,18 @@ +def is_majority(arr, n, x):
 +	i = binary_search(arr, 0, n-1, x)
 +	if i == -1:
 +		return False
 +	if ((i + n//2) <= (n -1)) and arr[i + n//2] == x:
 +		return True
 +	else:
 +		return False
 +def binary_search(arr, low, high, x):
 +	if high >= low:
 +		mid = (low + high)//2 
 +		if (mid == 0 or x > arr[mid-1]) and (arr[mid] == x):
 +			return mid
 +		elif x > arr[mid]:
 +			return binary_search(arr, (mid + 1), high, x)
 +		else:
 +			return binary_search(arr, low, (mid -1), x)
 +	return -1
\ No newline at end of file diff --git a/progs/a587.py b/progs/a587.py new file mode 100644 index 0000000..090067e --- /dev/null +++ b/progs/a587.py @@ -0,0 +1,6 @@ +def count_Set_Bits(n): 
 +    count = 0
 +    while (n): 
 +        count += n & 1
 +        n >>= 1
 +    return count 
\ No newline at end of file diff --git a/progs/a588.py b/progs/a588.py new file mode 100644 index 0000000..2f7f299 --- /dev/null +++ b/progs/a588.py @@ -0,0 +1,10 @@ +def find_Min(arr,low,high): 
 +    while (low < high): 
 +        mid = low + (high - low) // 2;   
 +        if (arr[mid] == arr[high]): 
 +            high -= 1; 
 +        elif (arr[mid] > arr[high]): 
 +            low = mid + 1; 
 +        else: 
 +            high = mid; 
 +    return arr[high]; 
\ No newline at end of file diff --git a/progs/a589.py b/progs/a589.py new file mode 100644 index 0000000..7d008d2 --- /dev/null +++ b/progs/a589.py @@ -0,0 +1,6 @@ +def odd_values_string(str):
 +  result = "" 
 +  for i in range(len(str)):
 +    if i % 2 == 0:
 +      result = result + str[i]
 +  return result
\ No newline at end of file diff --git a/progs/a59.py b/progs/a59.py new file mode 100644 index 0000000..c0c172b --- /dev/null +++ b/progs/a59.py @@ -0,0 +1,4 @@ +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)
\ No newline at end of file diff --git a/progs/a590.py b/progs/a590.py new file mode 100644 index 0000000..dbca6c1 --- /dev/null +++ b/progs/a590.py @@ -0,0 +1,8 @@ +def min_of_three(a,b,c): 
 +      if (a <= b) and (a <= c): 
 +        smallest = a 
 +      elif (b <= a) and (b <= c): 
 +        smallest = b 
 +      else: 
 +        smallest = c 
 +      return smallest 
\ No newline at end of file diff --git a/progs/a591.py b/progs/a591.py new file mode 100644 index 0000000..3ddb9b2 --- /dev/null +++ b/progs/a591.py @@ -0,0 +1,6 @@ +def all_Bits_Set_In_The_Given_Range(n,l,r):  
 +    num = (((1 << r) - 1) ^ ((1 << (l - 1)) - 1)) 
 +    new_num = n & num
 +    if (new_num == 0): 
 +        return True
 +    return False
\ No newline at end of file diff --git a/progs/a592.py b/progs/a592.py new file mode 100644 index 0000000..b8d4ed9 --- /dev/null +++ b/progs/a592.py @@ -0,0 +1,9 @@ +def re_arrange_array(arr, n):
 +  j=0
 +  for i in range(0, n):
 +    if (arr[i] < 0):
 +      temp = arr[i]
 +      arr[i] = arr[j]
 +      arr[j] = temp
 +      j = j + 1
 +  return arr
\ No newline at end of file diff --git a/progs/a593.py b/progs/a593.py new file mode 100644 index 0000000..121a170 --- /dev/null +++ b/progs/a593.py @@ -0,0 +1,3 @@ +def replace_blank(str1,char):
 + str2 = str1.replace(' ', char)
 + return str2
\ No newline at end of file diff --git a/progs/a594.py b/progs/a594.py new file mode 100644 index 0000000..3ab2be7 --- /dev/null +++ b/progs/a594.py @@ -0,0 +1,13 @@ +def max_sum(tri, n): 
 +	if n > 1: 
 +		tri[1][1] = tri[1][1]+tri[0][0] 
 +		tri[1][0] = tri[1][0]+tri[0][0] 
 +	for i in range(2, n): 
 +		tri[i][0] = tri[i][0] + tri[i-1][0] 
 +		tri[i][i] = tri[i][i] + tri[i-1][i-1] 
 +		for j in range(1, i): 
 +			if tri[i][j]+tri[i-1][j-1] >= tri[i][j]+tri[i-1][j]: 
 +				tri[i][j] = tri[i][j] + tri[i-1][j-1] 
 +			else: 
 +				tri[i][j] = tri[i][j]+tri[i-1][j] 
 +	return (max(tri[n-1]))
\ No newline at end of file diff --git a/progs/a595.py b/progs/a595.py new file mode 100644 index 0000000..e4ede5e --- /dev/null +++ b/progs/a595.py @@ -0,0 +1,4 @@ +import heapq
 +def larg_nnum(list1,n):
 + largest=heapq.nlargest(n,list1)
 + return largest
\ No newline at end of file diff --git a/progs/a596.py b/progs/a596.py new file mode 100644 index 0000000..ac17e20 --- /dev/null +++ b/progs/a596.py @@ -0,0 +1,3 @@ +def lateralsuface_cylinder(r,h):
 +  lateralsurface= 2*3.1415*r*h
 +  return lateralsurface
\ No newline at end of file diff --git a/progs/a597.py b/progs/a597.py new file mode 100644 index 0000000..29bb3ea --- /dev/null +++ b/progs/a597.py @@ -0,0 +1,3 @@ +def volume_cube(l):
 +  volume = l * l * l
 +  return volume
\ No newline at end of file diff --git a/progs/a598.py b/progs/a598.py new file mode 100644 index 0000000..e9ed033 --- /dev/null +++ b/progs/a598.py @@ -0,0 +1,8 @@ +def even_bit_set_number(n): 
 +    count = 0;res = 0;temp = n 
 +    while(temp > 0): 
 +        if (count % 2 == 1): 
 +            res |= (1 << count)
 +        count+=1
 +        temp >>= 1
 +    return (n | res) 
\ No newline at end of file diff --git a/progs/a599.py b/progs/a599.py new file mode 100644 index 0000000..789a533 --- /dev/null +++ b/progs/a599.py @@ -0,0 +1,9 @@ +def No_of_Triangle(N,K):
 +    if (N < K):
 +        return -1;
 +    else:
 +        Tri_up = 0;
 +        Tri_up = ((N - K + 1) *(N - K + 2)) // 2;
 +        Tri_down = 0;
 +        Tri_down = ((N - 2 * K + 1) *(N - 2 * K + 2)) // 2;
 +        return Tri_up + Tri_down;
\ No newline at end of file diff --git a/progs/a6.py b/progs/a6.py new file mode 100644 index 0000000..466e560 --- /dev/null +++ b/progs/a6.py @@ -0,0 +1,8 @@ +import re
 +pattern = 'fox'
 +text = 'The quick brown fox jumps over the lazy dog.'
 +def find_literals(text, pattern):
 +  match = re.search(pattern, text)
 +  s = match.start()
 +  e = match.end()
 +  return (match.re.pattern, s, e)
\ No newline at end of file diff --git a/progs/a60.py b/progs/a60.py new file mode 100644 index 0000000..2118c35 --- /dev/null +++ b/progs/a60.py @@ -0,0 +1,11 @@ +def max_sum_of_three_consecutive(arr, n): 
 +	sum = [0 for k in range(n)] 
 +	if n >= 1: 
 +		sum[0] = arr[0] 
 +	if n >= 2: 
 +		sum[1] = arr[0] + arr[1] 
 +	if n > 2: 
 +		sum[2] = max(sum[1], max(arr[1] + arr[2], arr[0] + arr[2])) 
 +	for i in range(3, n): 
 +		sum[i] = max(max(sum[i-1], sum[i-2] + arr[i]), arr[i] + arr[i-1] + sum[i-3]) 
 +	return sum[n-1]
\ No newline at end of file diff --git a/progs/a600.py b/progs/a600.py new file mode 100644 index 0000000..b495ef6 --- /dev/null +++ b/progs/a600.py @@ -0,0 +1,4 @@ +from collections import Counter 
 +def check_occurences(test_list):
 +  res = dict(Counter(tuple(ele) for ele in map(sorted, test_list)))
 +  return  (res) 
\ No newline at end of file diff --git a/progs/a601.py b/progs/a601.py new file mode 100644 index 0000000..e519c4b --- /dev/null +++ b/progs/a601.py @@ -0,0 +1,3 @@ +def number_of_substrings(str): 
 +	str_len = len(str); 
 +	return int(str_len * (str_len + 1) / 2); 
\ No newline at end of file diff --git a/progs/a602.py b/progs/a602.py new file mode 100644 index 0000000..1bc248f --- /dev/null +++ b/progs/a602.py @@ -0,0 +1,13 @@ +def get_total_number_of_sequences(m,n): 
 +	T=[[0 for i in range(n+1)] for i in range(m+1)] 
 +	for i in range(m+1): 
 +		for j in range(n+1): 
 +			if i==0 or j==0: 
 +				T[i][j]=0
 +			elif i<j: 
 +				T[i][j]=0
 +			elif j==1: 
 +				T[i][j]=i 
 +			else: 
 +				T[i][j]=T[i-1][j]+T[i//2][j-1] 
 +	return T[m][n]
\ No newline at end of file diff --git a/progs/a603.py b/progs/a603.py new file mode 100644 index 0000000..beb649c --- /dev/null +++ b/progs/a603.py @@ -0,0 +1,4 @@ +def replace_list(list1,list2):
 + list1[-1:] = list2
 + replace_list=list1
 + return replace_list
 diff --git a/progs/a604.py b/progs/a604.py new file mode 100644 index 0000000..313d424 --- /dev/null +++ b/progs/a604.py @@ -0,0 +1,3 @@ +def array_3d(m,n,o):
 + array_3d = [[ ['*' for col in range(m)] for col in range(n)] for row in range(o)]
 + return array_3d
\ No newline at end of file diff --git a/progs/a605.py b/progs/a605.py new file mode 100644 index 0000000..d820c8d --- /dev/null +++ b/progs/a605.py @@ -0,0 +1,5 @@ +def count_charac(str1):
 + total = 0
 + for i in str1:
 +    total = total + 1
 + return total
\ No newline at end of file diff --git a/progs/a607.py b/progs/a607.py new file mode 100644 index 0000000..8015c13 --- /dev/null +++ b/progs/a607.py @@ -0,0 +1,4 @@ +import math  
 +def next_Perfect_Square(N): 
 +    nextN = math.floor(math.sqrt(N)) + 1
 +    return nextN * nextN 
\ No newline at end of file diff --git a/progs/a608.py b/progs/a608.py new file mode 100644 index 0000000..3d66438 --- /dev/null +++ b/progs/a608.py @@ -0,0 +1,15 @@ +def max_sum(arr, n): 
 +	MSIBS = arr[:] 
 +	for i in range(n): 
 +		for j in range(0, i): 
 +			if arr[i] > arr[j] and MSIBS[i] < MSIBS[j] + arr[i]: 
 +				MSIBS[i] = MSIBS[j] + arr[i] 
 +	MSDBS = arr[:] 
 +	for i in range(1, n + 1): 
 +		for j in range(1, i): 
 +			if arr[-i] > arr[-j] and MSDBS[-i] < MSDBS[-j] + arr[-i]: 
 +				MSDBS[-i] = MSDBS[-j] + arr[-i] 
 +	max_sum = float("-Inf") 
 +	for i, j, k in zip(MSIBS, MSDBS, arr): 
 +		max_sum = max(max_sum, i + j - k) 
 +	return max_sum
\ No newline at end of file diff --git a/progs/a609.py b/progs/a609.py new file mode 100644 index 0000000..e45607f --- /dev/null +++ b/progs/a609.py @@ -0,0 +1,10 @@ +def babylonian_squareroot(number):
 +    if(number == 0):
 +        return 0;
 +    g = number/2.0;
 +    g2 = g + 1;
 +    while(g != g2):
 +        n = number/ g;
 +        g2 = g;
 +        g = (g + n)/2;
 +    return g;
\ No newline at end of file diff --git a/progs/a610.py b/progs/a610.py new file mode 100644 index 0000000..0d349ee --- /dev/null +++ b/progs/a610.py @@ -0,0 +1,15 @@ +def lps(str): 
 +	n = len(str) 
 +	L = [[0 for x in range(n)] for x in range(n)] 
 +	for i in range(n): 
 +		L[i][i] = 1
 +	for cl in range(2, n+1): 
 +		for i in range(n-cl+1): 
 +			j = i+cl-1
 +			if str[i] == str[j] and cl == 2: 
 +				L[i][j] = 2
 +			elif str[i] == str[j]: 
 +				L[i][j] = L[i+1][j-1] + 2
 +			else: 
 +				L[i][j] = max(L[i][j-1], L[i+1][j]); 
 +	return L[0][n-1]
\ No newline at end of file diff --git a/progs/a611.py b/progs/a611.py new file mode 100644 index 0000000..ed26fe4 --- /dev/null +++ b/progs/a611.py @@ -0,0 +1,5 @@ +def harmonic_sum(n):
 +  if n < 2:
 +    return 1
 +  else:
 +    return 1 / n + (harmonic_sum(n - 1)) 
\ No newline at end of file diff --git a/progs/a613.py b/progs/a613.py new file mode 100644 index 0000000..8577279 --- /dev/null +++ b/progs/a613.py @@ -0,0 +1,6 @@ +def count_X(tup, x): 
 +    count = 0
 +    for ele in tup: 
 +        if (ele == x): 
 +            count = count + 1
 +    return count 
\ No newline at end of file diff --git a/progs/a614.py b/progs/a614.py new file mode 100644 index 0000000..457133b --- /dev/null +++ b/progs/a614.py @@ -0,0 +1,3 @@ +def insert_element(list,element):
 + list = [v for elt in list for v in (element, elt)]
 + return list
\ No newline at end of file diff --git a/progs/a615.py b/progs/a615.py new file mode 100644 index 0000000..36cd1c1 --- /dev/null +++ b/progs/a615.py @@ -0,0 +1,4 @@ +import cmath  
 +def convert(numbers):    
 +  num = cmath.polar(numbers)  
 +  return (num) 
\ No newline at end of file diff --git a/progs/a616.py b/progs/a616.py new file mode 100644 index 0000000..0db9470 --- /dev/null +++ b/progs/a616.py @@ -0,0 +1,6 @@ +def count_integer(list1):
 +    ctr = 0
 +    for i in list1:
 +        if isinstance(i, int):
 +            ctr = ctr + 1
 +    return ctr
\ No newline at end of file diff --git a/progs/a617.py b/progs/a617.py new file mode 100644 index 0000000..5271766 --- /dev/null +++ b/progs/a617.py @@ -0,0 +1,4 @@ +import re
 +def words_ae(text):
 + list = re.findall("[ae]\w+", text)
 + return list
\ No newline at end of file diff --git a/progs/a618.py b/progs/a618.py new file mode 100644 index 0000000..c231942 --- /dev/null +++ b/progs/a618.py @@ -0,0 +1,3 @@ +from itertools import combinations_with_replacement 
 +def combinations_colors(l, n):
 +    return list(combinations_with_replacement(l,n))
\ No newline at end of file diff --git a/progs/a619.py b/progs/a619.py new file mode 100644 index 0000000..f756769 --- /dev/null +++ b/progs/a619.py @@ -0,0 +1,11 @@ +def count_Primes_nums(n):
 +    ctr = 0
 +    for num in range(n):
 +        if num <= 1:
 +            continue
 +        for i in range(2,num):
 +            if (num % i) == 0:
 +                break
 +        else:
 +            ctr += 1
 +    return ctr
\ No newline at end of file diff --git a/progs/a62.py b/progs/a62.py new file mode 100644 index 0000000..771e781 --- /dev/null +++ b/progs/a62.py @@ -0,0 +1,8 @@ +import sys 
 +def find_max_val(n, x, y): 
 +	ans = -sys.maxsize 
 +	for k in range(n + 1): 
 +		if (k % x == y): 
 +			ans = max(ans, k) 
 +	return (ans if (ans >= 0 and
 +					ans <= n) else -1) 
\ No newline at end of file diff --git a/progs/a620.py b/progs/a620.py new file mode 100644 index 0000000..0e4513a --- /dev/null +++ b/progs/a620.py @@ -0,0 +1,5 @@ +def swap_numbers(a,b):
 + temp = a
 + a = b
 + b = temp
 + return (a,b)
\ No newline at end of file diff --git a/progs/a622.py b/progs/a622.py new file mode 100644 index 0000000..fa80778 --- /dev/null +++ b/progs/a622.py @@ -0,0 +1,4 @@ +def maximize_elements(test_tup1, test_tup2):
 +  res = tuple(tuple(max(a, b) for a, b in zip(tup1, tup2))
 +   for tup1, tup2 in zip(test_tup1, test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a623.py b/progs/a623.py new file mode 100644 index 0000000..3e4ade4 --- /dev/null +++ b/progs/a623.py @@ -0,0 +1,4 @@ +def newman_prime(n): 
 +	if n == 0 or n == 1: 
 +		return 1
 +	return 2 * newman_prime(n - 1) + newman_prime(n - 2)
\ No newline at end of file diff --git a/progs/a624.py b/progs/a624.py new file mode 100644 index 0000000..d7125cc --- /dev/null +++ b/progs/a624.py @@ -0,0 +1,3 @@ +def division_elements(test_tup1, test_tup2):
 +  res = tuple(ele1 // ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a625.py b/progs/a625.py new file mode 100644 index 0000000..72a246e --- /dev/null +++ b/progs/a625.py @@ -0,0 +1,2 @@ +def split_two_parts(list1, L):
 +    return list1[:L], list1[L:]
\ No newline at end of file diff --git a/progs/a626.py b/progs/a626.py new file mode 100644 index 0000000..b131c33 --- /dev/null +++ b/progs/a626.py @@ -0,0 +1,4 @@ +def merge_dict(d1,d2):
 + d = d1.copy()
 + d.update(d2)
 + return d
\ No newline at end of file diff --git a/progs/a627.py b/progs/a627.py new file mode 100644 index 0000000..a96e17c --- /dev/null +++ b/progs/a627.py @@ -0,0 +1,8 @@ +def dog_age(h_age):
 + if h_age < 0:
 + 	exit()
 + elif h_age <= 2:
 +	 d_age = h_age * 10.5
 + else:
 +	 d_age = 21 + (h_age - 2)*4
 + return d_age
\ No newline at end of file diff --git a/progs/a628.py b/progs/a628.py new file mode 100644 index 0000000..69f1961 --- /dev/null +++ b/progs/a628.py @@ -0,0 +1,2 @@ +def list_split(S, step):
 +    return [S[i::step] for i in range(step)]
\ No newline at end of file diff --git a/progs/a629.py b/progs/a629.py new file mode 100644 index 0000000..8c2982f --- /dev/null +++ b/progs/a629.py @@ -0,0 +1,3 @@ +def lateralsurface_cube(l):
 +  LSA = 4 * (l * l)
 +  return LSA
\ No newline at end of file diff --git a/progs/a63.py b/progs/a63.py new file mode 100644 index 0000000..5f9586b --- /dev/null +++ b/progs/a63.py @@ -0,0 +1,11 @@ +def average_Even(n) : 
 +    if (n% 2!= 0) : 
 +        return ("Invalid Input") 
 +        return -1  
 +    sm = 0
 +    count = 0
 +    while (n>= 2) : 
 +        count = count+1
 +        sm = sm+n 
 +        n = n-2
 +    return sm // count 
\ No newline at end of file diff --git a/progs/a630.py b/progs/a630.py new file mode 100644 index 0000000..9de4ca6 --- /dev/null +++ b/progs/a630.py @@ -0,0 +1,2 @@ +def square_Sum(n):  
 +    return int(n*(4*n*n-1)/3) 
\ No newline at end of file diff --git a/progs/a631.py b/progs/a631.py new file mode 100644 index 0000000..0790cd1 --- /dev/null +++ b/progs/a631.py @@ -0,0 +1,2 @@ +def find_star_num(n): 
 +	return (6 * n * (n - 1) + 1) 
\ No newline at end of file diff --git a/progs/a632.py b/progs/a632.py new file mode 100644 index 0000000..a0e5c26 --- /dev/null +++ b/progs/a632.py @@ -0,0 +1,3 @@ +def ascii_value(k):
 +  ch=k
 +  return ord(ch)
\ No newline at end of file diff --git a/progs/a633.py b/progs/a633.py new file mode 100644 index 0000000..beb07c0 --- /dev/null +++ b/progs/a633.py @@ -0,0 +1,7 @@ +def sum_even_and_even_index(arr,n):  
 +    i = 0
 +    sum = 0
 +    for i in range(0,n,2): 
 +        if (arr[i] % 2 == 0) : 
 +            sum += arr[i]  
 +    return sum
\ No newline at end of file diff --git a/progs/a634.py b/progs/a634.py new file mode 100644 index 0000000..d3bcf99 --- /dev/null +++ b/progs/a634.py @@ -0,0 +1,6 @@ +def even_Power_Sum(n): 
 +    sum = 0; 
 +    for i in range(1,n+1): 
 +        j = 2*i; 
 +        sum = sum + (j*j*j*j*j); 
 +    return sum; 
\ No newline at end of file diff --git a/progs/a635.py b/progs/a635.py new file mode 100644 index 0000000..cd09d1e --- /dev/null +++ b/progs/a635.py @@ -0,0 +1,3 @@ +def rear_extract(test_list):
 +  res = [lis[-1] for lis in test_list]
 +  return (res) 
\ No newline at end of file diff --git a/progs/a637.py b/progs/a637.py new file mode 100644 index 0000000..93f1fa8 --- /dev/null +++ b/progs/a637.py @@ -0,0 +1,3 @@ +import math  
 +def even_binomial_Coeff_Sum( n): 
 +    return (1 << (n - 1)) 
\ No newline at end of file diff --git a/progs/a638.py b/progs/a638.py new file mode 100644 index 0000000..8d21121 --- /dev/null +++ b/progs/a638.py @@ -0,0 +1,10 @@ +import math as mt 
 +def get_Position(a,n,m): 
 +    for i in range(n): 
 +        a[i] = (a[i] // m + (a[i] % m != 0))  
 +    result,maxx = -1,-1
 +    for i in range(n - 1,-1,-1): 
 +        if (maxx < a[i]): 
 +            maxx = a[i] 
 +            result = i 
 +    return result + 1
\ No newline at end of file diff --git a/progs/a639.py b/progs/a639.py new file mode 100644 index 0000000..b3acab6 --- /dev/null +++ b/progs/a639.py @@ -0,0 +1,3 @@ +def volume_cylinder(r,h):
 +  volume=3.1415*r*r*h
 +  return volume
\ No newline at end of file diff --git a/progs/a64.py b/progs/a64.py new file mode 100644 index 0000000..73b23fd --- /dev/null +++ b/progs/a64.py @@ -0,0 +1,5 @@ +def move_last(num_list):
 +    a = [num_list[0] for i in range(num_list.count(num_list[0]))]
 +    x = [ i for i in num_list if i != num_list[0]]
 +    x.extend(a)
 +    return (x)
\ No newline at end of file diff --git a/progs/a641.py b/progs/a641.py new file mode 100644 index 0000000..51393cd --- /dev/null +++ b/progs/a641.py @@ -0,0 +1,5 @@ +def count_first_elements(test_tup):
 +  for count, ele in enumerate(test_tup):
 +    if isinstance(ele, tuple):
 +      break
 +  return (count) 
\ No newline at end of file diff --git a/progs/a642.py b/progs/a642.py new file mode 100644 index 0000000..eebcf33 --- /dev/null +++ b/progs/a642.py @@ -0,0 +1,2 @@ +def is_num_decagonal(n): 
 +	return 4 * n * n - 3 * n 
\ No newline at end of file diff --git a/progs/a643.py b/progs/a643.py new file mode 100644 index 0000000..f1d5b59 --- /dev/null +++ b/progs/a643.py @@ -0,0 +1,9 @@ +def sequential_search(dlist, item):
 +    pos = 0
 +    found = False
 +    while pos < len(dlist) and not found:
 +        if dlist[pos] == item:
 +            found = True
 +        else:
 +            pos = pos + 1
 +    return found, pos
\ No newline at end of file diff --git a/progs/a644.py b/progs/a644.py new file mode 100644 index 0000000..e7386b8 --- /dev/null +++ b/progs/a644.py @@ -0,0 +1,4 @@ +def all_unique(test_list):
 +    if len(test_list) > len(set(test_list)):
 +        return False
 +    return True
\ No newline at end of file diff --git a/progs/a646.py b/progs/a646.py new file mode 100644 index 0000000..450cbd7 --- /dev/null +++ b/progs/a646.py @@ -0,0 +1,11 @@ +def validate(n): 
 +    for i in range(10): 
 +        temp = n;  
 +        count = 0; 
 +        while (temp): 
 +            if (temp % 10 == i): 
 +                count+=1;  
 +            if (count > i): 
 +                return False
 +            temp //= 10; 
 +    return True
\ No newline at end of file diff --git a/progs/a647.py b/progs/a647.py new file mode 100644 index 0000000..fe4d34b --- /dev/null +++ b/progs/a647.py @@ -0,0 +1,3 @@ +def check_element(list,element):
 +  check_element=all(v== element for v in list)
 +  return check_element
\ No newline at end of file diff --git a/progs/a648.py b/progs/a648.py new file mode 100644 index 0000000..d71fe11 --- /dev/null +++ b/progs/a648.py @@ -0,0 +1,7 @@ +import re
 +def text_match_two_three(text):
 +        patterns = 'ab{2,3}'
 +        if re.search(patterns,  text):
 +                return 'Found a match!'
 +        else:
 +                return('Not matched!')
\ No newline at end of file diff --git a/progs/a649.py b/progs/a649.py new file mode 100644 index 0000000..f1b903b --- /dev/null +++ b/progs/a649.py @@ -0,0 +1,10 @@ +def max_sub_array_sum_repeated(a, n, k): 
 +	max_so_far = -2147483648
 +	max_ending_here = 0
 +	for i in range(n*k): 
 +		max_ending_here = max_ending_here + a[i%n] 
 +		if (max_so_far < max_ending_here): 
 +			max_so_far = max_ending_here 
 +		if (max_ending_here < 0): 
 +			max_ending_here = 0
 +	return max_so_far
\ No newline at end of file diff --git a/progs/a65.py b/progs/a65.py new file mode 100644 index 0000000..8b3e0fb --- /dev/null +++ b/progs/a65.py @@ -0,0 +1,6 @@ +def count_char(string,char):
 + count = 0
 + for i in range(len(string)):
 +    if(string[i] == char):
 +        count = count + 1
 + return count
\ No newline at end of file diff --git a/progs/a650.py b/progs/a650.py new file mode 100644 index 0000000..4516aad --- /dev/null +++ b/progs/a650.py @@ -0,0 +1,2 @@ +def square_Sum(n):  
 +    return int(2*n*(n+1)*(2*n+1)/3)
\ No newline at end of file diff --git a/progs/a651.py b/progs/a651.py new file mode 100644 index 0000000..e2c1852 --- /dev/null +++ b/progs/a651.py @@ -0,0 +1,6 @@ +def modular_inverse(arr, N, P):
 +	current_element = 0
 +	for i in range(0, N):
 +		if ((arr[i] * arr[i]) % P == 1):
 +			current_element = current_element + 1
 +	return current_element
\ No newline at end of file diff --git a/progs/a652.py b/progs/a652.py new file mode 100644 index 0000000..52a274b --- /dev/null +++ b/progs/a652.py @@ -0,0 +1,14 @@ +def odd_Days(N): 
 +    hund1 = N // 100
 +    hund4 = N // 400
 +    leap = N >> 2
 +    ordd = N - leap 
 +    if (hund1): 
 +        ordd += hund1 
 +        leap -= hund1 
 +    if (hund4): 
 +        ordd -= hund4 
 +        leap += hund4 
 +    days = ordd + leap * 2
 +    odd = days % 7
 +    return odd 
\ No newline at end of file diff --git a/progs/a653.py b/progs/a653.py new file mode 100644 index 0000000..c553010 --- /dev/null +++ b/progs/a653.py @@ -0,0 +1,4 @@ +def max_length(list1):
 +    max_length = max(len(x) for x in  list1 )  
 +    max_list = max((x) for x in   list1)
 +    return(max_length, max_list)
\ No newline at end of file diff --git a/progs/a654.py b/progs/a654.py new file mode 100644 index 0000000..8b15e73 --- /dev/null +++ b/progs/a654.py @@ -0,0 +1,9 @@ +def count_no_of_ways(n, k): 
 +	dp = [0] * (n + 1) 
 +	total = k 
 +	mod = 1000000007
 +	dp[1] = k 
 +	dp[2] = k * k	 
 +	for i in range(3,n+1): 
 +		dp[i] = ((k - 1) * (dp[i - 1] + dp[i - 2])) % mod 
 +	return dp[n]
\ No newline at end of file diff --git a/progs/a655.py b/progs/a655.py new file mode 100644 index 0000000..e723d9c --- /dev/null +++ b/progs/a655.py @@ -0,0 +1,3 @@ +def find(n,m):  
 +    q = n//m 
 +    return (q)
\ No newline at end of file diff --git a/progs/a656.py b/progs/a656.py new file mode 100644 index 0000000..acb01e2 --- /dev/null +++ b/progs/a656.py @@ -0,0 +1,4 @@ +import math
 +def otherside_rightangle(w,h):
 +  s=math.sqrt((w*w)+(h*h))
 +  return s
\ No newline at end of file diff --git a/progs/a657.py b/progs/a657.py new file mode 100644 index 0000000..db7ed67 --- /dev/null +++ b/progs/a657.py @@ -0,0 +1,3 @@ +def max_val(listval):
 +     max_val = max(i for i in listval if isinstance(i, int)) 
 +     return(max_val)
\ No newline at end of file diff --git a/progs/a658.py b/progs/a658.py new file mode 100644 index 0000000..790155b --- /dev/null +++ b/progs/a658.py @@ -0,0 +1,6 @@ +def sum_div(number):
 +    divisors = [1]
 +    for i in range(2, number):
 +        if (number % i)==0:
 +            divisors.append(i)
 +    return sum(divisors)
\ No newline at end of file diff --git a/progs/a659.py b/progs/a659.py new file mode 100644 index 0000000..b38ab53 --- /dev/null +++ b/progs/a659.py @@ -0,0 +1,7 @@ +def get_Inv_Count(arr,n): 
 +    inv_count = 0
 +    for i in range(n): 
 +        for j in range(i + 1,n): 
 +            if (arr[i] > arr[j]): 
 +                inv_count += 1
 +    return inv_count 
\ No newline at end of file diff --git a/progs/a66.py b/progs/a66.py new file mode 100644 index 0000000..3a452a2 --- /dev/null +++ b/progs/a66.py @@ -0,0 +1,3 @@ +def Check_Vow(string, vowels): 
 +    final = [each for each in string if each in vowels] 
 +    return(len(final)) 
 diff --git a/progs/a660.py b/progs/a660.py new file mode 100644 index 0000000..341c0fc --- /dev/null +++ b/progs/a660.py @@ -0,0 +1,13 @@ +def flatten_list(list1):
 +    result_list = []
 +    if not list1: return result_list
 +    stack = [list(list1)]
 +    while stack:
 +        c_num = stack.pop()
 +        next = c_num.pop()
 +        if c_num: stack.append(c_num)
 +        if isinstance(next, list):
 +            if next: stack.append(list(next))
 +        else: result_list.append(next)
 +    result_list.reverse()
 +    return result_list 
\ No newline at end of file diff --git a/progs/a661.py b/progs/a661.py new file mode 100644 index 0000000..124d3f8 --- /dev/null +++ b/progs/a661.py @@ -0,0 +1,3 @@ +def intersection_nested_lists(l1, l2):
 +    result = [[n for n in lst if n in l1] for lst in l2]
 +    return result
\ No newline at end of file diff --git a/progs/a663.py b/progs/a663.py new file mode 100644 index 0000000..7130b51 --- /dev/null +++ b/progs/a663.py @@ -0,0 +1,7 @@ +def count_binary_seq(n): 
 +	nCr = 1
 +	res = 1
 +	for r in range(1, n + 1): 
 +		nCr = (nCr * (n + 1 - r)) / r 
 +		res += nCr * nCr 
 +	return res 
\ No newline at end of file diff --git a/progs/a664.py b/progs/a664.py new file mode 100644 index 0000000..60aa164 --- /dev/null +++ b/progs/a664.py @@ -0,0 +1,4 @@ +def dict_depth(d):
 +    if isinstance(d, dict):
 +        return 1 + (max(map(dict_depth, d.values())) if d else 0)
 +    return 0
\ No newline at end of file diff --git a/progs/a665.py b/progs/a665.py new file mode 100644 index 0000000..0a0047e --- /dev/null +++ b/progs/a665.py @@ -0,0 +1,9 @@ +def set_Bit_Number(n): 
 +    if (n == 0): 
 +        return 0; 
 +    msb = 0; 
 +    n = int(n / 2); 
 +    while (n > 0): 
 +        n = int(n / 2); 
 +        msb += 1; 
 +    return (1 << msb)
\ No newline at end of file diff --git a/progs/a666.py b/progs/a666.py new file mode 100644 index 0000000..be8c1d9 --- /dev/null +++ b/progs/a666.py @@ -0,0 +1,8 @@ +import sys 
 +def solve(a,n):   
 +    mx = -sys.maxsize - 1
 +    for j in range(1,n):  
 +        if (mx > a[j]):  
 +            return False  
 +        mx = max(mx,a[j - 1])    
 +    return True
\ No newline at end of file diff --git a/progs/a667.py b/progs/a667.py new file mode 100644 index 0000000..9360352 --- /dev/null +++ b/progs/a667.py @@ -0,0 +1,10 @@ +def find_Element(arr,ranges,rotations,index) :  
 +    for i in range(rotations - 1,-1,-1 ) : 
 +        left = ranges[i][0] 
 +        right = ranges[i][1] 
 +        if (left <= index and right >= index) : 
 +            if (index == left) : 
 +                index = right 
 +            else : 
 +                index = index - 1 
 +    return arr[index] 
\ No newline at end of file diff --git a/progs/a668.py b/progs/a668.py new file mode 100644 index 0000000..49dd545 --- /dev/null +++ b/progs/a668.py @@ -0,0 +1,6 @@ +import re
 +def start_withp(words):
 + for w in words:
 +        m = re.match("(P\w+)\W(P\w+)", w)
 +        if m:
 +            return m.groups()
\ No newline at end of file diff --git a/progs/a669.py b/progs/a669.py new file mode 100644 index 0000000..8c0d2da --- /dev/null +++ b/progs/a669.py @@ -0,0 +1,18 @@ +def max_sum_increasing_subseq(a, n, index, k):
 +	dp = [[0 for i in range(n)] 
 +			for i in range(n)]
 +	for i in range(n):
 +		if a[i] > a[0]:
 +			dp[0][i] = a[i] + a[0]
 +		else:
 +			dp[0][i] = a[i]
 +	for i in range(1, n):
 +		for j in range(n):
 +			if a[j] > a[i] and j > i:
 +				if dp[i - 1][i] + a[j] > dp[i - 1][j]:
 +					dp[i][j] = dp[i - 1][i] + a[j]
 +				else:
 +					dp[i][j] = dp[i - 1][j]
 +			else:
 +				dp[i][j] = dp[i - 1][j]
 +	return dp[index][k]
\ No newline at end of file diff --git a/progs/a67.py b/progs/a67.py new file mode 100644 index 0000000..842e41b --- /dev/null +++ b/progs/a67.py @@ -0,0 +1,5 @@ +import re 
 +def replace(string, char): 
 +    pattern = char + '{2,}'
 +    string = re.sub(pattern, char, string) 
 +    return string 
\ No newline at end of file diff --git a/progs/a670.py b/progs/a670.py new file mode 100644 index 0000000..4fba8b0 --- /dev/null +++ b/progs/a670.py @@ -0,0 +1,5 @@ +from copy import deepcopy
 +def colon_tuplex(tuplex,m,n):
 +  tuplex_colon = deepcopy(tuplex)
 +  tuplex_colon[m].append(n)
 +  return tuplex_colon
\ No newline at end of file diff --git a/progs/a671.py b/progs/a671.py new file mode 100644 index 0000000..1aee272 --- /dev/null +++ b/progs/a671.py @@ -0,0 +1,3 @@ +def large_product(nums1, nums2, N):
 +    result = sorted([x*y for x in nums1 for y in nums2], reverse=True)[:N]
 +    return result
\ No newline at end of file diff --git a/progs/a672.py b/progs/a672.py new file mode 100644 index 0000000..3fbd4ef --- /dev/null +++ b/progs/a672.py @@ -0,0 +1,5 @@ +def maximum(a,b):   
 +    if a >= b: 
 +        return a 
 +    else: 
 +        return b 
\ No newline at end of file diff --git a/progs/a673.py b/progs/a673.py new file mode 100644 index 0000000..5b99fc8 --- /dev/null +++ b/progs/a673.py @@ -0,0 +1,3 @@ +def string_to_tuple(str1):
 +    result = tuple(x for x in str1 if not x.isspace()) 
 +    return result
\ No newline at end of file diff --git a/progs/a674.py b/progs/a674.py new file mode 100644 index 0000000..cf8e36a --- /dev/null +++ b/progs/a674.py @@ -0,0 +1,9 @@ +def set_left_most_unset_bit(n): 
 +    if not (n & (n + 1)): 
 +        return n 
 +    pos, temp, count = 0, n, 0 
 +    while temp: 
 +        if not (temp & 1): 
 +            pos = count      
 +        count += 1; temp>>=1
 +    return (n | (1 << (pos))) 
\ No newline at end of file diff --git a/progs/a675.py b/progs/a675.py new file mode 100644 index 0000000..1de8c7a --- /dev/null +++ b/progs/a675.py @@ -0,0 +1,4 @@ +import math
 +def volume_cone(r,h):
 +  volume = (1.0/3) * math.pi * r * r * h
 +  return volume
\ No newline at end of file diff --git a/progs/a676.py b/progs/a676.py new file mode 100644 index 0000000..9cd0bb5 --- /dev/null +++ b/progs/a676.py @@ -0,0 +1,4 @@ +def pos_nos(list1):
 +  for num in list1: 
 +    if num >= 0: 
 +       return num 
\ No newline at end of file diff --git a/progs/a677.py b/progs/a677.py new file mode 100644 index 0000000..73a09b9 --- /dev/null +++ b/progs/a677.py @@ -0,0 +1,8 @@ +def max_sum_rectangular_grid(grid, n) : 
 +	incl = max(grid[0][0], grid[1][0]) 
 +	excl = 0
 +	for i in range(1, n) : 
 +		excl_new = max(excl, incl) 
 +		incl = excl + max(grid[0][i], grid[1][i]) 
 +		excl = excl_new 
 +	return max(excl, incl)
\ No newline at end of file diff --git a/progs/a678.py b/progs/a678.py new file mode 100644 index 0000000..2b3d4a0 --- /dev/null +++ b/progs/a678.py @@ -0,0 +1,23 @@ +def find_Max_Len_Even(str): 
 +    n = len(str) 
 +    i = 0
 +    currlen = 0
 +    maxlen = 0
 +    st = -1
 +    while (i < n): 
 +        if (str[i] == ' '): 
 +            if (currlen % 2 == 0): 
 +                if (maxlen < currlen): 
 +                    maxlen = currlen 
 +                    st = i - currlen 
 +            currlen = 0 
 +        else : 
 +            currlen += 1
 +        i += 1
 +    if (currlen % 2 == 0): 
 +        if (maxlen < currlen): 
 +            maxlen = currlen 
 +            st = i - currlen 
 +    if (st == -1): 
 +        return "-1" 
 +    return str[st: st + maxlen] 
\ No newline at end of file diff --git a/progs/a679.py b/progs/a679.py new file mode 100644 index 0000000..97472a6 --- /dev/null +++ b/progs/a679.py @@ -0,0 +1,13 @@ +def find_last_occurrence(A, x):
 +    (left, right) = (0, len(A) - 1)
 +    result = -1
 +    while left <= right:
 +        mid = (left + right) // 2
 +        if x == A[mid]:
 +            result = mid
 +            left = mid + 1
 +        elif x < A[mid]:
 +            right = mid - 1
 +        else:
 +            left = mid + 1
 +    return result 
\ No newline at end of file diff --git a/progs/a680.py b/progs/a680.py new file mode 100644 index 0000000..03f4da8 --- /dev/null +++ b/progs/a680.py @@ -0,0 +1,6 @@ +from itertools import groupby
 +def modified_encode(alist):
 +        def ctr_ele(el):
 +            if len(el)>1: return [len(el), el[0]]
 +            else: return el[0]
 +        return [ctr_ele(list(group)) for key, group in groupby(alist)]
\ No newline at end of file diff --git a/progs/a681.py b/progs/a681.py new file mode 100644 index 0000000..2282fac --- /dev/null +++ b/progs/a681.py @@ -0,0 +1,9 @@ +def max_volume (s): 
 +    maxvalue = 0
 +    i = 1
 +    for i in range(s - 1): 
 +        j = 1
 +        for j in range(s): 
 +            k = s - i - j 
 +            maxvalue = max(maxvalue, i * j * k)         
 +    return maxvalue 
\ No newline at end of file diff --git a/progs/a683.py b/progs/a683.py new file mode 100644 index 0000000..90cb153 --- /dev/null +++ b/progs/a683.py @@ -0,0 +1,8 @@ +def sum_difference(n):
 +    sumofsquares = 0
 +    squareofsum = 0
 +    for num in range(1, n+1):
 +        sumofsquares += num * num
 +        squareofsum += num
 +    squareofsum = squareofsum ** 2
 +    return squareofsum - sumofsquares
\ No newline at end of file diff --git a/progs/a684.py b/progs/a684.py new file mode 100644 index 0000000..03db71e --- /dev/null +++ b/progs/a684.py @@ -0,0 +1,8 @@ +def find_demlo(s): 
 +	l = len(s) 
 +	res = "" 
 +	for i in range(1,l+1): 
 +		res = res + str(i) 
 +	for i in range(l-1,0,-1): 
 +		res = res + str(i) 
 +	return res 	
\ No newline at end of file diff --git a/progs/a685.py b/progs/a685.py new file mode 100644 index 0000000..b0ffc4f --- /dev/null +++ b/progs/a685.py @@ -0,0 +1,4 @@ +def position_min(list1):
 +    min_val = min(list1)
 +    min_result = [i for i, j in enumerate(list1) if j == min_val]
 +    return min_result
\ No newline at end of file diff --git a/progs/a686.py b/progs/a686.py new file mode 100644 index 0000000..960f706 --- /dev/null +++ b/progs/a686.py @@ -0,0 +1,22 @@ +def right_rotate(arr, n, out_of_place, cur):
 +	temp = arr[cur]
 +	for i in range(cur, out_of_place, -1):
 +		arr[i] = arr[i - 1]
 +	arr[out_of_place] = temp
 +	return arr
 +def re_arrange(arr, n):
 +	out_of_place = -1
 +	for index in range(n):
 +		if (out_of_place >= 0):
 +			if ((arr[index] >= 0 and arr[out_of_place] < 0) or
 +			(arr[index] < 0 and arr[out_of_place] >= 0)):
 +				arr = right_rotate(arr, n, out_of_place, index)
 +				if (index-out_of_place > 2):
 +					out_of_place += 2
 +				else:
 +					out_of_place = - 1
 +		if (out_of_place == -1):
 +			if ((arr[index] >= 0 and index % 2 == 0) or
 +			 (arr[index] < 0 and index % 2 == 1)):
 +				out_of_place = index
 +	return arr
\ No newline at end of file diff --git a/progs/a687.py b/progs/a687.py new file mode 100644 index 0000000..b189d16 --- /dev/null +++ b/progs/a687.py @@ -0,0 +1,9 @@ +def sum_of_alternates(test_tuple):
 +  sum1 = 0
 +  sum2 = 0
 +  for idx, ele in enumerate(test_tuple):
 +    if idx % 2:
 +      sum1 += ele
 +    else:
 +      sum2 += ele
 +  return ((sum1),(sum2)) 
\ No newline at end of file diff --git a/progs/a688.py b/progs/a688.py new file mode 100644 index 0000000..ddfc18e --- /dev/null +++ b/progs/a688.py @@ -0,0 +1,11 @@ +def get_Min_Squares(n):
 +    if n <= 3:
 +        return n;
 +    res = n 
 +    for x in range(1,n + 1):
 +        temp = x * x;
 +        if temp > n:
 +            break
 +        else:
 +            res = min(res,1 + get_Min_Squares(n  - temp)) 
 +    return res;
\ No newline at end of file diff --git a/progs/a689.py b/progs/a689.py new file mode 100644 index 0000000..5dd684d --- /dev/null +++ b/progs/a689.py @@ -0,0 +1,9 @@ +from collections import defaultdict 
 +
 +def most_occurrences(test_list):
 +  temp = defaultdict(int)
 +  for sub in test_list:
 +    for wrd in sub.split():
 +      temp[wrd] += 1
 +  res = max(temp, key=temp.get)
 +  return (str(res)) 
\ No newline at end of file diff --git a/progs/a69.py b/progs/a69.py new file mode 100644 index 0000000..0d2a517 --- /dev/null +++ b/progs/a69.py @@ -0,0 +1,5 @@ +def decreasing_trend(nums):
 +    if (sorted(nums)== nums):
 +        return True
 +    else:
 +        return False
\ No newline at end of file diff --git a/progs/a690.py b/progs/a690.py new file mode 100644 index 0000000..118be49 --- /dev/null +++ b/progs/a690.py @@ -0,0 +1,5 @@ +def check_isosceles(x,y,z):
 +  if x==y or y==z or z==x:
 +	   return True
 +  else:
 +     return False
\ No newline at end of file diff --git a/progs/a691.py b/progs/a691.py new file mode 100644 index 0000000..03d58df --- /dev/null +++ b/progs/a691.py @@ -0,0 +1,3 @@ +def rotate_left(list1,m,n):
 +  result =  list1[m:]+list1[:n]
 +  return result
\ No newline at end of file diff --git a/progs/a692.py b/progs/a692.py new file mode 100644 index 0000000..201442d --- /dev/null +++ b/progs/a692.py @@ -0,0 +1,6 @@ +def neg_count(list):
 +  neg_count= 0
 +  for num in list: 
 +    if num <= 0: 
 +      neg_count += 1
 +  return neg_count 
\ No newline at end of file diff --git a/progs/a694.py b/progs/a694.py new file mode 100644 index 0000000..5a670ce --- /dev/null +++ b/progs/a694.py @@ -0,0 +1,8 @@ +def count_unset_bits(n): 
 +    count = 0
 +    x = 1
 +    while(x < n + 1): 
 +        if ((x & n) == 0): 
 +            count += 1
 +        x = x << 1
 +    return count  
\ No newline at end of file diff --git a/progs/a695.py b/progs/a695.py new file mode 100644 index 0000000..826651d --- /dev/null +++ b/progs/a695.py @@ -0,0 +1,9 @@ +def char_frequency(str1):
 +    dict = {}
 +    for n in str1:
 +        keys = dict.keys()
 +        if n in keys:
 +            dict[n] += 1
 +        else:
 +            dict[n] = 1
 +    return dict
\ No newline at end of file diff --git a/progs/a697.py b/progs/a697.py new file mode 100644 index 0000000..d139561 --- /dev/null +++ b/progs/a697.py @@ -0,0 +1,5 @@ +def check_Validity(a,b,c):  
 +    if (a + b <= c) or (a + c <= b) or (b + c <= a) : 
 +        return False
 +    else: 
 +        return True        
\ No newline at end of file diff --git a/progs/a698.py b/progs/a698.py new file mode 100644 index 0000000..47b03c5 --- /dev/null +++ b/progs/a698.py @@ -0,0 +1,3 @@ +def ap_sum(a,n,d):
 +  total = (n * (2 * a + (n - 1) * d)) / 2
 +  return total
\ No newline at end of file diff --git a/progs/a699.py b/progs/a699.py new file mode 100644 index 0000000..252f8ed --- /dev/null +++ b/progs/a699.py @@ -0,0 +1,5 @@ +def check_monthnum(monthname1):
 +  if monthname1 == "February":
 +    return True
 +  else:
 +    return False
\ No newline at end of file diff --git a/progs/a7.py b/progs/a7.py new file mode 100644 index 0000000..4d08386 --- /dev/null +++ b/progs/a7.py @@ -0,0 +1,8 @@ +def bell_Number(n): 
 +    bell = [[0 for i in range(n+1)] for j in range(n+1)] 
 +    bell[0][0] = 1
 +    for i in range(1, n+1):
 +        bell[i][0] = bell[i-1][i-1]
 +        for j in range(1, i+1): 
 +            bell[i][j] = bell[i-1][j-1] + bell[i][j-1] 
 +    return bell[n][0] 
\ No newline at end of file diff --git a/progs/a70.py b/progs/a70.py new file mode 100644 index 0000000..6e61717 --- /dev/null +++ b/progs/a70.py @@ -0,0 +1,10 @@ +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) 
\ No newline at end of file diff --git a/progs/a700.py b/progs/a700.py new file mode 100644 index 0000000..474cfb5 --- /dev/null +++ b/progs/a700.py @@ -0,0 +1,7 @@ +import re
 +def text_match_word(text):
 +        patterns = '\w+\S*$'
 +        if re.search(patterns,  text):
 +                return 'Found a match!'
 +        else:
 +                return 'Not matched!'
\ No newline at end of file diff --git a/progs/a701.py b/progs/a701.py new file mode 100644 index 0000000..7b8c0fe --- /dev/null +++ b/progs/a701.py @@ -0,0 +1,10 @@ +def check_Equality(s): 
 +    return (ord(s[0]) == ord(s[len(s) - 1])); 
 +def count_Substring_With_Equal_Ends(s): 
 +    result = 0; 
 +    n = len(s); 
 +    for i in range(n):
 +        for j in range(1,n-i+1): 
 +            if (check_Equality(s[i:i+j])): 
 +                result+=1; 
 +    return result; 
\ No newline at end of file diff --git a/progs/a702.py b/progs/a702.py new file mode 100644 index 0000000..05bfd42 --- /dev/null +++ b/progs/a702.py @@ -0,0 +1,4 @@ +def find_Divisor(x,y):  
 +    if (x==y): 
 +        return y 
 +    return 2
\ No newline at end of file diff --git a/progs/a703.py b/progs/a703.py new file mode 100644 index 0000000..d0b9171 --- /dev/null +++ b/progs/a703.py @@ -0,0 +1,2 @@ +def sum_three_smallest_nums(lst):
 +	return sum(sorted([x for x in lst if x > 0])[:3])
\ No newline at end of file diff --git a/progs/a704.py b/progs/a704.py new file mode 100644 index 0000000..e4b492f --- /dev/null +++ b/progs/a704.py @@ -0,0 +1,3 @@ +def set_to_tuple(s):
 +  t = tuple(sorted(s))
 +  return (t)
\ No newline at end of file diff --git a/progs/a707.py b/progs/a707.py new file mode 100644 index 0000000..e78244d --- /dev/null +++ b/progs/a707.py @@ -0,0 +1,2 @@ +def count_Odd_Squares(n,m): 
 +    return int(m**0.5) - int((n-1)**0.5) 
\ No newline at end of file diff --git a/progs/a708.py b/progs/a708.py new file mode 100644 index 0000000..84dda65 --- /dev/null +++ b/progs/a708.py @@ -0,0 +1,3 @@ +def diff_consecutivenums(nums):
 +    result = [b-a for a, b in zip(nums[:-1], nums[1:])]
 +    return result
\ No newline at end of file diff --git a/progs/a709.py b/progs/a709.py new file mode 100644 index 0000000..7a8d089 --- /dev/null +++ b/progs/a709.py @@ -0,0 +1,6 @@ +def zigzag(n, k): 
 +	if (n == 0 and k == 0): 
 +		return 1
 +	if (k == 0): 
 +		return 0
 +	return zigzag(n, k - 1) + zigzag(n - 1, n - k)
\ No newline at end of file diff --git a/progs/a71.py b/progs/a71.py new file mode 100644 index 0000000..d77ef0b --- /dev/null +++ b/progs/a71.py @@ -0,0 +1,8 @@ +def max_of_three(num1,num2,num3): 
 +    if (num1 >= num2) and (num1 >= num3):
 +       lnum = num1
 +    elif (num2 >= num1) and (num2 >= num3):
 +       lnum = num2
 +    else:
 +       lnum = num3
 +    return lnum
\ No newline at end of file diff --git a/progs/a710.py b/progs/a710.py new file mode 100644 index 0000000..53ba065 --- /dev/null +++ b/progs/a710.py @@ -0,0 +1,6 @@ +def count_Squares(m,n): 
 +    if (n < m): 
 +        temp = m 
 +        m = n 
 +        n = temp 
 +    return n * (n + 1) * (3 * m - n + 1) // 6
\ No newline at end of file diff --git a/progs/a711.py b/progs/a711.py new file mode 100644 index 0000000..860a306 --- /dev/null +++ b/progs/a711.py @@ -0,0 +1,13 @@ +def bin_coff(n, r): 
 +	val = 1
 +	if (r > (n - r)): 
 +		r = (n - r) 
 +	for i in range(0, r): 
 +		val *= (n - i) 
 +		val //= (i + 1) 
 +	return val 
 +def find_ways(M): 
 +	n = M // 2
 +	a = bin_coff(2 * n, n) 
 +	b = a // (n + 1) 
 +	return (b) 
\ No newline at end of file diff --git a/progs/a712.py b/progs/a712.py new file mode 100644 index 0000000..72c3bfc --- /dev/null +++ b/progs/a712.py @@ -0,0 +1,7 @@ +def check(string) :
 +    p = set(string) 
 +    s = {'0', '1'} 
 +    if s == p or p == {'0'} or p == {'1'}: 
 +        return ("Yes") 
 +    else : 
 +        return ("No") 
\ No newline at end of file diff --git a/progs/a713.py b/progs/a713.py new file mode 100644 index 0000000..772766f --- /dev/null +++ b/progs/a713.py @@ -0,0 +1,10 @@ +def minimum_Length(s) : 
 +    maxOcc = 0
 +    n = len(s) 
 +    arr = [0]*26
 +    for i in range(n) : 
 +        arr[ord(s[i]) -ord('a')] += 1
 +    for i in range(26) : 
 +        if arr[i] > maxOcc : 
 +            maxOcc = arr[i] 
 +    return n - maxOcc 
\ No newline at end of file diff --git a/progs/a714.py b/progs/a714.py new file mode 100644 index 0000000..a4ab447 --- /dev/null +++ b/progs/a714.py @@ -0,0 +1,13 @@ +def first_Element(arr,n,k): 
 +    count_map = {}; 
 +    for i in range(0, n): 
 +        if(arr[i] in count_map.keys()): 
 +            count_map[arr[i]] += 1
 +        else: 
 +            count_map[arr[i]] = 1
 +        i += 1
 +    for i in range(0, n):  
 +        if (count_map[arr[i]] == k): 
 +            return arr[i] 
 +        i += 1 
 +    return -1
\ No newline at end of file diff --git a/progs/a715.py b/progs/a715.py new file mode 100644 index 0000000..13c696b --- /dev/null +++ b/progs/a715.py @@ -0,0 +1,6 @@ +def unique_Characters(str):
 +    for i in range(len(str)):
 +        for j in range(i + 1,len(str)): 
 +            if (str[i] == str[j]):
 +                return False;
 +    return True;
\ No newline at end of file diff --git a/progs/a717.py b/progs/a717.py new file mode 100644 index 0000000..427cd29 --- /dev/null +++ b/progs/a717.py @@ -0,0 +1,3 @@ +def tn_ap(a,n,d):
 +  tn = a + (n - 1) * d
 +  return tn
\ No newline at end of file diff --git a/progs/a718.py b/progs/a718.py new file mode 100644 index 0000000..c0d535b --- /dev/null +++ b/progs/a718.py @@ -0,0 +1,10 @@ +def count_Rectangles(radius):  
 +    rectangles = 0 
 +    diameter = 2 * radius 
 +    diameterSquare = diameter * diameter 
 +    for a in range(1, 2 * radius):  
 +        for b in range(1, 2 * radius): 
 +            diagnalLengthSquare = (a * a +  b * b)  
 +            if (diagnalLengthSquare <= diameterSquare) : 
 +                rectangles += 1
 +    return rectangles 
\ No newline at end of file diff --git a/progs/a719.py b/progs/a719.py new file mode 100644 index 0000000..28a11fc --- /dev/null +++ b/progs/a719.py @@ -0,0 +1,3 @@ +def find_angle(a,b):
 + c = 180 - (a + b)
 + return c
 diff --git a/progs/a72.py b/progs/a72.py new file mode 100644 index 0000000..0fec899 --- /dev/null +++ b/progs/a72.py @@ -0,0 +1,4 @@ +def convert(list): 
 +    s = [str(i) for i in list] 
 +    res = int("".join(s))  
 +    return (res) 
\ No newline at end of file diff --git a/progs/a720.py b/progs/a720.py new file mode 100644 index 0000000..c5ce3e0 --- /dev/null +++ b/progs/a720.py @@ -0,0 +1,3 @@ +def find_max(test_list):
 +  res = max(int(j) for i in test_list for j in i)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a722.py b/progs/a722.py new file mode 100644 index 0000000..6fff9ea --- /dev/null +++ b/progs/a722.py @@ -0,0 +1,5 @@ +def Check_Solution(a,b,c): 
 +    if (2*b*b == 9*a*c): 
 +        return ("Yes"); 
 +    else: 
 +        return ("No"); 
\ No newline at end of file diff --git a/progs/a723.py b/progs/a723.py new file mode 100644 index 0000000..231ef5e --- /dev/null +++ b/progs/a723.py @@ -0,0 +1,3 @@ +def get_carol(n): 
 +	result = (2**n) - 1
 +	return result * result - 2
\ No newline at end of file diff --git a/progs/a724.py b/progs/a724.py new file mode 100644 index 0000000..6881793 --- /dev/null +++ b/progs/a724.py @@ -0,0 +1,3 @@ +def remove_empty(list1):
 +  remove_empty = [x for x in list1 if x]
 +  return remove_empty
\ No newline at end of file diff --git a/progs/a725.py b/progs/a725.py new file mode 100644 index 0000000..b542e99 --- /dev/null +++ b/progs/a725.py @@ -0,0 +1,9 @@ +def max_occurrences(nums):
 +    max_val = 0
 +    result = nums[0] 
 +    for i in nums:
 +        occu = nums.count(i)
 +        if occu > max_val:
 +            max_val = occu
 +            result = i 
 +    return result
\ No newline at end of file diff --git a/progs/a726.py b/progs/a726.py new file mode 100644 index 0000000..2a96bbf --- /dev/null +++ b/progs/a726.py @@ -0,0 +1,3 @@ +def add_K_element(test_list, K):
 +  res = [tuple(j + K for j in sub ) for sub in test_list]
 +  return (res) 
\ No newline at end of file diff --git a/progs/a727.py b/progs/a727.py new file mode 100644 index 0000000..404a989 --- /dev/null +++ b/progs/a727.py @@ -0,0 +1,11 @@ +def make_flip(ch): 
 +	return '1' if (ch == '0') else '0'
 +def get_flip_with_starting_charcter(str, expected): 
 +	flip_count = 0
 +	for i in range(len( str)): 
 +		if (str[i] != expected): 
 +			flip_count += 1
 +		expected = make_flip(expected) 
 +	return flip_count 
 +def min_flip_to_make_string_alternate(str): 
 +	return min(get_flip_with_starting_charcter(str, '0'),get_flip_with_starting_charcter(str, '1')) 
\ No newline at end of file diff --git a/progs/a728.py b/progs/a728.py new file mode 100644 index 0000000..1d1bf45 --- /dev/null +++ b/progs/a728.py @@ -0,0 +1,6 @@ +def count_Digit(n):
 +    count = 0
 +    while n != 0:
 +        n //= 10
 +        count += 1
 +    return count
\ No newline at end of file diff --git a/progs/a729.py b/progs/a729.py new file mode 100644 index 0000000..339c5d3 --- /dev/null +++ b/progs/a729.py @@ -0,0 +1,2 @@ +def adjacent_num_product(list_nums):
 +    return max(a*b for a, b in zip(list_nums, list_nums[1:]))
\ No newline at end of file diff --git a/progs/a73.py b/progs/a73.py new file mode 100644 index 0000000..3273244 --- /dev/null +++ b/progs/a73.py @@ -0,0 +1,4 @@ +from collections import OrderedDict
 +def remove_duplicate(string):
 +  result = ' '.join(OrderedDict((w,w) for w in string.split()).keys())
 +  return result
\ No newline at end of file diff --git a/progs/a731.py b/progs/a731.py new file mode 100644 index 0000000..14bf68d --- /dev/null +++ b/progs/a731.py @@ -0,0 +1,3 @@ +def repeat_tuples(test_tup, N):
 +  res = ((test_tup, ) * N)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a732.py b/progs/a732.py new file mode 100644 index 0000000..e3f1ec0 --- /dev/null +++ b/progs/a732.py @@ -0,0 +1,3 @@ +def lateralsurface_cuboid(l,w,h):
 +  LSA = 2*h*(l+w)
 +  return LSA
\ No newline at end of file diff --git a/progs/a734.py b/progs/a734.py new file mode 100644 index 0000000..87acf69 --- /dev/null +++ b/progs/a734.py @@ -0,0 +1,8 @@ +def smallest_missing(A, left_element, right_element):
 +    if left_element > right_element:
 +        return left_element
 +    mid = left_element + (right_element - left_element) // 2
 +    if A[mid] == mid:
 +        return smallest_missing(A, mid + 1, right_element)
 +    else:
 +        return smallest_missing(A, left_element, mid - 1)
\ No newline at end of file diff --git a/progs/a735.py b/progs/a735.py new file mode 100644 index 0000000..03a488e --- /dev/null +++ b/progs/a735.py @@ -0,0 +1,5 @@ +import heapq as hq
 +def heap_assending(nums):
 +  hq.heapify(nums)
 +  s_result = [hq.heappop(nums) for i in range(len(nums))]
 +  return s_result
\ No newline at end of file diff --git a/progs/a736.py b/progs/a736.py new file mode 100644 index 0000000..884935f --- /dev/null +++ b/progs/a736.py @@ -0,0 +1,3 @@ +def volume_cuboid(l,w,h):
 +  volume=l*w*h
 +  return volume
\ No newline at end of file diff --git a/progs/a737.py b/progs/a737.py new file mode 100644 index 0000000..80925dc --- /dev/null +++ b/progs/a737.py @@ -0,0 +1,11 @@ +def permute_string(str):
 +    if len(str) == 0:
 +        return ['']
 +    prev_list = permute_string(str[1:len(str)])
 +    next_list = []
 +    for i in range(0,len(prev_list)):
 +        for j in range(0,len(str)):
 +            new_str = prev_list[i][0:j]+str[0]+prev_list[i][j:len(str)-1]
 +            if new_str not in next_list:
 +                next_list.append(new_str)
 +    return next_list
\ No newline at end of file diff --git a/progs/a738.py b/progs/a738.py new file mode 100644 index 0000000..27191c1 --- /dev/null +++ b/progs/a738.py @@ -0,0 +1,4 @@ +def round_num(n,m):
 +    a = (n //m) * m
 +    b = a + m
 +    return (b if n - a > b - n else a)
\ No newline at end of file diff --git a/progs/a739.py b/progs/a739.py new file mode 100644 index 0000000..0bffccc --- /dev/null +++ b/progs/a739.py @@ -0,0 +1,5 @@ +def remove_replica(test_tup):
 +  temp = set()
 +  res = tuple(ele if ele not in temp and not temp.add(ele) 
 +				else 'MSP' for ele in test_tup)
 +  return (res)
\ No newline at end of file diff --git a/progs/a74.py b/progs/a74.py new file mode 100644 index 0000000..394014e --- /dev/null +++ b/progs/a74.py @@ -0,0 +1,6 @@ +def sum_nums(x, y,m,n):
 +    sum_nums= x + y
 +    if sum_nums in range(m, n):
 +        return 20
 +    else:
 +        return sum_nums
\ No newline at end of file diff --git a/progs/a740.py b/progs/a740.py new file mode 100644 index 0000000..a0f32cf --- /dev/null +++ b/progs/a740.py @@ -0,0 +1,8 @@ +def remove_Char(s,c) :  
 +    counts = s.count(c) 
 +    s = list(s) 
 +    while counts :  
 +        s.remove(c) 
 +        counts -= 1 
 +    s = '' . join(s)   
 +    return (s) 
\ No newline at end of file diff --git a/progs/a741.py b/progs/a741.py new file mode 100644 index 0000000..c7510f5 --- /dev/null +++ b/progs/a741.py @@ -0,0 +1,3 @@ +def move_first(test_list):
 +  test_list = test_list[-1:] + test_list[:-1]  
 +  return test_list
\ No newline at end of file diff --git a/progs/a742.py b/progs/a742.py new file mode 100644 index 0000000..907c58b --- /dev/null +++ b/progs/a742.py @@ -0,0 +1,3 @@ +def surfacearea_cuboid(l,w,h):
 +  SA = 2*(l*w + l * h + w * h)
 +  return SA
\ No newline at end of file diff --git a/progs/a743.py b/progs/a743.py new file mode 100644 index 0000000..76bd95b --- /dev/null +++ b/progs/a743.py @@ -0,0 +1,6 @@ +def multi_list(rownum,colnum):
 +  multi_list = [[0 for col in range(colnum)] for row in range(rownum)]
 +  for row in range(rownum):
 +    for col in range(colnum):
 +        multi_list[row][col]= row*col
 +  return multi_list
 diff --git a/progs/a744.py b/progs/a744.py new file mode 100644 index 0000000..7299c64 --- /dev/null +++ b/progs/a744.py @@ -0,0 +1,4 @@ +from operator import itemgetter
 +def index_on_inner_list(list_data, index_no):
 +    result = sorted(list_data, key=itemgetter(index_no))
 +    return result
\ No newline at end of file diff --git a/progs/a745.py b/progs/a745.py new file mode 100644 index 0000000..9a21dfa --- /dev/null +++ b/progs/a745.py @@ -0,0 +1,15 @@ +def find_rotation_count(A):
 +    (left, right) = (0, len(A) - 1)
 +    while left <= right:
 +        if A[left] <= A[right]:
 +            return left
 +        mid = (left + right) // 2
 +        next = (mid + 1) % len(A)
 +        prev = (mid - 1 + len(A)) % len(A)
 +        if A[mid] <= A[next] and A[mid] <= A[prev]:
 +            return mid
 +        elif A[mid] <= A[right]:
 +            right = mid - 1
 +        elif A[mid] >= A[left]:
 +            left = mid + 1
 +    return -1
\ No newline at end of file diff --git a/progs/a746.py b/progs/a746.py new file mode 100644 index 0000000..938c495 --- /dev/null +++ b/progs/a746.py @@ -0,0 +1,8 @@ +def even_bit_toggle_number(n) : 
 +    res = 0; count = 0; temp = n    
 +    while(temp > 0 ) : 
 +        if (count % 2 == 0) : 
 +            res = res | (1 << count)      
 +        count = count + 1
 +        temp >>= 1 
 +    return n ^ res 
\ No newline at end of file diff --git a/progs/a747.py b/progs/a747.py new file mode 100644 index 0000000..f4ea228 --- /dev/null +++ b/progs/a747.py @@ -0,0 +1,10 @@ +def frequency_Of_Smallest(n,arr): 
 +    mn = arr[0] 
 +    freq = 1
 +    for i in range(1,n): 
 +        if (arr[i] < mn): 
 +            mn = arr[i] 
 +            freq = 1
 +        elif (arr[i] == mn): 
 +            freq += 1
 +    return freq 
\ No newline at end of file diff --git a/progs/a748.py b/progs/a748.py new file mode 100644 index 0000000..2378f61 --- /dev/null +++ b/progs/a748.py @@ -0,0 +1,8 @@ +def get_perrin(n):
 +  if (n == 0):
 +    return 3
 +  if (n == 1):
 +    return 0
 +  if (n == 2):
 +    return 2 
 +  return get_perrin(n - 2) + get_perrin(n - 3)
\ No newline at end of file diff --git a/progs/a749.py b/progs/a749.py new file mode 100644 index 0000000..9c4c559 --- /dev/null +++ b/progs/a749.py @@ -0,0 +1,16 @@ +def swap_count(s):
 +	chars = s
 +	count_left = 0
 +	count_right = 0
 +	swap = 0
 +	imbalance = 0; 
 +	for i in range(len(chars)):
 +		if chars[i] == '[':
 +			count_left += 1
 +			if imbalance > 0:
 +				swap += imbalance
 +				imbalance -= 1
 +		elif chars[i] == ']':
 +			count_right += 1
 +			imbalance = (count_right - count_left) 
 +	return swap
\ No newline at end of file diff --git a/progs/a75.py b/progs/a75.py new file mode 100644 index 0000000..7092017 --- /dev/null +++ b/progs/a75.py @@ -0,0 +1,4 @@ +import re
 +def remove_extra_char(text1):
 +  pattern = re.compile('[\W_]+')
 +  return (pattern.sub('', text1))
\ No newline at end of file diff --git a/progs/a750.py b/progs/a750.py new file mode 100644 index 0000000..ca69d06 --- /dev/null +++ b/progs/a750.py @@ -0,0 +1,9 @@ +def even_or_odd(N): 
 +    l = len(N) 
 +    if (N[l-1] =='0'or N[l-1] =='2'or 
 +        N[l-1] =='4'or N[l-1] =='6'or 
 +        N[l-1] =='8'or N[l-1] =='A'or 
 +        N[l-1] =='C'or N[l-1] =='E'): 
 +        return ("Even") 
 +    else: 
 +        return ("Odd") 
\ No newline at end of file diff --git a/progs/a751.py b/progs/a751.py new file mode 100644 index 0000000..1f37c66 --- /dev/null +++ b/progs/a751.py @@ -0,0 +1,7 @@ +def highest_Power_of_2(n): 
 +    res = 0; 
 +    for i in range(n, 0, -1): 
 +        if ((i & (i - 1)) == 0): 
 +            res = i; 
 +            break; 
 +    return res; 
\ No newline at end of file diff --git a/progs/a752.py b/progs/a752.py new file mode 100644 index 0000000..fe4d162 --- /dev/null +++ b/progs/a752.py @@ -0,0 +1,6 @@ +def find_lucas(n): 
 +	if (n == 0): 
 +		return 2
 +	if (n == 1): 
 +		return 1
 +	return find_lucas(n - 1) + find_lucas(n - 2) 
\ No newline at end of file diff --git a/progs/a753.py b/progs/a753.py new file mode 100644 index 0000000..c747eba --- /dev/null +++ b/progs/a753.py @@ -0,0 +1,3 @@ +def add_string(list,string):
 + add_string=[string.format(i) for i in  list]
 + return add_string
\ No newline at end of file diff --git a/progs/a755.py b/progs/a755.py new file mode 100644 index 0000000..e338956 --- /dev/null +++ b/progs/a755.py @@ -0,0 +1,12 @@ +def get_max_sum (n):
 +	res = list()
 +	res.append(0)
 +	res.append(1)
 +	i = 2
 +	while i<n + 1:
 +		res.append(max(i, (res[int(i / 2)] 
 +						+ res[int(i / 3)] +
 +							res[int(i / 4)]
 +						+ res[int(i / 5)])))
 +		i = i + 1
 +	return res[n]
\ No newline at end of file diff --git a/progs/a757.py b/progs/a757.py new file mode 100644 index 0000000..0058994 --- /dev/null +++ b/progs/a757.py @@ -0,0 +1,9 @@ +def check_distinct(test_tup):
 +  res = True
 +  temp = set()
 +  for ele in test_tup:
 +    if ele in temp:
 +      res = False
 +      break
 +    temp.add(ele)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a758.py b/progs/a758.py new file mode 100644 index 0000000..eed8169 --- /dev/null +++ b/progs/a758.py @@ -0,0 +1,13 @@ +def first_non_repeating_character(str1):
 +  char_order = []
 +  ctr = {}
 +  for c in str1:
 +    if c in ctr:
 +      ctr[c] += 1
 +    else:
 +      ctr[c] = 1 
 +      char_order.append(c)
 +  for c in char_order:
 +    if ctr[c] == 1:
 +      return c
 +  return None
\ No newline at end of file diff --git a/progs/a76.py b/progs/a76.py new file mode 100644 index 0000000..f0231e4 --- /dev/null +++ b/progs/a76.py @@ -0,0 +1,6 @@ +def validity_triangle(a,b,c):
 + total = a + b + c
 + if total == 180:
 +    return True
 + else:
 +    return False
\ No newline at end of file diff --git a/progs/a760.py b/progs/a760.py new file mode 100644 index 0000000..2689e93 --- /dev/null +++ b/progs/a760.py @@ -0,0 +1,16 @@ +def median_numbers(a,b,c):
 + if a > b:
 +    if a < c:
 +        median = a
 +    elif b > c:
 +        median = b
 +    else:
 +        median = c
 + else:
 +    if a > c:
 +        median = a
 +    elif b < c:
 +        median = b
 +    else:
 +        median = c
 + return median
\ No newline at end of file diff --git a/progs/a761.py b/progs/a761.py new file mode 100644 index 0000000..664f653 --- /dev/null +++ b/progs/a761.py @@ -0,0 +1,2 @@ +def sum_of_digits(nums):
 +    return sum(int(el) for n in nums for el in str(n) if el.isdigit())
\ No newline at end of file diff --git a/progs/a762.py b/progs/a762.py new file mode 100644 index 0000000..6ea034b --- /dev/null +++ b/progs/a762.py @@ -0,0 +1,3 @@ +def bitwise_xor(test_tup1, test_tup2):
 +  res = tuple(ele1 ^ ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a763.py b/progs/a763.py new file mode 100644 index 0000000..6f2fc59 --- /dev/null +++ b/progs/a763.py @@ -0,0 +1,3 @@ +def extract_freq(test_list):
 +  res = len(list(set(tuple(sorted(sub)) for sub in test_list)))
 +  return (res)
\ No newline at end of file diff --git a/progs/a764.py b/progs/a764.py new file mode 100644 index 0000000..fdbfe3b --- /dev/null +++ b/progs/a764.py @@ -0,0 +1,4 @@ +def add_nested_tuples(test_tup1, test_tup2):
 +  res = tuple(tuple(a + b for a, b in zip(tup1, tup2))
 +   for tup1, tup2 in zip(test_tup1, test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a765.py b/progs/a765.py new file mode 100644 index 0000000..0c2e314 --- /dev/null +++ b/progs/a765.py @@ -0,0 +1,7 @@ +def ncr_modp(n, r, p): 
 +    C = [0 for i in range(r+1)]   
 +    C[0] = 1
 +    for i in range(1, n+1): 
 +        for j in range(min(i, r), 0, -1): 
 +            C[j] = (C[j] + C[j-1]) % p   
 +    return C[r] 
\ No newline at end of file diff --git a/progs/a766.py b/progs/a766.py new file mode 100644 index 0000000..cd09339 --- /dev/null +++ b/progs/a766.py @@ -0,0 +1,14 @@ +import re
 +def is_valid_URL(str):
 +	regex = ("((http|https)://)(www.)?" +
 +			"[a-zA-Z0-9@:%._\\+~#?&//=]" +
 +			"{2,256}\\.[a-z]" +
 +			"{2,6}\\b([-a-zA-Z0-9@:%" +
 +			"._\\+~#?&//=]*)")
 +	p = re.compile(regex)
 +	if (str == None):
 +		return False
 +	if(re.search(p, str)):
 +		return True
 +	else:
 +		return False
\ No newline at end of file diff --git a/progs/a767.py b/progs/a767.py new file mode 100644 index 0000000..f50e422 --- /dev/null +++ b/progs/a767.py @@ -0,0 +1,5 @@ +def minimum(a,b):   
 +    if a <= b: 
 +        return a 
 +    else: 
 +        return b 
\ No newline at end of file diff --git a/progs/a768.py b/progs/a768.py new file mode 100644 index 0000000..ab1612a --- /dev/null +++ b/progs/a768.py @@ -0,0 +1,5 @@ +def check_tuplex(tuplex,tuple1): 
 +  if tuple1 in tuplex:
 +    return True
 +  else:
 +     return False
\ No newline at end of file diff --git a/progs/a769.py b/progs/a769.py new file mode 100644 index 0000000..416b907 --- /dev/null +++ b/progs/a769.py @@ -0,0 +1,9 @@ +def find_Parity(x): 
 +    y = x ^ (x >> 1); 
 +    y = y ^ (y >> 2); 
 +    y = y ^ (y >> 4); 
 +    y = y ^ (y >> 8); 
 +    y = y ^ (y >> 16); 
 +    if (y & 1): 
 +        return ("Odd Parity"); 
 +    return ("Even Parity"); 
\ No newline at end of file diff --git a/progs/a77.py b/progs/a77.py new file mode 100644 index 0000000..f62aab2 --- /dev/null +++ b/progs/a77.py @@ -0,0 +1,3 @@ +def remove_spaces(str1):
 +  str1 = str1.replace(' ','')
 +  return str1
\ No newline at end of file diff --git a/progs/a772.py b/progs/a772.py new file mode 100644 index 0000000..5b664ff --- /dev/null +++ b/progs/a772.py @@ -0,0 +1,3 @@ +def min_product_tuple(list1):
 +    result_min = min([abs(x * y) for x, y in list1] )
 +    return result_min
\ No newline at end of file diff --git a/progs/a773.py b/progs/a773.py new file mode 100644 index 0000000..fc85ac4 --- /dev/null +++ b/progs/a773.py @@ -0,0 +1,3 @@ +def min_val(listval):
 +     min_val = min(i for i in listval if isinstance(i, int))
 +     return min_val
\ No newline at end of file diff --git a/progs/a774.py b/progs/a774.py new file mode 100644 index 0000000..5140495 --- /dev/null +++ b/progs/a774.py @@ -0,0 +1,3 @@ +import re
 +def snake_to_camel(word):
 +  return ''.join(x.capitalize() or '_' for x in word.split('_'))
\ No newline at end of file diff --git a/progs/a775.py b/progs/a775.py new file mode 100644 index 0000000..011edf9 --- /dev/null +++ b/progs/a775.py @@ -0,0 +1,5 @@ +def remove_odd(l):
 +    for i in l:
 +        if i % 2 != 0:
 +            l.remove(i)
 +    return l
\ No newline at end of file diff --git a/progs/a776.py b/progs/a776.py new file mode 100644 index 0000000..8a4206d --- /dev/null +++ b/progs/a776.py @@ -0,0 +1,3 @@ +def extract_nth_element(list1, n):
 +    result = [x[n] for x in list1]
 +    return result
\ No newline at end of file diff --git a/progs/a777.py b/progs/a777.py new file mode 100644 index 0000000..290a05f --- /dev/null +++ b/progs/a777.py @@ -0,0 +1,12 @@ +def overlapping(list1,list2):  
 +    c=0
 +    d=0
 +    for i in list1: 
 +        c+=1
 +    for i in list2: 
 +        d+=1
 +    for i in range(0,c): 
 +        for j in range(0,d): 
 +            if(list1[i]==list2[j]): 
 +                return 1
 +    return 0
\ No newline at end of file diff --git a/progs/a778.py b/progs/a778.py new file mode 100644 index 0000000..ad21966 --- /dev/null +++ b/progs/a778.py @@ -0,0 +1,10 @@ +def max_Product(arr): 
 +    arr_len = len(arr) 
 +    if (arr_len < 2): 
 +        return ("No pairs exists")           
 +    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    
\ No newline at end of file diff --git a/progs/a779.py b/progs/a779.py new file mode 100644 index 0000000..6c95c23 --- /dev/null +++ b/progs/a779.py @@ -0,0 +1,8 @@ +MAX = 1000000
 +def breakSum(n): 
 +	dp = [0]*(n+1) 
 +	dp[0] = 0
 +	dp[1] = 1
 +	for i in range(2, n+1): 
 +		dp[i] = max(dp[int(i/2)] + dp[int(i/3)] + dp[int(i/4)], i); 
 +	return dp[n]
\ No newline at end of file diff --git a/progs/a78.py b/progs/a78.py new file mode 100644 index 0000000..d02c2fd --- /dev/null +++ b/progs/a78.py @@ -0,0 +1,2 @@ +def access_key(ditionary,key):
 +  return list(ditionary)[key]
\ No newline at end of file diff --git a/progs/a781.py b/progs/a781.py new file mode 100644 index 0000000..d70c0c8 --- /dev/null +++ b/progs/a781.py @@ -0,0 +1,3 @@ +def Find_Max(lst): 
 +    maxList = max((x) for x in lst) 
 +    return maxList
\ No newline at end of file diff --git a/progs/a782.py b/progs/a782.py new file mode 100644 index 0000000..eaaeb95 --- /dev/null +++ b/progs/a782.py @@ -0,0 +1,4 @@ +def round_and_sum(list1):
 +  lenght=len(list1)
 +  round_and_sum=sum(list(map(round,list1))* lenght)
 +  return round_and_sum
\ No newline at end of file diff --git a/progs/a783.py b/progs/a783.py new file mode 100644 index 0000000..34b7aa4 --- /dev/null +++ b/progs/a783.py @@ -0,0 +1,5 @@ +def cube_Sum(n): 
 +    sum = 0
 +    for i in range(1,n + 1): 
 +        sum += (2*i)*(2*i)*(2*i) 
 +    return sum
\ No newline at end of file diff --git a/progs/a784.py b/progs/a784.py new file mode 100644 index 0000000..73045af --- /dev/null +++ b/progs/a784.py @@ -0,0 +1,5 @@ +def concatenate_tuple(test_tup):
 +    delim = "-"
 +    res = ''.join([str(ele) + delim for ele in test_tup])
 +    res = res[ : len(res) - len(delim)]
 +    return (str(res)) 
\ No newline at end of file diff --git a/progs/a785.py b/progs/a785.py new file mode 100644 index 0000000..9db1add --- /dev/null +++ b/progs/a785.py @@ -0,0 +1,5 @@ +def find_Average_Of_Cube(n):  
 +    sum = 0
 +    for i in range(1, n + 1): 
 +        sum += i * i * i  
 +    return round(sum / n, 6) 
\ No newline at end of file diff --git a/progs/a786.py b/progs/a786.py new file mode 100644 index 0000000..f389b2d --- /dev/null +++ b/progs/a786.py @@ -0,0 +1,22 @@ +def get_maxgold(gold, m, n): 
 +    goldTable = [[0 for i in range(n)] 
 +                        for j in range(m)]   
 +    for col in range(n-1, -1, -1): 
 +        for row in range(m):  
 +            if (col == n-1): 
 +                right = 0
 +            else: 
 +                right = goldTable[row][col+1] 
 +            if (row == 0 or col == n-1): 
 +                right_up = 0
 +            else: 
 +                right_up = goldTable[row-1][col+1] 
 +            if (row == m-1 or col == n-1): 
 +                right_down = 0
 +            else: 
 +                right_down = goldTable[row+1][col+1] 
 +            goldTable[row][col] = gold[row][col] + max(right, right_up, right_down) 
 +    res = goldTable[0][0] 
 +    for i in range(1, m): 
 +        res = max(res, goldTable[i][0])  
 +    return res 
\ No newline at end of file diff --git a/progs/a787.py b/progs/a787.py new file mode 100644 index 0000000..511864b --- /dev/null +++ b/progs/a787.py @@ -0,0 +1,3 @@ +def extract_rear(test_tuple):
 +  res = list(sub[len(sub) - 1] for sub in test_tuple)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a788.py b/progs/a788.py new file mode 100644 index 0000000..7e95056 --- /dev/null +++ b/progs/a788.py @@ -0,0 +1,6 @@ +def count_element_in_list(list1, x): 
 +    ctr = 0
 +    for i in range(len(list1)): 
 +        if x in list1[i]: 
 +            ctr+= 1          
 +    return ctr
\ No newline at end of file diff --git a/progs/a79.py b/progs/a79.py new file mode 100644 index 0000000..20b8646 --- /dev/null +++ b/progs/a79.py @@ -0,0 +1,5 @@ +def increasing_trend(nums):
 +    if (sorted(nums)== nums):
 +        return True
 +    else:
 +        return False
\ No newline at end of file diff --git a/progs/a791.py b/progs/a791.py new file mode 100644 index 0000000..d92ed2e --- /dev/null +++ b/progs/a791.py @@ -0,0 +1,13 @@ +def shell_sort(my_list):
 +    gap = len(my_list) // 2
 +    while gap > 0:
 +        for i in range(gap, len(my_list)):
 +            current_item = my_list[i]
 +            j = i
 +            while j >= gap and my_list[j - gap] > current_item:
 +                my_list[j] = my_list[j - gap]
 +                j -= gap
 +            my_list[j] = current_item
 +        gap //= 2
 +
 +    return my_list
\ No newline at end of file diff --git a/progs/a792.py b/progs/a792.py new file mode 100644 index 0000000..627f870 --- /dev/null +++ b/progs/a792.py @@ -0,0 +1,3 @@ +def and_tuples(test_tup1, test_tup2):
 +  res = tuple(ele1 & ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a793.py b/progs/a793.py new file mode 100644 index 0000000..de20ece --- /dev/null +++ b/progs/a793.py @@ -0,0 +1,3 @@ +def parabola_directrix(a, b, c): 
 +  directrix=((int)(c - ((b * b) + 1) * 4 * a ))
 +  return directrix
\ No newline at end of file diff --git a/progs/a794.py b/progs/a794.py new file mode 100644 index 0000000..564ce23 --- /dev/null +++ b/progs/a794.py @@ -0,0 +1,7 @@ +def common_element(list1, list2):
 +     result = False
 +     for x in list1:
 +         for y in list2:
 +             if x == y:
 +                 result = True
 +                 return result
\ No newline at end of file diff --git a/progs/a795.py b/progs/a795.py new file mode 100644 index 0000000..0321581 --- /dev/null +++ b/progs/a795.py @@ -0,0 +1,3 @@ +def median_trapezium(base1,base2,height):
 + median = 0.5 * (base1+ base2)
 + return median
\ No newline at end of file diff --git a/progs/a796.py b/progs/a796.py new file mode 100644 index 0000000..037d6cb --- /dev/null +++ b/progs/a796.py @@ -0,0 +1,6 @@ +def check_greater(arr, number):
 +  arr.sort()
 +  if number > arr[-1]:
 +    return ('Yes, the entered number is greater than those in the array')
 +  else:
 +    return ('No, entered number is less than those in the array')
\ No newline at end of file diff --git a/progs/a797.py b/progs/a797.py new file mode 100644 index 0000000..da7ac90 --- /dev/null +++ b/progs/a797.py @@ -0,0 +1,7 @@ +import re
 +def text_match_one(text):
 +        patterns = 'ab+?'
 +        if re.search(patterns,  text):
 +                return 'Found a match!'
 +        else:
 +                return('Not matched!')
 diff --git a/progs/a798.py b/progs/a798.py new file mode 100644 index 0000000..e028b53 --- /dev/null +++ b/progs/a798.py @@ -0,0 +1,2 @@ +def last_Digit(n) :
 +    return (n % 10) 
\ No newline at end of file diff --git a/progs/a799.py b/progs/a799.py new file mode 100644 index 0000000..5195a90 --- /dev/null +++ b/progs/a799.py @@ -0,0 +1,4 @@ +def neg_nos(list1):
 +  for num in list1: 
 +    if num < 0: 
 +       return num 
\ No newline at end of file diff --git a/progs/a8.py b/progs/a8.py new file mode 100644 index 0000000..b4bf744 --- /dev/null +++ b/progs/a8.py @@ -0,0 +1,3 @@ +def floor_Min(A,B,N):
 +    x = max(B - 1,N)
 +    return (A*x) // B
\ No newline at end of file diff --git a/progs/a80.py b/progs/a80.py new file mode 100644 index 0000000..799d51a --- /dev/null +++ b/progs/a80.py @@ -0,0 +1,9 @@ +def smallest_Divisor(n): 
 +    if (n % 2 == 0): 
 +        return 2; 
 +    i = 3;  
 +    while (i*i <= n): 
 +        if (n % i == 0): 
 +            return i; 
 +        i += 2; 
 +    return n; 
\ No newline at end of file diff --git a/progs/a800.py b/progs/a800.py new file mode 100644 index 0000000..a0b3a08 --- /dev/null +++ b/progs/a800.py @@ -0,0 +1,6 @@ +def remove_odd(str1):
 + str2 = ''
 + for i in range(1, len(str1) + 1):
 +    if(i % 2 == 0):
 +        str2 = str2 + str1[i - 1]
 + return str2
\ No newline at end of file diff --git a/progs/a801.py b/progs/a801.py new file mode 100644 index 0000000..5b0c931 --- /dev/null +++ b/progs/a801.py @@ -0,0 +1,7 @@ +def count_bidirectional(test_list):
 +  res = 0
 +  for idx in range(0, len(test_list)):
 +    for iidx in range(idx + 1, len(test_list)):
 +      if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:
 +        res += 1
 +  return (str(res)) 
\ No newline at end of file diff --git a/progs/a802.py b/progs/a802.py new file mode 100644 index 0000000..d1c92cd --- /dev/null +++ b/progs/a802.py @@ -0,0 +1,3 @@ +def multiple_to_single(L):
 +  x = int("".join(map(str, L)))
 +  return x
\ No newline at end of file diff --git a/progs/a804.py b/progs/a804.py new file mode 100644 index 0000000..a007024 --- /dev/null +++ b/progs/a804.py @@ -0,0 +1,3 @@ +def surfacearea_cube(l):
 +  surfacearea= 6*l*l
 +  return surfacearea
\ No newline at end of file diff --git a/progs/a805.py b/progs/a805.py new file mode 100644 index 0000000..aeb949e --- /dev/null +++ b/progs/a805.py @@ -0,0 +1,10 @@ +from array import array
 +def positive_count(nums):
 +    n = len(nums)
 +    n1 = 0
 +    for x in nums:
 +        if x > 0:
 +            n1 += 1
 +        else:
 +          None
 +    return round(n1/n,2)
\ No newline at end of file diff --git a/progs/a806.py b/progs/a806.py new file mode 100644 index 0000000..bccb853 --- /dev/null +++ b/progs/a806.py @@ -0,0 +1,6 @@ +def largest_neg(list1): 
 +    max = list1[0] 
 +    for x in list1: 
 +        if x < max : 
 +             max = x  
 +    return max
\ No newline at end of file diff --git a/progs/a807.py b/progs/a807.py new file mode 100644 index 0000000..2ee98f6 --- /dev/null +++ b/progs/a807.py @@ -0,0 +1,6 @@ +def trim_tuple(test_list, K):
 +  res = []
 +  for ele in test_list:
 +    N = len(ele)
 +    res.append(tuple(list(ele)[K: N - K]))
 +  return (str(res)) 
\ No newline at end of file diff --git a/progs/a808.py b/progs/a808.py new file mode 100644 index 0000000..2d8bef1 --- /dev/null +++ b/progs/a808.py @@ -0,0 +1,4 @@ +def index_multiplication(test_tup1, test_tup2):
 +  res = tuple(tuple(a * b for a, b in zip(tup1, tup2))
 +   for tup1, tup2 in zip(test_tup1, test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a809.py b/progs/a809.py new file mode 100644 index 0000000..936cd5e --- /dev/null +++ b/progs/a809.py @@ -0,0 +1,7 @@ +from collections import Counter 
 +def count_Occurrence(tup, lst): 
 +    count = 0
 +    for item in tup: 
 +        if item in lst: 
 +            count+= 1 
 +    return count  
\ No newline at end of file diff --git a/progs/a811.py b/progs/a811.py new file mode 100644 index 0000000..2788477 --- /dev/null +++ b/progs/a811.py @@ -0,0 +1,19 @@ +def cal_sum(n): 
 +	a = 3
 +	b = 0
 +	c = 2
 +	if (n == 0): 
 +		return 3
 +	if (n == 1): 
 +		return 3
 +	if (n == 2): 
 +		return 5
 +	sum = 5
 +	while (n > 2): 
 +		d = a + b 
 +		sum = sum + d 
 +		a = b 
 +		b = c 
 +		c = d 
 +		n = n-1
 +	return sum
\ No newline at end of file diff --git a/progs/a812.py b/progs/a812.py new file mode 100644 index 0000000..5db5018 --- /dev/null +++ b/progs/a812.py @@ -0,0 +1,6 @@ +def check_Triangle(x1,y1,x2,y2,x3,y3): 
 +    a = (x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))   
 +    if a == 0: 
 +        return ('No') 
 +    else: 
 +        return ('Yes') 
\ No newline at end of file diff --git a/progs/a813.py b/progs/a813.py new file mode 100644 index 0000000..67d4eec --- /dev/null +++ b/progs/a813.py @@ -0,0 +1,3 @@ +def extract_string(str, l):
 +    result = [e for e in str if len(e) == l] 
 +    return result
\ No newline at end of file diff --git a/progs/a815.py b/progs/a815.py new file mode 100644 index 0000000..1c6dbb1 --- /dev/null +++ b/progs/a815.py @@ -0,0 +1,6 @@ +def loss_amount(actual_cost,sale_amount): 
 +  if(sale_amount > actual_cost):
 +    amount = sale_amount - actual_cost
 +    return amount
 +  else:
 +    return None
\ No newline at end of file diff --git a/progs/a816.py b/progs/a816.py new file mode 100644 index 0000000..2809b86 --- /dev/null +++ b/progs/a816.py @@ -0,0 +1,20 @@ +import math 
 +def sumofFactors(n) : 
 +    if (n % 2 != 0) : 
 +        return 0
 +    res = 1
 +    for i in range(2, (int)(math.sqrt(n)) + 1) :    
 +        count = 0
 +        curr_sum = 1
 +        curr_term = 1
 +        while (n % i == 0) : 
 +            count= count + 1
 +            n = n // i 
 +            if (i == 2 and count == 1) : 
 +                curr_sum = 0
 +            curr_term = curr_term * i 
 +            curr_sum = curr_sum + curr_term 
 +        res = res * curr_sum  
 +    if (n >= 2) : 
 +        res = res * (1 + n) 
 +    return res 
\ No newline at end of file diff --git a/progs/a817.py b/progs/a817.py new file mode 100644 index 0000000..472dac9 --- /dev/null +++ b/progs/a817.py @@ -0,0 +1,7 @@ +import re
 +def text_match_wordz(text):
 +        patterns = '\w*z.\w*'
 +        if re.search(patterns,  text):
 +                return 'Found a match!'
 +        else:
 +                return('Not matched!')
\ No newline at end of file diff --git a/progs/a818.py b/progs/a818.py new file mode 100644 index 0000000..377a6e9 --- /dev/null +++ b/progs/a818.py @@ -0,0 +1,5 @@ +def check_monthnumb_number(monthnum2):
 +  if(monthnum2==1 or monthnum2==3 or monthnum2==5 or monthnum2==7 or monthnum2==8 or monthnum2==10 or monthnum2==12):
 +    return True
 +  else:
 +    return False
\ No newline at end of file diff --git a/progs/a819.py b/progs/a819.py new file mode 100644 index 0000000..f6b1e08 --- /dev/null +++ b/progs/a819.py @@ -0,0 +1,3 @@ +def reverse_string_list(stringlist):
 +    result = [x[::-1] for x in stringlist]
 +    return result
\ No newline at end of file diff --git a/progs/a82.py b/progs/a82.py new file mode 100644 index 0000000..cbd8881 --- /dev/null +++ b/progs/a82.py @@ -0,0 +1,10 @@ +def sum_Square(n) : 
 +    i = 1 
 +    while i*i <= n : 
 +        j = 1
 +        while (j*j <= n) : 
 +            if (i*i+j*j == n) : 
 +                return True
 +            j = j+1
 +        i = i+1     
 +    return False
\ No newline at end of file diff --git a/progs/a820.py b/progs/a820.py new file mode 100644 index 0000000..ffdec8e --- /dev/null +++ b/progs/a820.py @@ -0,0 +1,3 @@ +def Find_Min(lst): 
 +    minList = min((x) for x in lst) 
 +    return minList
\ No newline at end of file diff --git a/progs/a821.py b/progs/a821.py new file mode 100644 index 0000000..427df42 --- /dev/null +++ b/progs/a821.py @@ -0,0 +1,3 @@ +def rectangle_area(l,b):
 +  area=l*b
 +  return area
\ No newline at end of file diff --git a/progs/a823.py b/progs/a823.py new file mode 100644 index 0000000..2c3eea4 --- /dev/null +++ b/progs/a823.py @@ -0,0 +1,2 @@ +def Extract(lst): 
 +    return [item[0] for item in lst] 
\ No newline at end of file diff --git a/progs/a824.py b/progs/a824.py new file mode 100644 index 0000000..5c8fcbd --- /dev/null +++ b/progs/a824.py @@ -0,0 +1,5 @@ +def upper_ctr(str):
 +    upper_ctr = 0
 +    for i in range(len(str)):
 +          if str[i] >= 'A' and str[i] <= 'Z': upper_ctr += 1
 +          return upper_ctr
\ No newline at end of file diff --git a/progs/a825.py b/progs/a825.py new file mode 100644 index 0000000..24d9abe --- /dev/null +++ b/progs/a825.py @@ -0,0 +1,7 @@ +def combinations_list(list1):
 +    if len(list1) == 0:
 +        return [[]]
 +    result = []
 +    for el in combinations_list(list1[1:]):
 +        result += [el, el+[list1[0]]]
 +    return result
\ No newline at end of file diff --git a/progs/a826.py b/progs/a826.py new file mode 100644 index 0000000..ce273aa --- /dev/null +++ b/progs/a826.py @@ -0,0 +1,23 @@ +def max_subarray_product(arr):
 +	n = len(arr)
 +	max_ending_here = 1
 +	min_ending_here = 1
 +	max_so_far = 0
 +	flag = 0
 +	for i in range(0, n):
 +		if arr[i] > 0:
 +			max_ending_here = max_ending_here * arr[i]
 +			min_ending_here = min (min_ending_here * arr[i], 1)
 +			flag = 1
 +		elif arr[i] == 0:
 +			max_ending_here = 1
 +			min_ending_here = 1
 +		else:
 +			temp = max_ending_here
 +			max_ending_here = max (min_ending_here * arr[i], 1)
 +			min_ending_here = temp * arr[i]
 +		if (max_so_far < max_ending_here):
 +			max_so_far = max_ending_here
 +	if flag == 0 and max_so_far == 0:
 +		return 0
 +	return max_so_far
\ No newline at end of file diff --git a/progs/a827.py b/progs/a827.py new file mode 100644 index 0000000..1d9e61d --- /dev/null +++ b/progs/a827.py @@ -0,0 +1,3 @@ +def check_value(dict, n):
 +    result = all(x == n for x in dict.values()) 
 +    return result
\ No newline at end of file diff --git a/progs/a829.py b/progs/a829.py new file mode 100644 index 0000000..6bc62b9 --- /dev/null +++ b/progs/a829.py @@ -0,0 +1,12 @@ +def find_peak_util(arr, low, high, n): 
 +	mid = low + (high - low)/2
 +	mid = int(mid) 
 +	if ((mid == 0 or arr[mid - 1] <= arr[mid]) and
 +		(mid == n - 1 or arr[mid + 1] <= arr[mid])): 
 +		return mid 
 +	elif (mid > 0 and arr[mid - 1] > arr[mid]): 
 +		return find_peak_util(arr, low, (mid - 1), n) 
 +	else: 
 +		return find_peak_util(arr, (mid + 1), high, n) 
 +def find_peak(arr, n): 
 +	return find_peak_util(arr, 0, n - 1, n) 
\ No newline at end of file diff --git a/progs/a83.py b/progs/a83.py new file mode 100644 index 0000000..213440b --- /dev/null +++ b/progs/a83.py @@ -0,0 +1,13 @@ +def count_Char(str,x): 
 +    count = 0
 +    for i in range(len(str)):  
 +        if (str[i] == x) : 
 +            count += 1
 +    n = 10
 +    repititions = n // len(str)  
 +    count = count * repititions  
 +    l = n % len(str)  
 +    for i in range(l): 
 +        if (str[i] == x):  
 +            count += 1
 +    return count  
\ No newline at end of file diff --git a/progs/a830.py b/progs/a830.py new file mode 100644 index 0000000..1541288 --- /dev/null +++ b/progs/a830.py @@ -0,0 +1,10 @@ +def decimal_to_Octal(deciNum):
 +    octalNum = 0
 +    countval = 1;
 +    dNo = deciNum;
 +    while (deciNum!= 0):
 +        remainder= deciNum % 8;
 +        octalNum+= remainder*countval;
 +        countval= countval*10;
 +        deciNum //= 8; 
 +    return (octalNum)
\ No newline at end of file diff --git a/progs/a831.py b/progs/a831.py new file mode 100644 index 0000000..117ceeb --- /dev/null +++ b/progs/a831.py @@ -0,0 +1,10 @@ +def max_product(arr, n ): 
 +	mpis =[0] * (n) 
 +	for i in range(n): 
 +		mpis[i] = arr[i] 
 +	for i in range(1, n): 
 +		for j in range(i): 
 +			if (arr[i] > arr[j] and
 +					mpis[i] < (mpis[j] * arr[i])): 
 +						mpis[i] = mpis[j] * arr[i] 
 +	return max(mpis)
\ No newline at end of file diff --git a/progs/a832.py b/progs/a832.py new file mode 100644 index 0000000..5e11874 --- /dev/null +++ b/progs/a832.py @@ -0,0 +1,15 @@ +def max_profit(price, k):
 +    n = len(price)
 +    final_profit = [[None for x in range(n)] for y in range(k + 1)]
 +    for i in range(k + 1):
 +        for j in range(n):
 +            if i == 0 or j == 0:
 +                final_profit[i][j] = 0
 +            else:
 +                max_so_far = 0
 +                for x in range(j):
 +                    curr_price = price[j] - price[x] + final_profit[i-1][x]
 +                    if max_so_far < curr_price:
 +                        max_so_far = curr_price
 +                final_profit[i][j] = max(final_profit[i][j-1], max_so_far)
 +    return final_profit[k][n-1]
\ No newline at end of file diff --git a/progs/a833.py b/progs/a833.py new file mode 100644 index 0000000..36c43d1 --- /dev/null +++ b/progs/a833.py @@ -0,0 +1,3 @@ +def add_pairwise(test_tup):
 +  res = tuple(i + j for i, j in zip(test_tup, test_tup[1:]))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a834.py b/progs/a834.py new file mode 100644 index 0000000..3948f46 --- /dev/null +++ b/progs/a834.py @@ -0,0 +1,5 @@ +def find_remainder(arr, lens, n): 
 +    mul = 1
 +    for i in range(lens):  
 +        mul = (mul * (arr[i] % n)) % n 
 +    return mul % n 
\ No newline at end of file diff --git a/progs/a835.py b/progs/a835.py new file mode 100644 index 0000000..f407838 --- /dev/null +++ b/progs/a835.py @@ -0,0 +1,2 @@ +def check_Consecutive(l): 
 +    return sorted(l) == list(range(min(l),max(l)+1)) 
\ No newline at end of file diff --git a/progs/a836.py b/progs/a836.py new file mode 100644 index 0000000..319fd86 --- /dev/null +++ b/progs/a836.py @@ -0,0 +1,3 @@ +def tuple_intersection(test_list1, test_list2):
 +  res = set([tuple(sorted(ele)) for ele in test_list1]) & set([tuple(sorted(ele)) for ele in test_list2])
 +  return (res)
\ No newline at end of file diff --git a/progs/a837.py b/progs/a837.py new file mode 100644 index 0000000..38c9d68 --- /dev/null +++ b/progs/a837.py @@ -0,0 +1,3 @@ +def replace_char(str1,ch,newch):
 + str2 = str1.replace(ch, newch)
 + return str2
\ No newline at end of file diff --git a/progs/a838.py b/progs/a838.py new file mode 100644 index 0000000..9dfef53 --- /dev/null +++ b/progs/a838.py @@ -0,0 +1,5 @@ +from collections import Counter
 +def sort_counter(dict1):
 + x = Counter(dict1)
 + sort_counter=x.most_common()
 + return sort_counter
\ No newline at end of file diff --git a/progs/a839.py b/progs/a839.py new file mode 100644 index 0000000..1aeeb64 --- /dev/null +++ b/progs/a839.py @@ -0,0 +1,3 @@ +def big_sum(nums):
 +      sum= max(nums)+min(nums)
 +      return sum
\ No newline at end of file diff --git a/progs/a84.py b/progs/a84.py new file mode 100644 index 0000000..f7e6c29 --- /dev/null +++ b/progs/a84.py @@ -0,0 +1,15 @@ +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
\ No newline at end of file diff --git a/progs/a840.py b/progs/a840.py new file mode 100644 index 0000000..58cf076 --- /dev/null +++ b/progs/a840.py @@ -0,0 +1,2 @@ +def is_lower(string):
 +  return (string.lower())
\ No newline at end of file diff --git a/progs/a842.py b/progs/a842.py new file mode 100644 index 0000000..6759e3e --- /dev/null +++ b/progs/a842.py @@ -0,0 +1,4 @@ +def first_Digit(n) :  
 +    while n >= 10:  
 +        n = n / 10; 
 +    return int(n) 
\ No newline at end of file diff --git a/progs/a843.py b/progs/a843.py new file mode 100644 index 0000000..0f192b7 --- /dev/null +++ b/progs/a843.py @@ -0,0 +1,12 @@ +def get_max_occuring_char(str1):
 +  ASCII_SIZE = 256
 +  ctr = [0] * ASCII_SIZE
 +  max = -1
 +  ch = ''
 +  for i in str1:
 +    ctr[ord(i)]+=1;
 +  for i in str1:
 +    if max < ctr[ord(i)]:
 +      max = ctr[ord(i)]
 +      ch = i
 +  return ch
\ No newline at end of file diff --git a/progs/a844.py b/progs/a844.py new file mode 100644 index 0000000..069b713 --- /dev/null +++ b/progs/a844.py @@ -0,0 +1,8 @@ +def is_subset_sum(set, n, sum):
 +	if (sum == 0):
 +		return True
 +	if (n == 0):
 +		return False
 +	if (set[n - 1] > sum):
 +		return is_subset_sum(set, n - 1, sum)
 +	return is_subset_sum(set, n-1, sum) or is_subset_sum(set, n-1, sum-set[n-1])
\ No newline at end of file diff --git a/progs/a845.py b/progs/a845.py new file mode 100644 index 0000000..d263407 --- /dev/null +++ b/progs/a845.py @@ -0,0 +1,7 @@ +import re 
 +def match(text): 
 +		pattern = '[A-Z]+[a-z]+$'
 +		if re.search(pattern, text): 
 +				return('Yes') 
 +		else: 
 +				return('No') 
\ No newline at end of file diff --git a/progs/a846.py b/progs/a846.py new file mode 100644 index 0000000..d77c2e2 --- /dev/null +++ b/progs/a846.py @@ -0,0 +1,8 @@ +def first_Factorial_Divisible_Number(x): 
 +    i = 1;
 +    fact = 1; 
 +    for i in range(1,x): 
 +        fact = fact * i 
 +        if (fact % x == 0): 
 +            break
 +    return i 
\ No newline at end of file diff --git a/progs/a847.py b/progs/a847.py new file mode 100644 index 0000000..2de4852 --- /dev/null +++ b/progs/a847.py @@ -0,0 +1,3 @@ +def remove_matching_tuple(test_list1, test_list2):
 +  res = [sub for sub in test_list1 if sub not in test_list2]
 +  return (res) 
\ No newline at end of file diff --git a/progs/a848.py b/progs/a848.py new file mode 100644 index 0000000..594d29b --- /dev/null +++ b/progs/a848.py @@ -0,0 +1,18 @@ +def is_palindrome(n) : 
 +	divisor = 1
 +	while (n / divisor >= 10) : 
 +		divisor *= 10
 +	while (n != 0) : 
 +		leading = n // divisor 
 +		trailing = n % 10
 +		if (leading != trailing) : 
 +			return False
 +		n = (n % divisor) // 10
 +		divisor = divisor // 100
 +	return True
 +def largest_palindrome(A, n) : 
 +	A.sort() 
 +	for i in range(n - 1, -1, -1) : 
 +		if (is_palindrome(A[i])) : 
 +			return A[i] 
 +	return -1
\ No newline at end of file diff --git a/progs/a849.py b/progs/a849.py new file mode 100644 index 0000000..b35a0d0 --- /dev/null +++ b/progs/a849.py @@ -0,0 +1,10 @@ +def nCr(n, r): 
 +	if (r > n / 2): 
 +		r = n - r 
 +	answer = 1 
 +	for i in range(1, r + 1): 
 +		answer *= (n - r + i) 
 +		answer /= i 
 +	return answer 
 +def binomial_probability(n, k, p): 
 +	return (nCr(n, k) * pow(p, k) *	pow(1 - p, n - k)) 
\ No newline at end of file diff --git a/progs/a85.py b/progs/a85.py new file mode 100644 index 0000000..f07b1fe --- /dev/null +++ b/progs/a85.py @@ -0,0 +1,6 @@ +from collections import defaultdict 
 +def freq_element(test_tup):
 +  res = defaultdict(int)
 +  for ele in test_tup:
 +    res[ele] += 1
 +  return (str(dict(res))) 
\ No newline at end of file diff --git a/progs/a850.py b/progs/a850.py new file mode 100644 index 0000000..1a39421 --- /dev/null +++ b/progs/a850.py @@ -0,0 +1,9 @@ +def sort_tuple(tup): 
 +	lst = len(tup) 
 +	for i in range(0, lst): 
 +		for j in range(0, lst-i-1): 
 +			if (tup[j][-1] > tup[j + 1][-1]): 
 +				temp = tup[j] 
 +				tup[j]= tup[j + 1] 
 +				tup[j + 1]= temp 
 +	return tup
\ No newline at end of file diff --git a/progs/a851.py b/progs/a851.py new file mode 100644 index 0000000..4fd1a4b --- /dev/null +++ b/progs/a851.py @@ -0,0 +1,4 @@ +import math
 +def area_pentagon(a):
 +  area=(math.sqrt(5*(5+2*math.sqrt(5)))*pow(a,2))/4.0
 +  return area
\ No newline at end of file diff --git a/progs/a852.py b/progs/a852.py new file mode 100644 index 0000000..1b0f727 --- /dev/null +++ b/progs/a852.py @@ -0,0 +1,10 @@ +def frequency_Of_Largest(n,arr): 
 +    mn = arr[0] 
 +    freq = 1
 +    for i in range(1,n): 
 +        if (arr[i] >mn): 
 +            mn = arr[i] 
 +            freq = 1
 +        elif (arr[i] == mn): 
 +            freq += 1
 +    return freq 
\ No newline at end of file diff --git a/progs/a853.py b/progs/a853.py new file mode 100644 index 0000000..df558ce --- /dev/null +++ b/progs/a853.py @@ -0,0 +1,4 @@ +def extract_symmetric(test_list):
 +  temp = set(test_list) & {(b, a) for a, b in test_list}
 +  res = {(a, b) for a, b in temp if a < b}
 +  return (res) 
\ No newline at end of file diff --git a/progs/a854.py b/progs/a854.py new file mode 100644 index 0000000..6c39844 --- /dev/null +++ b/progs/a854.py @@ -0,0 +1,4 @@ +import math
 +def sum_gp(a,n,r):
 + total = (a * (1 - math.pow(r, n ))) / (1- r)
 + return total
\ No newline at end of file diff --git a/progs/a855.py b/progs/a855.py new file mode 100644 index 0000000..370a4d9 --- /dev/null +++ b/progs/a855.py @@ -0,0 +1,14 @@ +def binary_search(item_list,item):
 +	first = 0
 +	last = len(item_list)-1
 +	found = False
 +	while( first<=last and not found):
 +		mid = (first + last)//2
 +		if item_list[mid] == item :
 +			found = True
 +		else:
 +			if item < item_list[mid]:
 +				last = mid - 1
 +			else:
 +				first = mid + 1	
 +	return found
\ No newline at end of file diff --git a/progs/a856.py b/progs/a856.py new file mode 100644 index 0000000..aa5a8e0 --- /dev/null +++ b/progs/a856.py @@ -0,0 +1,50 @@ +import math
 +def calculate_polygons(startx, starty, endx, endy, radius):
 +    sl = (2 * radius) * math.tan(math.pi / 6)
 +    p = sl * 0.5
 +    b = sl * math.cos(math.radians(30))
 +    w = b * 2
 +    h = 2 * sl   
 +    startx = startx - w
 +    starty = starty - h
 +    endx = endx + w
 +    endy = endy + h
 +    origx = startx
 +    origy = starty
 +    xoffset = b
 +    yoffset = 3 * p
 +    polygons = []
 +    row = 1
 +    counter = 0
 +    while starty < endy:
 +        if row % 2 == 0:
 +            startx = origx + xoffset
 +        else:
 +            startx = origx
 +        while startx < endx:
 +            p1x = startx
 +            p1y = starty + p
 +            p2x = startx
 +            p2y = starty + (3 * p)
 +            p3x = startx + b
 +            p3y = starty + h
 +            p4x = startx + w
 +            p4y = starty + (3 * p)
 +            p5x = startx + w
 +            p5y = starty + p
 +            p6x = startx + b
 +            p6y = starty
 +            poly = [
 +                (p1x, p1y),
 +                (p2x, p2y),
 +                (p3x, p3y),
 +                (p4x, p4y),
 +                (p5x, p5y),
 +                (p6x, p6y),
 +                (p1x, p1y)]
 +            polygons.append(poly)
 +            counter += 1
 +            startx += w
 +        starty += yoffset
 +        row += 1
 +    return polygons
\ No newline at end of file diff --git a/progs/a857.py b/progs/a857.py new file mode 100644 index 0000000..39fba8c --- /dev/null +++ b/progs/a857.py @@ -0,0 +1,3 @@ +def binary_to_integer(test_tup):
 +  res = int("".join(str(ele) for ele in test_tup), 2)
 +  return (str(res)) 
\ No newline at end of file diff --git a/progs/a859.py b/progs/a859.py new file mode 100644 index 0000000..2718025 --- /dev/null +++ b/progs/a859.py @@ -0,0 +1,4 @@ +import heapq as hq
 +def heap_queue_smallest(nums,n):
 +  smallest_nums = hq.nsmallest(n, nums)
 +  return smallest_nums
\ No newline at end of file diff --git a/progs/a86.py b/progs/a86.py new file mode 100644 index 0000000..7dedf3c --- /dev/null +++ b/progs/a86.py @@ -0,0 +1,9 @@ +def recur_gcd(a, b):
 +	low = min(a, b)
 +	high = max(a, b)
 +	if low == 0:
 +		return high
 +	elif low == 1:
 +		return 1
 +	else:
 +		return recur_gcd(low, high%low)
\ No newline at end of file diff --git a/progs/a860.py b/progs/a860.py new file mode 100644 index 0000000..bce4d9e --- /dev/null +++ b/progs/a860.py @@ -0,0 +1,5 @@ +import math
 +def surfacearea_cone(r,h):
 +  l = math.sqrt(r * r + h * h)
 +  SA = math.pi * r * (r + l)
 +  return SA
\ No newline at end of file diff --git a/progs/a861.py b/progs/a861.py new file mode 100644 index 0000000..3d50955 --- /dev/null +++ b/progs/a861.py @@ -0,0 +1,9 @@ +def gcd(x, y):
 +    gcd = 1
 +    if x % y == 0:
 +        return y
 +    for k in range(int(y / 2), 0, -1):
 +        if x % k == 0 and y % k == 0:
 +            gcd = k
 +            break  
 +    return gcd
\ No newline at end of file diff --git a/progs/a862.py b/progs/a862.py new file mode 100644 index 0000000..3867b26 --- /dev/null +++ b/progs/a862.py @@ -0,0 +1,3 @@ +def diameter_circle(r):
 +  diameter=2*r
 +  return diameter
\ No newline at end of file diff --git a/progs/a863.py b/progs/a863.py new file mode 100644 index 0000000..f4d8c79 --- /dev/null +++ b/progs/a863.py @@ -0,0 +1,5 @@ +def concatenate_elements(list):
 +  ans = ' '
 +  for i in list:
 +    ans = ans+ ' '+i
 +  return (ans) 
\ No newline at end of file diff --git a/progs/a864.py b/progs/a864.py new file mode 100644 index 0000000..b9ce38d --- /dev/null +++ b/progs/a864.py @@ -0,0 +1,19 @@ +def ngcd(x,y):
 +    i=1
 +    while(i<=x and i<=y):
 +        if(x%i==0 and y%i == 0):
 +            gcd=i;
 +        i+=1
 +    return gcd;
 +def num_comm_div(x,y):
 +  n = ngcd(x,y)
 +  result = 0
 +  z = int(n**0.5)
 +  i = 1
 +  while(i <= z):
 +    if(n % i == 0):
 +      result += 2 
 +      if(i == n/i):
 +        result-=1
 +    i+=1
 +  return result
\ No newline at end of file diff --git a/progs/a865.py b/progs/a865.py new file mode 100644 index 0000000..59d630b --- /dev/null +++ b/progs/a865.py @@ -0,0 +1,3 @@ +def find(n,m):
 +  r = n%m
 +  return (r)
\ No newline at end of file diff --git a/progs/a866.py b/progs/a866.py new file mode 100644 index 0000000..651da78 --- /dev/null +++ b/progs/a866.py @@ -0,0 +1,3 @@ +def add_consecutive_nums(nums):
 +    result = [b+a for a, b in zip(nums[:-1], nums[1:])]
 +    return result
\ No newline at end of file diff --git a/progs/a867.py b/progs/a867.py new file mode 100644 index 0000000..c8fc7bf --- /dev/null +++ b/progs/a867.py @@ -0,0 +1,5 @@ +def sum_Of_Series(n): 
 +    sum = 0
 +    for i in range(1,n + 1): 
 +        sum += i * i*i       
 +    return sum
\ No newline at end of file diff --git a/progs/a868.py b/progs/a868.py new file mode 100644 index 0000000..fa2a9d2 --- /dev/null +++ b/progs/a868.py @@ -0,0 +1,9 @@ +def re_order(A):
 +    k = 0
 +    for i in A:
 +        if i:
 +            A[k] = i
 +            k = k + 1
 +    for i in range(k, len(A)):
 +        A[i] = 0
 +    return A
\ No newline at end of file diff --git a/progs/a869.py b/progs/a869.py new file mode 100644 index 0000000..4c6a66f --- /dev/null +++ b/progs/a869.py @@ -0,0 +1,13 @@ +def permutation_coefficient(n, k): 
 +	P = [[0 for i in range(k + 1)] 
 +			for j in range(n + 1)] 
 +	for i in range(n + 1): 
 +		for j in range(min(i, k) + 1): 
 +			if (j == 0): 
 +				P[i][j] = 1
 +			else: 
 +				P[i][j] = P[i - 1][j] + ( 
 +						j * P[i - 1][j - 1]) 
 +			if (j < k): 
 +				P[i][j + 1] = 0
 +	return P[n][k] 
\ No newline at end of file diff --git a/progs/a87.py b/progs/a87.py new file mode 100644 index 0000000..d41eb77 --- /dev/null +++ b/progs/a87.py @@ -0,0 +1,5 @@ +import cmath
 +def len_complex(a,b):
 +  cn=complex(a,b)
 +  length=abs(cn)
 +  return length
\ No newline at end of file diff --git a/progs/a870.py b/progs/a870.py new file mode 100644 index 0000000..ed9bae7 --- /dev/null +++ b/progs/a870.py @@ -0,0 +1,5 @@ +def remove_words(list1, removewords):
 +    for word in list(list1):
 +        if word in removewords:
 +            list1.remove(word)
 +    return list1  
\ No newline at end of file diff --git a/progs/a871.py b/progs/a871.py new file mode 100644 index 0000000..1a0e562 --- /dev/null +++ b/progs/a871.py @@ -0,0 +1,5 @@ +def same_order(l1, l2):
 +    common_elements = set(l1) & set(l2)
 +    l1 = [e for e in l1 if e in common_elements]
 +    l2 = [e for e in l2 if e in common_elements]
 +    return l1 == l2
\ No newline at end of file diff --git a/progs/a872.py b/progs/a872.py new file mode 100644 index 0000000..ee96b9c --- /dev/null +++ b/progs/a872.py @@ -0,0 +1,11 @@ +def average_Odd(n) : 
 +    if (n%2==0) : 
 +        return ("Invalid Input") 
 +        return -1 
 +    sm =0
 +    count =0
 +    while (n>=1) : 
 +        count=count+1
 +        sm = sm + n 
 +        n = n-2
 +    return sm//count 
\ No newline at end of file diff --git a/progs/a873.py b/progs/a873.py new file mode 100644 index 0000000..dbde9d2 --- /dev/null +++ b/progs/a873.py @@ -0,0 +1,10 @@ +def no_of_subsequences(arr, k): 
 +	n = len(arr) 
 +	dp = [[0 for i in range(n + 1)] 
 +			for j in range(k + 1)] 
 +	for i in range(1, k + 1): 
 +		for j in range(1, n + 1): 
 +			dp[i][j] = dp[i][j - 1] 
 +			if arr[j - 1] <= i and arr[j - 1] > 0: 
 +				dp[i][j] += dp[i // arr[j - 1]][j - 1] + 1
 +	return dp[k][n]
\ No newline at end of file diff --git a/progs/a874.py b/progs/a874.py new file mode 100644 index 0000000..82ae592 --- /dev/null +++ b/progs/a874.py @@ -0,0 +1,10 @@ +def find_Min_Sum(num): 
 +    sum = 0
 +    i = 2
 +    while(i * i <= num): 
 +        while(num % i == 0): 
 +            sum += i 
 +            num /= i 
 +        i += 1
 +    sum += num 
 +    return sum
\ No newline at end of file diff --git a/progs/a876.py b/progs/a876.py new file mode 100644 index 0000000..234a1f7 --- /dev/null +++ b/progs/a876.py @@ -0,0 +1,3 @@ +def add_str(test_tup, K):
 +  res = [ele for sub in test_tup for ele in (sub, K)]
 +  return (res) 
\ No newline at end of file diff --git a/progs/a877.py b/progs/a877.py new file mode 100644 index 0000000..4d874f4 --- /dev/null +++ b/progs/a877.py @@ -0,0 +1,3 @@ +def sum_elements(test_tup):
 +  res = sum(list(test_tup))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a878.py b/progs/a878.py new file mode 100644 index 0000000..a67f30a --- /dev/null +++ b/progs/a878.py @@ -0,0 +1,17 @@ +def modular_sum(arr, n, m): 
 +	if (n > m): 
 +		return True
 +	DP = [False for i in range(m)] 
 +	for i in range(n): 
 +		if (DP[0]): 
 +			return True
 +		temp = [False for i in range(m)] 
 +		for j in range(m): 
 +			if (DP[j] == True): 
 +				if (DP[(j + arr[i]) % m] == False): 
 +					temp[(j + arr[i]) % m] = True
 +		for j in range(m): 
 +			if (temp[j]): 
 +				DP[j] = True
 +		DP[arr[i] % m] = True
 +	return DP[0]
\ No newline at end of file diff --git a/progs/a88.py b/progs/a88.py new file mode 100644 index 0000000..bb791fd --- /dev/null +++ b/progs/a88.py @@ -0,0 +1,12 @@ +def min_jumps(arr, n):
 +	jumps = [0 for i in range(n)]
 +	if (n == 0) or (arr[0] == 0):
 +		return float('inf')
 +	jumps[0] = 0
 +	for i in range(1, n):
 +		jumps[i] = float('inf')
 +		for j in range(i):
 +			if (i <= j + arr[j]) and (jumps[j] != float('inf')):
 +				jumps[i] = min(jumps[i], jumps[j] + 1)
 +				break
 +	return jumps[n-1]
\ No newline at end of file diff --git a/progs/a880.py b/progs/a880.py new file mode 100644 index 0000000..a2fa0b7 --- /dev/null +++ b/progs/a880.py @@ -0,0 +1,6 @@ +def largest_pos(list1): 
 +    max = list1[0] 
 +    for x in list1: 
 +        if x > max : 
 +             max = x  
 +    return max
\ No newline at end of file diff --git a/progs/a881.py b/progs/a881.py new file mode 100644 index 0000000..5fae891 --- /dev/null +++ b/progs/a881.py @@ -0,0 +1,4 @@ +import math
 +def sqrt_root(num):
 + sqrt_root = math.pow(num, 0.5)
 + return sqrt_root 
\ No newline at end of file diff --git a/progs/a882.py b/progs/a882.py new file mode 100644 index 0000000..ba27baa --- /dev/null +++ b/progs/a882.py @@ -0,0 +1,4 @@ +import math
 +def volume_tetrahedron(num):
 +	volume = (num ** 3 / (6 * math.sqrt(2)))	
 +	return round(volume, 2)
\ No newline at end of file diff --git a/progs/a883.py b/progs/a883.py new file mode 100644 index 0000000..a72df99 --- /dev/null +++ b/progs/a883.py @@ -0,0 +1,22 @@ +def find_lcm(num1, num2): 
 +	if(num1>num2): 
 +		num = num1 
 +		den = num2 
 +	else: 
 +		num = num2 
 +		den = num1 
 +	rem = num % den 
 +	while (rem != 0): 
 +		num = den 
 +		den = rem 
 +		rem = num % den 
 +	gcd = den 
 +	lcm = int(int(num1 * num2)/int(gcd)) 
 +	return lcm 
 +def get_lcm(l):
 +  num1 = l[0]
 +  num2 = l[1]
 +  lcm = find_lcm(num1, num2)
 +  for i in range(2, len(l)):
 +    lcm = find_lcm(lcm, l[i])
 +  return lcm 
\ No newline at end of file diff --git a/progs/a884.py b/progs/a884.py new file mode 100644 index 0000000..39e90e1 --- /dev/null +++ b/progs/a884.py @@ -0,0 +1,5 @@ +def check_isosceles(x,y,z):
 +  if x!=y & y!=z & z!=x:
 +	   return True
 +  else:
 +     return False
\ No newline at end of file diff --git a/progs/a885.py b/progs/a885.py new file mode 100644 index 0000000..578b517 --- /dev/null +++ b/progs/a885.py @@ -0,0 +1,16 @@ +def lbs(arr): 
 +	n = len(arr) 
 +	lis = [1 for i in range(n+1)] 
 +	for i in range(1 , n): 
 +		for j in range(0 , i): 
 +			if ((arr[i] > arr[j]) and (lis[i] < lis[j] +1)): 
 +				lis[i] = lis[j] + 1
 +	lds = [1 for i in range(n+1)] 
 +	for i in reversed(range(n-1)): 
 +		for j in reversed(range(i-1 ,n)): 
 +			if(arr[i] > arr[j] and lds[i] < lds[j] + 1): 
 +				lds[i] = lds[j] + 1
 +	maximum = lis[0] + lds[0] - 1
 +	for i in range(1 , n): 
 +		maximum = max((lis[i] + lds[i]-1), maximum) 
 +	return maximum
\ No newline at end of file diff --git a/progs/a887.py b/progs/a887.py new file mode 100644 index 0000000..9d4965d --- /dev/null +++ b/progs/a887.py @@ -0,0 +1,14 @@ +def max_sum_increasing_subsequence(arr, n): 
 +	max = 0
 +	msis = [0 for x in range(n)] 
 +	for i in range(n): 
 +		msis[i] = arr[i] 
 +	for i in range(1, n): 
 +		for j in range(i): 
 +			if (arr[i] > arr[j] and
 +				msis[i] < msis[j] + arr[i]): 
 +				msis[i] = msis[j] + arr[i] 
 +	for i in range(n): 
 +		if max < msis[i]: 
 +			max = msis[i] 
 +	return max
\ No newline at end of file diff --git a/progs/a888.py b/progs/a888.py new file mode 100644 index 0000000..6332695 --- /dev/null +++ b/progs/a888.py @@ -0,0 +1,2 @@ +def parallel_lines(line1, line2):
 +  return line1[0]/line1[1] == line2[0]/line2[1]
\ No newline at end of file diff --git a/progs/a89.py b/progs/a89.py new file mode 100644 index 0000000..d1cff1d --- /dev/null +++ b/progs/a89.py @@ -0,0 +1,3 @@ +def mul_consecutive_nums(nums):
 +    result = [b*a for a, b in zip(nums[:-1], nums[1:])]
 +    return result
\ No newline at end of file diff --git a/progs/a890.py b/progs/a890.py new file mode 100644 index 0000000..2e9a35a --- /dev/null +++ b/progs/a890.py @@ -0,0 +1,7 @@ +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
\ No newline at end of file diff --git a/progs/a891.py b/progs/a891.py new file mode 100644 index 0000000..87ca1a8 --- /dev/null +++ b/progs/a891.py @@ -0,0 +1,4 @@ +def min_length(list1):
 +   min_length = min(len(x) for x in  list1 )  
 +   min_list = min((x) for x in   list1)
 +   return(min_length, min_list)     
\ No newline at end of file diff --git a/progs/a892.py b/progs/a892.py new file mode 100644 index 0000000..85d0cd6 --- /dev/null +++ b/progs/a892.py @@ -0,0 +1,7 @@ +def jacobsthal_lucas(n): 
 +	dp=[0] * (n + 1) 
 +	dp[0] = 2
 +	dp[1] = 1
 +	for i in range(2, n+1): 
 +		dp[i] = dp[i - 1] + 2 * dp[i - 2]; 
 +	return dp[n]
\ No newline at end of file diff --git a/progs/a893.py b/progs/a893.py new file mode 100644 index 0000000..701f532 --- /dev/null +++ b/progs/a893.py @@ -0,0 +1,10 @@ +from array import array
 +def negative_count(nums):
 +    n = len(nums)
 +    n1 = 0
 +    for x in nums:
 +        if x < 0:
 +            n1 += 1
 +        else:
 +          None
 +    return round(n1/n,2)
\ No newline at end of file diff --git a/progs/a894.py b/progs/a894.py new file mode 100644 index 0000000..b9ddf1d --- /dev/null +++ b/progs/a894.py @@ -0,0 +1,11 @@ +import sys 
 +def min_coins(coins, m, V): 
 +    if (V == 0): 
 +        return 0
 +    res = sys.maxsize 
 +    for i in range(0, m): 
 +        if (coins[i] <= V): 
 +            sub_res = min_coins(coins, m, V-coins[i]) 
 +            if (sub_res != sys.maxsize and sub_res + 1 < res): 
 +                res = sub_res + 1  
 +    return res 
\ No newline at end of file diff --git a/progs/a895.py b/progs/a895.py new file mode 100644 index 0000000..828ccad --- /dev/null +++ b/progs/a895.py @@ -0,0 +1,13 @@ +def check_permutation(str1, str2):
 +  n1=len(str1)
 +  n2=len(str2)
 +  if(n1!=n2):
 +    return False
 +  a=sorted(str1)
 +  str1=" ".join(a)
 +  b=sorted(str2)
 +  str2=" ".join(b)
 +  for i in range(0, n1, 1):
 +    if(str1[i] != str2[i]):
 +      return False
 +  return True
\ No newline at end of file diff --git a/progs/a896.py b/progs/a896.py new file mode 100644 index 0000000..e4022a7 --- /dev/null +++ b/progs/a896.py @@ -0,0 +1,6 @@ +def remove_datatype(test_tuple, data_type):
 +  res = []
 +  for ele in test_tuple:
 +    if not isinstance(ele, data_type):
 +      res.append(ele)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a897.py b/progs/a897.py new file mode 100644 index 0000000..22107cf --- /dev/null +++ b/progs/a897.py @@ -0,0 +1,6 @@ +import re
 +def search_literal(pattern,text):
 + match = re.search(pattern, text)
 + s = match.start()
 + e = match.end()
 + return (s, e)
\ No newline at end of file diff --git a/progs/a898.py b/progs/a898.py new file mode 100644 index 0000000..82d8bbd --- /dev/null +++ b/progs/a898.py @@ -0,0 +1,3 @@ +def topbottom_surfacearea(r):
 +  toporbottomarea=3.1415*r*r
 +  return toporbottomarea
\ No newline at end of file diff --git a/progs/a899.py b/progs/a899.py new file mode 100644 index 0000000..d6a633b --- /dev/null +++ b/progs/a899.py @@ -0,0 +1,2 @@ +def nth_items(list,n):
 + return list[::n]
\ No newline at end of file diff --git a/progs/a9.py b/progs/a9.py new file mode 100644 index 0000000..369c24d --- /dev/null +++ b/progs/a9.py @@ -0,0 +1,2 @@ +def remove_kth_element(list1, L):
 +    return  list1[:L-1] + list1[L:]
\ No newline at end of file diff --git a/progs/a900.py b/progs/a900.py new file mode 100644 index 0000000..8cda224 --- /dev/null +++ b/progs/a900.py @@ -0,0 +1,8 @@ +def first_repeated_word(str1):
 +  temp = set()
 +  for word in str1.split():
 +    if word in temp:
 +      return word;
 +    else:
 +      temp.add(word)
 +  return 'None'
\ No newline at end of file diff --git a/progs/a901.py b/progs/a901.py new file mode 100644 index 0000000..6d1dea5 --- /dev/null +++ b/progs/a901.py @@ -0,0 +1,3 @@ +def string_list_to_tuple(str1):
 +    result = tuple(x for x in str1 if not x.isspace()) 
 +    return result
\ No newline at end of file diff --git a/progs/a902.py b/progs/a902.py new file mode 100644 index 0000000..281b07e --- /dev/null +++ b/progs/a902.py @@ -0,0 +1,3 @@ +def basesnum_coresspondingnum(bases_num,index):
 +  result = list(map(pow, bases_num, index))
 +  return result
\ No newline at end of file diff --git a/progs/a903.py b/progs/a903.py new file mode 100644 index 0000000..c1b164e --- /dev/null +++ b/progs/a903.py @@ -0,0 +1,12 @@ +def find_Diff(arr,n): 
 +    arr.sort()  
 +    count = 0; max_count = 0; min_count = n 
 +    for i in range(0,(n-1)): 
 +        if arr[i] == arr[i + 1]: 
 +            count += 1
 +            continue
 +        else: 
 +            max_count = max(max_count,count) 
 +            min_count = min(min_count,count) 
 +            count = 0
 +    return max_count - min_count 
\ No newline at end of file diff --git a/progs/a904.py b/progs/a904.py new file mode 100644 index 0000000..9c41b60 --- /dev/null +++ b/progs/a904.py @@ -0,0 +1,19 @@ +import math 
 +def get_sum(n): 
 +	sum = 0
 +	i = 1
 +	while i <= (math.sqrt(n)): 
 +		if n%i == 0: 
 +			if n/i == i : 
 +				sum = sum + i 
 +			else: 
 +				sum = sum + i 
 +				sum = sum + (n / i ) 
 +		i = i + 1
 +	sum = sum - n 
 +	return sum
 +def check_abundant(n): 
 +	if (get_sum(n) > n): 
 +		return True
 +	else: 
 +		return False
\ No newline at end of file diff --git a/progs/a905.py b/progs/a905.py new file mode 100644 index 0000000..05efd0f --- /dev/null +++ b/progs/a905.py @@ -0,0 +1,3 @@ +import re
 +def fill_spaces(text):
 +  return (re.sub("[ ,.]", ":", text))
\ No newline at end of file diff --git a/progs/a906.py b/progs/a906.py new file mode 100644 index 0000000..e25ab0c --- /dev/null +++ b/progs/a906.py @@ -0,0 +1,7 @@ +def count_digits(num1,num2):
 +    number=num1+num2
 +    count = 0
 +    while(number > 0):
 +        number = number // 10
 +        count = count + 1
 +    return count
\ No newline at end of file diff --git a/progs/a907.py b/progs/a907.py new file mode 100644 index 0000000..636bfb9 --- /dev/null +++ b/progs/a907.py @@ -0,0 +1,3 @@ +def flatten_tuple(test_list):
 +  res = ' '.join([idx for tup in test_list for idx in tup])
 +  return (res) 
\ No newline at end of file diff --git a/progs/a908.py b/progs/a908.py new file mode 100644 index 0000000..1e3125c --- /dev/null +++ b/progs/a908.py @@ -0,0 +1,11 @@ +def take_L_and_F_set_bits(n) : 
 +    n = n | n >> 1
 +    n = n | n >> 2
 +    n = n | n >> 4
 +    n = n | n >> 8
 +    n = n | n >> 16 
 +    return ((n + 1) >> 1) + 1      
 +def toggle_F_and_L_bits(n) :  
 +    if (n == 1) : 
 +        return 0 
 +    return n ^ take_L_and_F_set_bits(n) 
\ No newline at end of file diff --git a/progs/a909.py b/progs/a909.py new file mode 100644 index 0000000..4eb1d5b --- /dev/null +++ b/progs/a909.py @@ -0,0 +1,9 @@ +def last_occurence_char(string,char):
 + flag = -1
 + for i in range(len(string)):
 +     if(string[i] == char):
 +         flag = i
 + if(flag == -1):
 +    return None
 + else:
 +    return flag + 1
\ No newline at end of file diff --git a/progs/a91.py b/progs/a91.py new file mode 100644 index 0000000..126f04e --- /dev/null +++ b/progs/a91.py @@ -0,0 +1,7 @@ +def last_Two_Digits(N): 
 +    if (N >= 10): 
 +        return
 +    fac = 1
 +    for i in range(1,N + 1): 
 +        fac = (fac * i) % 100
 +    return (fac) 
\ No newline at end of file diff --git a/progs/a910.py b/progs/a910.py new file mode 100644 index 0000000..8485252 --- /dev/null +++ b/progs/a910.py @@ -0,0 +1,7 @@ +def Total_Hamming_Distance(n):   
 +    i = 1
 +    sum = 0
 +    while (n // i > 0):  
 +        sum = sum + n // i  
 +        i = i * 2     
 +    return sum
\ No newline at end of file diff --git a/progs/a911.py b/progs/a911.py new file mode 100644 index 0000000..86552f2 --- /dev/null +++ b/progs/a911.py @@ -0,0 +1,11 @@ +def longest_increasing_subsequence(arr): 
 +	n = len(arr) 
 +	longest_increasing_subsequence = [1]*n 
 +	for i in range (1 , n): 
 +		for j in range(0 , i): 
 +			if arr[i] > arr[j] and longest_increasing_subsequence[i]< longest_increasing_subsequence[j] + 1 : 
 +				longest_increasing_subsequence[i] = longest_increasing_subsequence[j]+1
 +	maximum = 0
 +	for i in range(n): 
 +		maximum = max(maximum , longest_increasing_subsequence[i]) 
 +	return maximum
\ No newline at end of file diff --git a/progs/a912.py b/progs/a912.py new file mode 100644 index 0000000..7484aba --- /dev/null +++ b/progs/a912.py @@ -0,0 +1,7 @@ +def odd_Num_Sum(n) : 
 +    j = 0
 +    sm = 0
 +    for i in range(1,n+1) : 
 +        j = (2*i-1) 
 +        sm = sm + (j*j*j*j*j)     
 +    return sm 
\ No newline at end of file diff --git a/progs/a913.py b/progs/a913.py new file mode 100644 index 0000000..cfa860b --- /dev/null +++ b/progs/a913.py @@ -0,0 +1,14 @@ +def find_Max(arr,low,high): 
 +    if (high < low): 
 +        return arr[0] 
 +    if (high == low): 
 +        return arr[low] 
 +    mid = low + (high - low) // 2 
 +    if (mid < high and arr[mid + 1] < arr[mid]): 
 +        return arr[mid] 
 +    if (mid > low and arr[mid] < arr[mid - 1]): 
 +        return arr[mid - 1]  
 +    if (arr[low] > arr[mid]): 
 +        return find_Max(arr,low,mid - 1) 
 +    else: 
 +        return find_Max(arr,mid + 1,high) 
\ No newline at end of file diff --git a/progs/a914.py b/progs/a914.py new file mode 100644 index 0000000..06b323a --- /dev/null +++ b/progs/a914.py @@ -0,0 +1,3 @@ +def extract_column(list1, n):
 +   result = [i.pop(n) for i in list1]
 +   return result 
\ No newline at end of file diff --git a/progs/a915.py b/progs/a915.py new file mode 100644 index 0000000..6298b31 --- /dev/null +++ b/progs/a915.py @@ -0,0 +1,6 @@ +def Seq_Linear(seq_nums):
 +  seq_nums = [seq_nums[x] - seq_nums[x-1] for x in range(1, len(seq_nums))]
 +  if len(set(seq_nums)) == 1: 
 +    return "Linear Sequence"
 +  else:
 +    return "Non Linear Sequence"
\ No newline at end of file diff --git a/progs/a916.py b/progs/a916.py new file mode 100644 index 0000000..a827408 --- /dev/null +++ b/progs/a916.py @@ -0,0 +1,3 @@ +def tuple_to_float(test_tup):
 +  res = float('.'.join(str(ele) for ele in test_tup))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a917.py b/progs/a917.py new file mode 100644 index 0000000..55abb3b --- /dev/null +++ b/progs/a917.py @@ -0,0 +1,6 @@ +def Split(list): 
 +    od_li = [] 
 +    for i in list: 
 +        if (i % 2 != 0): 
 +            od_li.append(i)  
 +    return od_li
\ No newline at end of file diff --git a/progs/a918.py b/progs/a918.py new file mode 100644 index 0000000..642d76d --- /dev/null +++ b/progs/a918.py @@ -0,0 +1,4 @@ +def difference(n) :  
 +    S = (n*(n + 1))//2;  
 +    res = S*(S-1);  
 +    return res;  
\ No newline at end of file diff --git a/progs/a919.py b/progs/a919.py new file mode 100644 index 0000000..73e1240 --- /dev/null +++ b/progs/a919.py @@ -0,0 +1,7 @@ +def find_Odd_Pair(A,N) : 
 +    oddPair = 0
 +    for i in range(0,N) :  
 +        for j in range(i+1,N) :  
 +            if ((A[i] ^ A[j]) % 2 != 0):  
 +                oddPair+=1  
 +    return oddPair  
\ No newline at end of file diff --git a/progs/a92.py b/progs/a92.py new file mode 100644 index 0000000..bd1ef2f --- /dev/null +++ b/progs/a92.py @@ -0,0 +1,3 @@ +import re
 +def remove_multiple_spaces(text1):
 +  return (re.sub(' +',' ',text1))
\ No newline at end of file diff --git a/progs/a920.py b/progs/a920.py new file mode 100644 index 0000000..514c1fe --- /dev/null +++ b/progs/a920.py @@ -0,0 +1,3 @@ +def toggle_string(string):
 + string1 = string.swapcase()
 + return string1
\ No newline at end of file diff --git a/progs/a921.py b/progs/a921.py new file mode 100644 index 0000000..59ceb7d --- /dev/null +++ b/progs/a921.py @@ -0,0 +1,2 @@ +def digit_distance_nums(n1, n2):
 +         return sum(map(int,str(abs(n1-n2))))
\ No newline at end of file diff --git a/progs/a922.py b/progs/a922.py new file mode 100644 index 0000000..be47e86 --- /dev/null +++ b/progs/a922.py @@ -0,0 +1,10 @@ +def max_sub_array_sum(a, size):
 +  max_so_far = 0
 +  max_ending_here = 0
 +  for i in range(0, size):
 +    max_ending_here = max_ending_here + a[i]
 +    if max_ending_here < 0:
 +      max_ending_here = 0
 +    elif (max_so_far < max_ending_here):
 +      max_so_far = max_ending_here
 +  return max_so_far
\ No newline at end of file diff --git a/progs/a923.py b/progs/a923.py new file mode 100644 index 0000000..51e4841 --- /dev/null +++ b/progs/a923.py @@ -0,0 +1,3 @@ +def union_elements(test_tup1, test_tup2):
 +  res = tuple(set(test_tup1 + test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a924.py b/progs/a924.py new file mode 100644 index 0000000..01596f3 --- /dev/null +++ b/progs/a924.py @@ -0,0 +1,6 @@ +def assign_elements(test_list):
 +  res = dict()
 +  for key, val in test_list:
 +    res.setdefault(val, [])
 +    res.setdefault(key, []).append(val)
 +  return (res) 
\ No newline at end of file diff --git a/progs/a925.py b/progs/a925.py new file mode 100644 index 0000000..bf57154 --- /dev/null +++ b/progs/a925.py @@ -0,0 +1,3 @@ +def Find_Max_Length(lst):  
 +    maxLength = max(len(x) for x in lst )
 +    return maxLength 
\ No newline at end of file diff --git a/progs/a927.py b/progs/a927.py new file mode 100644 index 0000000..062abe0 --- /dev/null +++ b/progs/a927.py @@ -0,0 +1,7 @@ +def count_Pairs(arr,n): 
 +    cnt = 0; 
 +    for i in range(n): 
 +        for j in range(i + 1,n): 
 +            if (arr[i] != arr[j]): 
 +                cnt += 1; 
 +    return cnt; 
\ No newline at end of file diff --git a/progs/a928.py b/progs/a928.py new file mode 100644 index 0000000..0f0980d --- /dev/null +++ b/progs/a928.py @@ -0,0 +1,2 @@ +def split(word): 
 +    return [char for char in word] 
\ No newline at end of file diff --git a/progs/a929.py b/progs/a929.py new file mode 100644 index 0000000..1ae5aa1 --- /dev/null +++ b/progs/a929.py @@ -0,0 +1,5 @@ +def sum_digits(n):
 +  if n == 0:
 +    return 0
 +  else:
 +    return n % 10 + sum_digits(int(n / 10))
\ No newline at end of file diff --git a/progs/a93.py b/progs/a93.py new file mode 100644 index 0000000..5e61a69 --- /dev/null +++ b/progs/a93.py @@ -0,0 +1,3 @@ +def extract_unique(test_dict):
 +  res = list(sorted({ele for val in test_dict.values() for ele in val}))
 +  return res
\ No newline at end of file diff --git a/progs/a930.py b/progs/a930.py new file mode 100644 index 0000000..aa16b87 --- /dev/null +++ b/progs/a930.py @@ -0,0 +1,3 @@ +def issort_list(list1):
 +    result = all(list1[i] <= list1[i+1] for i in range(len(list1)-1))
 +    return result
\ No newline at end of file diff --git a/progs/a932.py b/progs/a932.py new file mode 100644 index 0000000..f6d49b4 --- /dev/null +++ b/progs/a932.py @@ -0,0 +1,3 @@ +def sort_sublists(list1):
 +    result = list(map(sorted,list1)) 
 +    return result
\ No newline at end of file diff --git a/progs/a933.py b/progs/a933.py new file mode 100644 index 0000000..930e0ad --- /dev/null +++ b/progs/a933.py @@ -0,0 +1,6 @@ +def remove_words(list1, charlist):
 +    new_list = []
 +    for line in list1:
 +        new_words = ' '.join([word for word in line.split() if not any([phrase in word for phrase in charlist])])
 +        new_list.append(new_words)
 +    return new_list
\ No newline at end of file diff --git a/progs/a934.py b/progs/a934.py new file mode 100644 index 0000000..8dc5f52 --- /dev/null +++ b/progs/a934.py @@ -0,0 +1,12 @@ +def max_sum_pair_diff_lessthan_K(arr, N, K): 
 +	arr.sort() 
 +	dp = [0] * N 
 +	dp[0] = 0
 +	for i in range(1, N): 
 +		dp[i] = dp[i-1] 
 +		if (arr[i] - arr[i-1] < K): 
 +			if (i >= 2): 
 +				dp[i] = max(dp[i], dp[i-2] + arr[i] + arr[i-1]); 
 +			else: 
 +				dp[i] = max(dp[i], arr[i] + arr[i-1]); 
 +	return dp[N - 1]
\ No newline at end of file diff --git a/progs/a935.py b/progs/a935.py new file mode 100644 index 0000000..d39cc29 --- /dev/null +++ b/progs/a935.py @@ -0,0 +1,2 @@ +def two_unique_nums(nums):
 +  return [i for i in nums if nums.count(i)==1]
\ No newline at end of file diff --git a/progs/a936.py b/progs/a936.py new file mode 100644 index 0000000..1ea3d53 --- /dev/null +++ b/progs/a936.py @@ -0,0 +1,6 @@ +def unique_product(list_data):
 +    temp = list(set(list_data))
 +    p = 1
 +    for i in temp:
 +        p *= i
 +    return p
\ No newline at end of file diff --git a/progs/a937.py b/progs/a937.py new file mode 100644 index 0000000..21c64d0 --- /dev/null +++ b/progs/a937.py @@ -0,0 +1,3 @@ +def surfacearea_cylinder(r,h):
 +  surfacearea=((2*3.1415*r*r) +(2*3.1415*r*h))
 +  return surfacearea
\ No newline at end of file diff --git a/progs/a938.py b/progs/a938.py new file mode 100644 index 0000000..823cea3 --- /dev/null +++ b/progs/a938.py @@ -0,0 +1,8 @@ +def count_no (A,N,L,R): 
 +    count = 0
 +    for i in range (L,R + 1): 
 +        if (i % A != 0): 
 +            count += 1
 +        if (count == N): 
 +            break
 +    return (i) 
\ No newline at end of file diff --git a/progs/a939.py b/progs/a939.py new file mode 100644 index 0000000..74c3463 --- /dev/null +++ b/progs/a939.py @@ -0,0 +1,12 @@ +def is_Sub_Array(A,B,n,m): 
 +    i = 0; j = 0; 
 +    while (i < n and j < m):  
 +        if (A[i] == B[j]): 
 +            i += 1; 
 +            j += 1; 
 +            if (j == m): 
 +                return True;  
 +        else: 
 +            i = i - j + 1; 
 +            j = 0;       
 +    return False; 
\ No newline at end of file diff --git a/progs/a94.py b/progs/a94.py new file mode 100644 index 0000000..60ac0b2 --- /dev/null +++ b/progs/a94.py @@ -0,0 +1,3 @@ +def check_greater(test_tup1, test_tup2):
 +  res = all(x < y for x, y in zip(test_tup1, test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a940.py b/progs/a940.py new file mode 100644 index 0000000..622b2e3 --- /dev/null +++ b/progs/a940.py @@ -0,0 +1,7 @@ +def last_Digit_Factorial(n): 
 +    if (n == 0): return 1
 +    elif (n <= 2): return n  
 +    elif (n == 3): return 6
 +    elif (n == 4): return 4 
 +    else: 
 +      return 0
\ No newline at end of file diff --git a/progs/a941.py b/progs/a941.py new file mode 100644 index 0000000..5e4799d --- /dev/null +++ b/progs/a941.py @@ -0,0 +1,3 @@ +def interleave_lists(list1,list2,list3):
 +    result = [el for pair in zip(list1, list2, list3) for el in pair]
 +    return result
\ No newline at end of file diff --git a/progs/a942.py b/progs/a942.py new file mode 100644 index 0000000..ce686f4 --- /dev/null +++ b/progs/a942.py @@ -0,0 +1,3 @@ +def find_dissimilar(test_tup1, test_tup2):
 +  res = tuple(set(test_tup1) ^ set(test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a944.py b/progs/a944.py new file mode 100644 index 0000000..d3bb480 --- /dev/null +++ b/progs/a944.py @@ -0,0 +1,2 @@ +def surface_Area(b,s): 
 +    return 2 * b * s + pow(b,2) 
\ No newline at end of file diff --git a/progs/a945.py b/progs/a945.py new file mode 100644 index 0000000..e57c4b3 --- /dev/null +++ b/progs/a945.py @@ -0,0 +1,5 @@ +def my_dict(dict1):
 +  if bool(dict1):
 +     return False
 +  else:
 +     return True
\ No newline at end of file diff --git a/progs/a946.py b/progs/a946.py new file mode 100644 index 0000000..cbfdb82 --- /dev/null +++ b/progs/a946.py @@ -0,0 +1,7 @@ +def catalan_number(num):
 +    if num <=1:
 +         return 1   
 +    res_num = 0
 +    for i in range(num):
 +        res_num += catalan_number(i) * catalan_number(num-i-1)
 +    return res_num
\ No newline at end of file diff --git a/progs/a949.py b/progs/a949.py new file mode 100644 index 0000000..b6df617 --- /dev/null +++ b/progs/a949.py @@ -0,0 +1,3 @@ +def split_Arr(a,n,k):  
 +   b = a[:k] 
 +   return (a[k::]+b[::]) 
\ No newline at end of file diff --git a/progs/a95.py b/progs/a95.py new file mode 100644 index 0000000..c8f3c14 --- /dev/null +++ b/progs/a95.py @@ -0,0 +1,3 @@ +def zip_list(list1,list2):  
 + result = list(map(list.__add__, list1, list2)) 
 + return result
\ No newline at end of file diff --git a/progs/a950.py b/progs/a950.py new file mode 100644 index 0000000..a91b10e --- /dev/null +++ b/progs/a950.py @@ -0,0 +1,3 @@ +def list_tuple(listx):
 +  tuplex = tuple(listx)
 +  return tuplex
\ No newline at end of file diff --git a/progs/a951.py b/progs/a951.py new file mode 100644 index 0000000..ab1e4c9 --- /dev/null +++ b/progs/a951.py @@ -0,0 +1,3 @@ +def big_diff(nums):
 +     diff= max(nums)-min(nums)
 +     return diff
\ No newline at end of file diff --git a/progs/a952.py b/progs/a952.py new file mode 100644 index 0000000..b2fcd03 --- /dev/null +++ b/progs/a952.py @@ -0,0 +1,10 @@ +def perfect_squares(a, b):
 +    lists=[]
 +    for i in range (a,b+1):
 +        j = 1;
 +        while j*j <= i:
 +            if j*j == i:
 +                 lists.append(i)  
 +            j = j+1
 +        i = i+1
 +    return lists
\ No newline at end of file diff --git a/progs/a953.py b/progs/a953.py new file mode 100644 index 0000000..fd6c8bd --- /dev/null +++ b/progs/a953.py @@ -0,0 +1,6 @@ +import cmath
 +def polar_rect(x,y):
 + cn = complex(x,y)
 + cn=cmath.polar(cn)
 + cn1 = cmath.rect(2, cmath.pi)
 + return (cn,cn1)
\ No newline at end of file diff --git a/progs/a954.py b/progs/a954.py new file mode 100644 index 0000000..78b3aa1 --- /dev/null +++ b/progs/a954.py @@ -0,0 +1,6 @@ +def swap_List(newList): 
 +    size = len(newList) 
 +    temp = newList[0] 
 +    newList[0] = newList[size - 1] 
 +    newList[size - 1] = temp  
 +    return newList 
\ No newline at end of file diff --git a/progs/a955.py b/progs/a955.py new file mode 100644 index 0000000..ac920a1 --- /dev/null +++ b/progs/a955.py @@ -0,0 +1,9 @@ +def binomial_Coeff(n,k): 
 +    C = [0] * (k + 1); 
 +    C[0] = 1; # nC0 is 1 
 +    for i in range(1,n + 1):  
 +        for j in range(min(i, k),0,-1): 
 +            C[j] = C[j] + C[j - 1]; 
 +    return C[k]; 
 +def sum_Of_product(n): 
 +    return binomial_Coeff(2 * n,n - 1); 
\ No newline at end of file diff --git a/progs/a956.py b/progs/a956.py new file mode 100644 index 0000000..dc88b37 --- /dev/null +++ b/progs/a956.py @@ -0,0 +1,4 @@ +import re
 +def removezero_ip(ip):
 + string = re.sub('\.[0]*', '.', ip)
 + return string
\ No newline at end of file diff --git a/progs/a957.py b/progs/a957.py new file mode 100644 index 0000000..0ef3c43 --- /dev/null +++ b/progs/a957.py @@ -0,0 +1,4 @@ +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)
\ No newline at end of file diff --git a/progs/a958.py b/progs/a958.py new file mode 100644 index 0000000..5982297 --- /dev/null +++ b/progs/a958.py @@ -0,0 +1,9 @@ +def min_Swaps(str1,str2) : 
 +    count = 0
 +    for i in range(len(str1)) :  
 +        if str1[i] != str2[i] : 
 +            count += 1
 +    if count % 2 == 0 : 
 +        return (count // 2) 
 +    else : 
 +        return ("Not Possible") 
\ No newline at end of file diff --git a/progs/a959.py b/progs/a959.py new file mode 100644 index 0000000..909ef0a --- /dev/null +++ b/progs/a959.py @@ -0,0 +1,3 @@ +import sys 
 +def tuple_size(tuple_list):
 +  return (sys.getsizeof(tuple_list)) 
\ No newline at end of file diff --git a/progs/a960.py b/progs/a960.py new file mode 100644 index 0000000..1e4960e --- /dev/null +++ b/progs/a960.py @@ -0,0 +1,22 @@ +def find_kth(arr1, arr2, m, n, k):
 +	sorted1 = [0] * (m + n)
 +	i = 0
 +	j = 0
 +	d = 0
 +	while (i < m and j < n):
 +		if (arr1[i] < arr2[j]):
 +			sorted1[d] = arr1[i]
 +			i += 1
 +		else:
 +			sorted1[d] = arr2[j]
 +			j += 1
 +		d += 1
 +	while (i < m):
 +		sorted1[d] = arr1[i]
 +		d += 1
 +		i += 1
 +	while (j < n):
 +		sorted1[d] = arr2[j]
 +		d += 1
 +		j += 1
 +	return sorted1[k - 1]
\ No newline at end of file diff --git a/progs/a961.py b/progs/a961.py new file mode 100644 index 0000000..9ad773a --- /dev/null +++ b/progs/a961.py @@ -0,0 +1,16 @@ +def armstrong_number(number):
 + sum = 0
 + times = 0
 + temp = number
 + while temp > 0:
 +           times = times + 1
 +           temp = temp // 10
 + temp = number
 + while temp > 0:
 +           reminder = temp % 10
 +           sum = sum + (reminder ** times)
 +           temp //= 10
 + if number == sum:
 +           return True
 + else:
 +           return False
\ No newline at end of file diff --git a/progs/a962.py b/progs/a962.py new file mode 100644 index 0000000..42c3f53 --- /dev/null +++ b/progs/a962.py @@ -0,0 +1,6 @@ +def sum_average(number):
 + total = 0
 + for value in range(1, number + 1):
 +    total = total + value
 + average = total / number
 + return (total,average)
\ No newline at end of file diff --git a/progs/a963.py b/progs/a963.py new file mode 100644 index 0000000..fe68ad4 --- /dev/null +++ b/progs/a963.py @@ -0,0 +1,5 @@ +def is_Even(n) : 
 +    if (n^1 == n+1) :
 +        return True; 
 +    else :
 +        return False; 
\ No newline at end of file diff --git a/progs/a964.py b/progs/a964.py new file mode 100644 index 0000000..0fbe808 --- /dev/null +++ b/progs/a964.py @@ -0,0 +1,13 @@ +R = 3
 +C = 3
 +def min_cost(cost, m, n): 
 +	tc = [[0 for x in range(C)] for x in range(R)] 
 +	tc[0][0] = cost[0][0] 
 +	for i in range(1, m+1): 
 +		tc[i][0] = tc[i-1][0] + cost[i][0] 
 +	for j in range(1, n+1): 
 +		tc[0][j] = tc[0][j-1] + cost[0][j] 
 +	for i in range(1, m+1): 
 +		for j in range(1, n+1): 
 +			tc[i][j] = min(tc[i-1][j-1], tc[i-1][j], tc[i][j-1]) + cost[i][j] 
 +	return tc[m][n]
\ No newline at end of file diff --git a/progs/a965.py b/progs/a965.py new file mode 100644 index 0000000..7c79c26 --- /dev/null +++ b/progs/a965.py @@ -0,0 +1,3 @@ +def similar_elements(test_tup1, test_tup2):
 +  res = tuple(set(test_tup1) & set(test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/a966.py b/progs/a966.py new file mode 100644 index 0000000..2e036ee --- /dev/null +++ b/progs/a966.py @@ -0,0 +1,7 @@ +import math
 +def is_not_prime(n):
 +    result = False
 +    for i in range(2,int(math.sqrt(n)) + 1):
 +        if n % i == 0:
 +            result = True
 +    return result
\ No newline at end of file diff --git a/progs/a967.py b/progs/a967.py new file mode 100644 index 0000000..e5909eb --- /dev/null +++ b/progs/a967.py @@ -0,0 +1,4 @@ +import heapq as hq
 +def heap_queue_largest(nums,n):
 +  largest_nums = hq.nlargest(n, nums)
 +  return largest_nums
\ No newline at end of file diff --git a/progs/a968.py b/progs/a968.py new file mode 100644 index 0000000..5a0b8f1 --- /dev/null +++ b/progs/a968.py @@ -0,0 +1,11 @@ +def count_ways(n): 
 +	A = [0] * (n + 1) 
 +	B = [0] * (n + 1) 
 +	A[0] = 1
 +	A[1] = 0
 +	B[0] = 0
 +	B[1] = 1
 +	for i in range(2, n+1): 
 +		A[i] = A[i - 2] + 2 * B[i - 1] 
 +		B[i] = A[i - 1] + B[i - 2] 
 +	return A[n] 
\ No newline at end of file diff --git a/progs/a969.py b/progs/a969.py new file mode 100644 index 0000000..5bbd674 --- /dev/null +++ b/progs/a969.py @@ -0,0 +1,4 @@ +def is_Power_Of_Two (x): 
 +    return x and (not(x & (x - 1))) 
 +def differ_At_One_Bit_Pos(a,b): 
 +    return is_Power_Of_Two(a ^ b)
\ No newline at end of file diff --git a/progs/a972.py b/progs/a972.py new file mode 100644 index 0000000..b158656 --- /dev/null +++ b/progs/a972.py @@ -0,0 +1,8 @@ +def find_Rotations(str): 
 +    tmp = str + str
 +    n = len(str) 
 +    for i in range(1,n + 1): 
 +        substring = tmp[i: i+n] 
 +        if (str == substring): 
 +            return i 
 +    return n 
\ No newline at end of file diff --git a/progs/a973.py b/progs/a973.py new file mode 100644 index 0000000..bc45bf4 --- /dev/null +++ b/progs/a973.py @@ -0,0 +1,4 @@ +import heapq
 +def small_nnum(list1,n):
 +  smallest=heapq.nsmallest(n,list1)
 +  return smallest
\ No newline at end of file diff --git a/progs/a98.py b/progs/a98.py new file mode 100644 index 0000000..96d6db0 --- /dev/null +++ b/progs/a98.py @@ -0,0 +1,9 @@ +def min_Swaps(str1,str2) : 
 +    count = 0
 +    for i in range(len(str1)) : 
 +        if str1[i] != str2[i] : 
 +            count += 1
 +    if count % 2 == 0 : 
 +        return (count // 2) 
 +    else : 
 +        return ("Not Possible") 
\ No newline at end of file diff --git a/progs/a99.py b/progs/a99.py new file mode 100644 index 0000000..9a4585f --- /dev/null +++ b/progs/a99.py @@ -0,0 +1,6 @@ +def count_range_in_list(li, min, max):
 +	ctr = 0
 +	for x in li:
 +		if min <= x <= max:
 +			ctr += 1
 +	return ctr
\ No newline at end of file diff --git a/progs/bunch_of_tests b/progs/bunch_of_tests new file mode 100644 index 0000000..b001761 --- /dev/null +++ b/progs/bunch_of_tests @@ -0,0 +1,101 @@ +def coin_change(S, m, n): +    table = [[0 for x in range(m)] for x in range(n+1)] +    for i in range(m): +        table[0][i] = 1 +    for i in range(1, n+1): +        for j in range(m): +            x = table[i - S[j]][j] if i-S[j] >= 0 else 0 +            y = table[i][j-1] if j >= 1 else 0 +            table[i][j] = x + y +    return table[n][m-1] + +================ +import re +def text_match_wordz_middle(text): +    patterns = '\Bz\B' +    if re.search(patterns, text): +        return 'Found a match!' +    else: +        return('Not matched!') +text_match_wordz_middle('ciao') + +============== + +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 + +================ + +def sort_matrix(M): +    result = sorted(M, key=sum) +    return result + +================= + +def get_ludic(n): +    ludics = [] +    for i in range(1, n + 1): +        ludics.append(i) +    return ludics +print(get_ludic(a*a)) + +================= + +def adjac(ele, sub = []): +    if not ele: +        yield sub +    else: +        yield from [ idx for j in range(ele[0] - 1, ele[0] + 2) +                     for idx in adjac(ele[1:], sub + [j]) +                   ] + +def get_coordinates(test_tup): +    res = list(adjac(test_tup)) +    return (res) + +=================== + +import heapq +def heap_sort(iterable): +    h = [] +    for value in iterable: +        heapq.heappush(h, value) +    return [hq.heappop(h) for i in range(len(h))] + + +====================== + +def get_ludic(n): +    ludics = [] +    for i in range(1, n + 1): +        ludics.append(i) +        index = 1 +        while(index != len(ludics)): +            first_ludic = ludics[index] +            remove_index = index + first_ludic +            while(remove_index < len(ludics)): +                ludics.remove(ludics[remove_index]) +                remove_index = remove_index + first_ludic - 1 +            index += 1 +    return ludics +print(get_ludic(a*a)) + +============================ + +from collections import defaultdict +def get_unique(test_list): +  res = defaultdict(list) +  for sub in test_list: +    res[sub[1]].append(sub[0]) +  res = dict(res) +  res_dict = dict() +  for key in res: +    res_dict[key] = len(list(set(res[key]))) +  return (str(res_dict))
\ No newline at end of file diff --git a/progs/dont_care/a0.py b/progs/dont_care/a0.py new file mode 100644 index 0000000..623045c --- /dev/null +++ b/progs/dont_care/a0.py @@ -0,0 +1,16 @@ +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
\ No newline at end of file diff --git a/progs/dont_care/a242.py b/progs/dont_care/a242.py new file mode 100644 index 0000000..dc0ceec --- /dev/null +++ b/progs/dont_care/a242.py @@ -0,0 +1,12 @@ +import heapq
 +def nth_super_ugly_number(n, primes):
 +    uglies = [1]
 +    def gen(prime):
 +        for ugly in uglies:
 +            yield ugly * prime
 +    merged = heapq.merge(*map(gen, primes))
 +    while len(uglies) < n:
 +        ugly = next(merged)
 +        if ugly != uglies[-1]:
 +            uglies.append(ugly)
 +    return uglies[-1]
\ No newline at end of file diff --git a/progs/dont_care/a29.py b/progs/dont_care/a29.py new file mode 100644 index 0000000..c5f976c --- /dev/null +++ b/progs/dont_care/a29.py @@ -0,0 +1,9 @@ +def adjac(ele, sub = []): 
 +  if not ele: 
 +     yield sub 
 +  else: 
 +     yield from [idx for j in range(ele[0] - 1, ele[0] + 2) 
 +                for idx in adjac(ele[1:], sub + [j])] 
 +def get_coordinates(test_tup):
 +  res = list(adjac(test_tup))
 +  return (res) 
\ No newline at end of file diff --git a/progs/dont_care/a309.py b/progs/dont_care/a309.py new file mode 100644 index 0000000..84b0ac2 --- /dev/null +++ b/progs/dont_care/a309.py @@ -0,0 +1,8 @@ +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
\ No newline at end of file diff --git a/progs/dont_care/a326.py b/progs/dont_care/a326.py new file mode 100644 index 0000000..8eeddd2 --- /dev/null +++ b/progs/dont_care/a326.py @@ -0,0 +1,15 @@ +class Node: 
 +	def __init__(self, data): 
 +		self.data = data 
 +		self.left = None
 +		self.right = None
 +def max_height(node): 
 +	if node is None: 
 +		return 0 ; 
 +	else : 
 +		left_height = max_height(node.left) 
 +		right_height = max_height(node.right) 
 +		if (left_height > right_height): 
 +			return left_height+1
 +		else: 
 +			return right_height+1
\ No newline at end of file diff --git a/progs/dont_care/a730.py b/progs/dont_care/a730.py new file mode 100644 index 0000000..ba741d2 --- /dev/null +++ b/progs/dont_care/a730.py @@ -0,0 +1,18 @@ +class Node: 
 +	def __init__(self, data): 
 +		self.data = data 
 +		self.left = None
 +		self.right = None
 +def get_height(root): 
 +	if root is None: 
 +		return 0
 +	return max(get_height(root.left), get_height(root.right)) + 1
 +def is_tree_balanced(root): 
 +	if root is None: 
 +		return True
 +	lh = get_height(root.left) 
 +	rh = get_height(root.right) 
 +	if (abs(lh - rh) <= 1) and is_tree_balanced( 
 +	root.left) is True and is_tree_balanced( root.right) is True: 
 +		return True
 +	return False
\ No newline at end of file diff --git a/progs/dont_care/a780.py b/progs/dont_care/a780.py new file mode 100644 index 0000000..e84f8ee --- /dev/null +++ b/progs/dont_care/a780.py @@ -0,0 +1,8 @@ +def group_tuples(Input): 
 +	out = {} 
 +	for elem in Input: 
 +		try: 
 +			out[elem[0]].extend(elem[1:]) 
 +		except KeyError: 
 +			out[elem[0]] = list(elem) 
 +	return [tuple(values) for values in out.values()] 
\ No newline at end of file diff --git a/progs/dont_care/a789.py b/progs/dont_care/a789.py new file mode 100644 index 0000000..06bda85 --- /dev/null +++ b/progs/dont_care/a789.py @@ -0,0 +1,3 @@ +def filter_oddnumbers(nums):
 + odd_nums = list(filter(lambda x: x%2 != 0, nums))
 + return odd_nums
\ No newline at end of file diff --git a/progs/dont_care/a875.py b/progs/dont_care/a875.py new file mode 100644 index 0000000..9bf97cf --- /dev/null +++ b/progs/dont_care/a875.py @@ -0,0 +1,13 @@ +def flatten(test_tuple): 
 +	for tup in test_tuple: 
 +		if isinstance(tup, tuple): 
 +			yield from flatten(tup) 
 +		else: 
 +			yield tup 
 +def count_element_freq(test_tuple):
 +  res = {}
 +  for ele in flatten(test_tuple):
 +    if ele not in res:
 +      res[ele] = 0
 +    res[ele] += 1
 +  return (res) 
\ No newline at end of file diff --git a/progs/ludic.py b/progs/ludic.py new file mode 100644 index 0000000..b5c7373 --- /dev/null +++ b/progs/ludic.py @@ -0,0 +1,6 @@ +def get_ludic(n): +    ludics = [] +    for i in range(1, n + 1): +        ludics.append(i) +    return ludics +print(get_ludic(a*a)) diff --git a/progs/test.py b/progs/test.py new file mode 100644 index 0000000..f168c9b --- /dev/null +++ b/progs/test.py @@ -0,0 +1,12 @@ +def find_first_duplicate(nums): +    num_set = set() +    no_duplicate = -1 + +    for i in range(len(nums)): + +        if nums[i] in num_set: +            return nums[i] +        else: +            num_set.add(nums[i]) + +    return no_duplicate
\ No newline at end of file diff --git a/progs/unparsable_programs/a11.py b/progs/unparsable_programs/a11.py new file mode 100644 index 0000000..722957f --- /dev/null +++ b/progs/unparsable_programs/a11.py @@ -0,0 +1,2 @@ +def merge(lst):  
 +    return [list(ele) for ele in list(zip(*lst))] 
\ No newline at end of file diff --git a/progs/unparsable_programs/a111.py b/progs/unparsable_programs/a111.py new file mode 100644 index 0000000..1123d7e --- /dev/null +++ b/progs/unparsable_programs/a111.py @@ -0,0 +1,5 @@ +import itertools
 +def remove_duplicate(list1):
 + list.sort(list1)
 + remove_duplicate = list(list1 for list1,_ in itertools.groupby(list1))
 + return remove_duplicate
\ No newline at end of file diff --git a/progs/unparsable_programs/a112.py b/progs/unparsable_programs/a112.py new file mode 100644 index 0000000..bb98f8e --- /dev/null +++ b/progs/unparsable_programs/a112.py @@ -0,0 +1,3 @@ +def check_valid(test_tup):
 +  res = not any(map(lambda ele: not ele, test_tup))
 +  return (res) 
\ No newline at end of file diff --git a/progs/unparsable_programs/a121.py b/progs/unparsable_programs/a121.py new file mode 100644 index 0000000..e4cd66d --- /dev/null +++ b/progs/unparsable_programs/a121.py @@ -0,0 +1,3 @@ +def filter_data(students,h,w):
 +    result = {k: s for k, s in students.items() if s[0] >=h and s[1] >=w}
 +    return result    
\ No newline at end of file diff --git a/progs/unparsable_programs/a124.py b/progs/unparsable_programs/a124.py new file mode 100644 index 0000000..594eef8 --- /dev/null +++ b/progs/unparsable_programs/a124.py @@ -0,0 +1,3 @@ +import re
 +def extract_quotation(text1):
 +  return (re.findall(r'"(.*?)"', text1))
\ No newline at end of file diff --git a/progs/unparsable_programs/a128.py b/progs/unparsable_programs/a128.py new file mode 100644 index 0000000..92e302f --- /dev/null +++ b/progs/unparsable_programs/a128.py @@ -0,0 +1,3 @@ +def add_list(nums1,nums2):
 +  result = map(lambda x, y: x + y, nums1, nums2)
 +  return list(result)
\ No newline at end of file diff --git a/progs/unparsable_programs/a14.py b/progs/unparsable_programs/a14.py new file mode 100644 index 0000000..c55f031 --- /dev/null +++ b/progs/unparsable_programs/a14.py @@ -0,0 +1,3 @@ +def average_tuple(nums):
 +    result = [sum(x) / len(x) for x in zip(*nums)]
 +    return result
\ No newline at end of file diff --git a/progs/unparsable_programs/a143.py b/progs/unparsable_programs/a143.py new file mode 100644 index 0000000..530261a --- /dev/null +++ b/progs/unparsable_programs/a143.py @@ -0,0 +1,3 @@ +def check_none(test_tup):
 +  res = any(map(lambda ele: ele is None, test_tup))
 +  return (res) 
\ No newline at end of file diff --git a/progs/unparsable_programs/a144.py b/progs/unparsable_programs/a144.py new file mode 100644 index 0000000..7342998 --- /dev/null +++ b/progs/unparsable_programs/a144.py @@ -0,0 +1,3 @@ +def divisible_by_digits(startnum, endnum):
 +    return [n for n in range(startnum, endnum+1) \
 +                if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]
\ No newline at end of file diff --git a/progs/unparsable_programs/a147.py b/progs/unparsable_programs/a147.py new file mode 100644 index 0000000..1645073 --- /dev/null +++ b/progs/unparsable_programs/a147.py @@ -0,0 +1,3 @@ +import re
 +def capital_words_spaces(str1):
 +  return re.sub(r"(\w)([A-Z])", r"\1 \2", str1)
\ No newline at end of file diff --git a/progs/unparsable_programs/a152.py b/progs/unparsable_programs/a152.py new file mode 100644 index 0000000..a7a582a --- /dev/null +++ b/progs/unparsable_programs/a152.py @@ -0,0 +1,3 @@ +def min_k(test_list, K):
 +  res = sorted(test_list, key = lambda x: x[1])[:K]
 +  return (res) 
\ No newline at end of file diff --git a/progs/unparsable_programs/a158.py b/progs/unparsable_programs/a158.py new file mode 100644 index 0000000..6e5fda0 --- /dev/null +++ b/progs/unparsable_programs/a158.py @@ -0,0 +1,5 @@ +def is_decimal(num):
 +    import re
 +    dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""")
 +    result = dnumre.search(num)
 +    return bool(result)
\ No newline at end of file diff --git a/progs/unparsable_programs/a17.py b/progs/unparsable_programs/a17.py new file mode 100644 index 0000000..47b8e06 --- /dev/null +++ b/progs/unparsable_programs/a17.py @@ -0,0 +1,3 @@ +def div_list(nums1,nums2):
 +  result = map(lambda x, y: x / y, nums1, nums2)
 +  return list(result)
\ No newline at end of file diff --git a/progs/unparsable_programs/a194.py b/progs/unparsable_programs/a194.py new file mode 100644 index 0000000..7574268 --- /dev/null +++ b/progs/unparsable_programs/a194.py @@ -0,0 +1,4 @@ +import heapq
 +def cheap_items(items,n):
 +  cheap_items = heapq.nsmallest(n, items, key=lambda s: s['price'])
 +  return cheap_items
\ No newline at end of file diff --git a/progs/unparsable_programs/a199.py b/progs/unparsable_programs/a199.py new file mode 100644 index 0000000..6cf5bd1 --- /dev/null +++ b/progs/unparsable_programs/a199.py @@ -0,0 +1,3 @@ +import re
 +def remove_all_spaces(text):
 + return (re.sub(r'\s+', '',text))
\ No newline at end of file diff --git a/progs/unparsable_programs/a216.py b/progs/unparsable_programs/a216.py new file mode 100644 index 0000000..658d48f --- /dev/null +++ b/progs/unparsable_programs/a216.py @@ -0,0 +1,3 @@ +def div_of_nums(nums,m,n):
 + result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums)) 
 + return result
\ No newline at end of file diff --git a/progs/unparsable_programs/a22.py b/progs/unparsable_programs/a22.py new file mode 100644 index 0000000..9209e85 --- /dev/null +++ b/progs/unparsable_programs/a22.py @@ -0,0 +1,3 @@ +def nth_nums(nums,n):
 + nth_nums = list(map(lambda x: x ** n, nums))
 + return nth_nums
\ No newline at end of file diff --git a/progs/unparsable_programs/a227.py b/progs/unparsable_programs/a227.py new file mode 100644 index 0000000..0143995 --- /dev/null +++ b/progs/unparsable_programs/a227.py @@ -0,0 +1,10 @@ +def count_alpha_dig_spl(string):
 +  alphabets=digits = special = 0
 +  for i in range(len(string)):
 +    if(string[i].isalpha()):
 +        alphabets = alphabets + 1
 +    elif(string[i].isdigit()):
 +        digits = digits + 1
 +    else:
 +        special = special + 1
 +  return (alphabets,digits,special)   
\ No newline at end of file diff --git a/progs/unparsable_programs/a260.py b/progs/unparsable_programs/a260.py new file mode 100644 index 0000000..cc6721a --- /dev/null +++ b/progs/unparsable_programs/a260.py @@ -0,0 +1,4 @@ +from collections import Counter 
 +def anagram_lambda(texts,str):
 +  result = list(filter(lambda x: (Counter(str) == Counter(x)), texts)) 
 +  return result
\ No newline at end of file diff --git a/progs/unparsable_programs/a263.py b/progs/unparsable_programs/a263.py new file mode 100644 index 0000000..0f71a0c --- /dev/null +++ b/progs/unparsable_programs/a263.py @@ -0,0 +1,3 @@ +def palindrome_lambda(texts):
 +  result = list(filter(lambda x: (x == "".join(reversed(x))), texts))
 +  return result
\ No newline at end of file diff --git a/progs/unparsable_programs/a264.py b/progs/unparsable_programs/a264.py new file mode 100644 index 0000000..e8036ea --- /dev/null +++ b/progs/unparsable_programs/a264.py @@ -0,0 +1,3 @@ +def ntimes_list(nums,n):
 +    result = map(lambda x:n*x, nums) 
 +    return list(result)
\ No newline at end of file diff --git a/progs/unparsable_programs/a269.py b/progs/unparsable_programs/a269.py new file mode 100644 index 0000000..cf1e2f5 --- /dev/null +++ b/progs/unparsable_programs/a269.py @@ -0,0 +1,3 @@ +def sum_positivenum(nums):
 +  sum_positivenum = list(filter(lambda nums:nums>0,nums))
 +  return sum(sum_positivenum)
\ No newline at end of file diff --git a/progs/unparsable_programs/a282.py b/progs/unparsable_programs/a282.py new file mode 100644 index 0000000..d336e30 --- /dev/null +++ b/progs/unparsable_programs/a282.py @@ -0,0 +1,3 @@ +def div_of_nums(nums,m,n):
 + result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums)) 
 + return result
\ No newline at end of file diff --git a/progs/unparsable_programs/a299.py b/progs/unparsable_programs/a299.py new file mode 100644 index 0000000..a217c0d --- /dev/null +++ b/progs/unparsable_programs/a299.py @@ -0,0 +1,7 @@ +import re
 +def match_num(string):
 +    text = re.compile(r"^5")
 +    if text.match(string):
 +        return True
 +    else:
 +        return False
\ No newline at end of file diff --git a/progs/unparsable_programs/a305.py b/progs/unparsable_programs/a305.py new file mode 100644 index 0000000..a438797 --- /dev/null +++ b/progs/unparsable_programs/a305.py @@ -0,0 +1,3 @@ +import re
 +def extract_date(url):
 +        return re.findall(r'/(\d{4})/(\d{1,2})/(\d{1,2})/', url)
\ No newline at end of file diff --git a/progs/unparsable_programs/a312.py b/progs/unparsable_programs/a312.py new file mode 100644 index 0000000..daf00bc --- /dev/null +++ b/progs/unparsable_programs/a312.py @@ -0,0 +1,7 @@ +import re
 +def end_num(string):
 +    text = re.compile(r".*[0-9]$")
 +    if text.match(string):
 +        return True
 +    else:
 +        return False
\ No newline at end of file diff --git a/progs/unparsable_programs/a314.py b/progs/unparsable_programs/a314.py new file mode 100644 index 0000000..db3d448 --- /dev/null +++ b/progs/unparsable_programs/a314.py @@ -0,0 +1,3 @@ +def rearrange_numbs(array_nums):
 +  result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)
 +  return result 
\ No newline at end of file diff --git a/progs/unparsable_programs/a327.py b/progs/unparsable_programs/a327.py new file mode 100644 index 0000000..f3946d3 --- /dev/null +++ b/progs/unparsable_programs/a327.py @@ -0,0 +1,4 @@ +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)
\ No newline at end of file diff --git a/progs/unparsable_programs/a332.py b/progs/unparsable_programs/a332.py new file mode 100644 index 0000000..dffadb2 --- /dev/null +++ b/progs/unparsable_programs/a332.py @@ -0,0 +1,4 @@ +import re
 +def camel_to_snake(text):
 +  str1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
 +  return re.sub('([a-z0-9])([A-Z])', r'\1_\2', str1).lower()
\ No newline at end of file diff --git a/progs/unparsable_programs/a338.py b/progs/unparsable_programs/a338.py new file mode 100644 index 0000000..cf007ed --- /dev/null +++ b/progs/unparsable_programs/a338.py @@ -0,0 +1,3 @@ +def sorted_models(models):
 + sorted_models = sorted(models, key = lambda x: x['color'])
 + return sorted_models
\ No newline at end of file diff --git a/progs/unparsable_programs/a357.py b/progs/unparsable_programs/a357.py new file mode 100644 index 0000000..54444b2 --- /dev/null +++ b/progs/unparsable_programs/a357.py @@ -0,0 +1,11 @@ +def int_to_roman( num):
 +        val = [1000, 900, 500, 400,100, 90, 50, 40,10, 9, 5, 4,1]
 +        syb = ["M", "CM", "D", "CD","C", "XC", "L", "XL","X", "IX", "V", "IV","I"]
 +        roman_num = ''
 +        i = 0
 +        while  num > 0:
 +            for _ in range(num // val[i]):
 +                roman_num += syb[i]
 +                num -= val[i]
 +            i += 1
 +        return roman_num
\ No newline at end of file diff --git a/progs/unparsable_programs/a360.py b/progs/unparsable_programs/a360.py new file mode 100644 index 0000000..f1ee86e --- /dev/null +++ b/progs/unparsable_programs/a360.py @@ -0,0 +1,9 @@ +def roman_to_int(s):
 +        rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
 +        int_val = 0
 +        for i in range(len(s)):
 +            if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]:
 +                int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]]
 +            else:
 +                int_val += rom_val[s[i]]
 +        return int_val
\ No newline at end of file diff --git a/progs/unparsable_programs/a364.py b/progs/unparsable_programs/a364.py new file mode 100644 index 0000000..42188d1 --- /dev/null +++ b/progs/unparsable_programs/a364.py @@ -0,0 +1,4 @@ +def camel_to_snake(text):
 +        import re
 +        str1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
 +        return re.sub('([a-z0-9])([A-Z])', r'\1_\2', str1).lower()
\ No newline at end of file diff --git a/progs/unparsable_programs/a38.py b/progs/unparsable_programs/a38.py new file mode 100644 index 0000000..40a99f5 --- /dev/null +++ b/progs/unparsable_programs/a38.py @@ -0,0 +1,3 @@ +def sample_nam(sample_names):
 +  sample_names=list(filter(lambda el:el[0].isupper() and el[1:].islower(),sample_names))
 +  return len(''.join(sample_names))
\ No newline at end of file diff --git a/progs/unparsable_programs/a39.py b/progs/unparsable_programs/a39.py new file mode 100644 index 0000000..36fc17a --- /dev/null +++ b/progs/unparsable_programs/a39.py @@ -0,0 +1,4 @@ +import re
 +def remove_parenthesis(items):
 + for item in items:
 +    return (re.sub(r" ?\([^)]+\)", "", item))
\ No newline at end of file diff --git a/progs/unparsable_programs/a404.py b/progs/unparsable_programs/a404.py new file mode 100644 index 0000000..ef8b757 --- /dev/null +++ b/progs/unparsable_programs/a404.py @@ -0,0 +1,3 @@ +def filter_evennumbers(nums):
 + even_nums = list(filter(lambda x: x%2 == 0, nums))
 + return even_nums
\ No newline at end of file diff --git a/progs/unparsable_programs/a412.py b/progs/unparsable_programs/a412.py new file mode 100644 index 0000000..0c94e06 --- /dev/null +++ b/progs/unparsable_programs/a412.py @@ -0,0 +1,4 @@ +def specified_element(nums, N):
 +    result = [i[N] for i in nums]
 +    return result
 +    
\ No newline at end of file diff --git a/progs/unparsable_programs/a413.py b/progs/unparsable_programs/a413.py new file mode 100644 index 0000000..2c2214e --- /dev/null +++ b/progs/unparsable_programs/a413.py @@ -0,0 +1,4 @@ +def min_length_list(input_list):
 +    min_length = min(len(x) for x in input_list )  
 +    min_list = min(input_list, key = lambda i: len(i))
 +    return(min_length, min_list)
\ No newline at end of file diff --git a/progs/unparsable_programs/a424.py b/progs/unparsable_programs/a424.py new file mode 100644 index 0000000..fb15cae --- /dev/null +++ b/progs/unparsable_programs/a424.py @@ -0,0 +1,10 @@ +from collections import defaultdict
 +def count_Substrings(s,n):
 +    count,sum = 0,0
 +    mp = defaultdict(lambda : 0)
 +    mp[0] += 1
 +    for i in range(n):
 +        sum += ord(s[i]) - ord('0')
 +        count += mp[sum - (i + 1)]
 +        mp[sum - (i + 1)] += 1
 +    return count
\ No newline at end of file diff --git a/progs/unparsable_programs/a427.py b/progs/unparsable_programs/a427.py new file mode 100644 index 0000000..07f0dc5 --- /dev/null +++ b/progs/unparsable_programs/a427.py @@ -0,0 +1,4 @@ +def subject_marks(subjectmarks):
 +#subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])
 + subjectmarks.sort(key = lambda x: x[1])
 + return subjectmarks
\ No newline at end of file diff --git a/progs/unparsable_programs/a464.py b/progs/unparsable_programs/a464.py new file mode 100644 index 0000000..19a3c54 --- /dev/null +++ b/progs/unparsable_programs/a464.py @@ -0,0 +1,6 @@ +def kth_element(arr, n, k):
 +  for i in range(n):
 +    for j in range(0, n-i-1):
 +      if arr[j] > arr[j+1]:
 +        arr[j], arr[j+1] == arr[j+1], arr[j]
 +  return arr[k-1]
\ No newline at end of file diff --git a/progs/unparsable_programs/a467.py b/progs/unparsable_programs/a467.py new file mode 100644 index 0000000..8d50f1a --- /dev/null +++ b/progs/unparsable_programs/a467.py @@ -0,0 +1,3 @@ +def sort_sublists(input_list):
 +    result = [sorted(x, key = lambda x:x[0]) for x in input_list] 
 +    return result
\ No newline at end of file diff --git a/progs/unparsable_programs/a474.py b/progs/unparsable_programs/a474.py new file mode 100644 index 0000000..8834f07 --- /dev/null +++ b/progs/unparsable_programs/a474.py @@ -0,0 +1,3 @@ +def common_in_nested_lists(nestedlist):
 +    result = list(set.intersection(*map(set, nestedlist)))
 +    return result
\ No newline at end of file diff --git a/progs/unparsable_programs/a477.py b/progs/unparsable_programs/a477.py new file mode 100644 index 0000000..ffe95ed --- /dev/null +++ b/progs/unparsable_programs/a477.py @@ -0,0 +1,4 @@ +from collections import Counter 
 +def assign_freq(test_list):
 +  res = [(*key, val) for key, val in Counter(test_list).items()]
 +  return (str(res)) 
\ No newline at end of file diff --git a/progs/unparsable_programs/a493.py b/progs/unparsable_programs/a493.py new file mode 100644 index 0000000..430263c --- /dev/null +++ b/progs/unparsable_programs/a493.py @@ -0,0 +1,7 @@ +from collections import defaultdict
 +def max_occurrences(nums):
 +    dict = defaultdict(int)
 +    for i in nums:
 +        dict[i] += 1
 +    result = max(dict.items(), key=lambda x: x[1]) 
 +    return result
\ No newline at end of file diff --git a/progs/unparsable_programs/a496.py b/progs/unparsable_programs/a496.py new file mode 100644 index 0000000..e34381b --- /dev/null +++ b/progs/unparsable_programs/a496.py @@ -0,0 +1,3 @@ +def sum_negativenum(nums):
 +  sum_negativenum = list(filter(lambda nums:nums<0,nums))
 +  return sum(sum_negativenum)
\ No newline at end of file diff --git a/progs/unparsable_programs/a51.py b/progs/unparsable_programs/a51.py new file mode 100644 index 0000000..5c5fc6f --- /dev/null +++ b/progs/unparsable_programs/a51.py @@ -0,0 +1,4 @@ +def matrix_to_list(test_list):
 +  temp = [ele for sub in test_list for ele in sub]
 +  res = list(zip(*temp))
 +  return (str(res))
\ No newline at end of file diff --git a/progs/unparsable_programs/a538.py b/progs/unparsable_programs/a538.py new file mode 100644 index 0000000..7ae9d78 --- /dev/null +++ b/progs/unparsable_programs/a538.py @@ -0,0 +1,8 @@ +def is_valid_parenthese( str1):
 +        stack, pchar = [], {"(": ")", "{": "}", "[": "]"}
 +        for parenthese in str1:
 +            if parenthese in pchar:
 +                stack.append(parenthese)
 +            elif len(stack) == 0 or pchar[stack.pop()] != parenthese:
 +                return False
 +        return len(stack) == 0
\ No newline at end of file diff --git a/progs/unparsable_programs/a545.py b/progs/unparsable_programs/a545.py new file mode 100644 index 0000000..1f2f494 --- /dev/null +++ b/progs/unparsable_programs/a545.py @@ -0,0 +1,7 @@ +import re
 +def find_character(string):
 +  uppercase_characters = re.findall(r"[A-Z]", string) 
 +  lowercase_characters = re.findall(r"[a-z]", string) 
 +  numerical_characters = re.findall(r"[0-9]", string) 
 +  special_characters = re.findall(r"[, .!?]", string) 
 +  return uppercase_characters, lowercase_characters, numerical_characters, special_characters
\ No newline at end of file diff --git a/progs/unparsable_programs/a568.py b/progs/unparsable_programs/a568.py new file mode 100644 index 0000000..817b96b --- /dev/null +++ b/progs/unparsable_programs/a568.py @@ -0,0 +1,3 @@ +def inversion_elements(test_tup):
 +  res = tuple(list(map(lambda x: ~x, list(test_tup))))
 +  return (res) 
\ No newline at end of file diff --git a/progs/unparsable_programs/a571.py b/progs/unparsable_programs/a571.py new file mode 100644 index 0000000..4f882e6 --- /dev/null +++ b/progs/unparsable_programs/a571.py @@ -0,0 +1,5 @@ +import re
 +def is_decimal(num):
 +  num_fetch = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""")
 +  result = num_fetch.search(num)
 +  return bool(result)
\ No newline at end of file diff --git a/progs/unparsable_programs/a573.py b/progs/unparsable_programs/a573.py new file mode 100644 index 0000000..a07ff11 --- /dev/null +++ b/progs/unparsable_programs/a573.py @@ -0,0 +1,5 @@ +import re
 +def is_allowed_specific_char(string):
 +    get_char = re.compile(r'[^a-zA-Z0-9.]')
 +    string = get_char.search(string)
 +    return not bool(string)
\ No newline at end of file diff --git a/progs/unparsable_programs/a606.py b/progs/unparsable_programs/a606.py new file mode 100644 index 0000000..b5699a7 --- /dev/null +++ b/progs/unparsable_programs/a606.py @@ -0,0 +1,6 @@ +def sort_on_occurence(lst): 
 +	dct = {} 
 +	for i, j in lst: 
 +		dct.setdefault(i, []).append(j) 
 +	return ([(i, *dict.fromkeys(j), len(j)) 
 +				for i, j in dct.items()]) 
\ No newline at end of file diff --git a/progs/unparsable_programs/a61.py b/progs/unparsable_programs/a61.py new file mode 100644 index 0000000..86e124b --- /dev/null +++ b/progs/unparsable_programs/a61.py @@ -0,0 +1,3 @@ +def sorted_dict(dict1):
 +  sorted_dict = {x: sorted(y) for x, y in dict1.items()}
 +  return sorted_dict
\ No newline at end of file diff --git a/progs/unparsable_programs/a612.py b/progs/unparsable_programs/a612.py new file mode 100644 index 0000000..558350e --- /dev/null +++ b/progs/unparsable_programs/a612.py @@ -0,0 +1,3 @@ +def intersection_array(array_nums1,array_nums2):
 + result = list(filter(lambda x: x in array_nums1, array_nums2)) 
 + return result
\ No newline at end of file diff --git a/progs/unparsable_programs/a621.py b/progs/unparsable_programs/a621.py new file mode 100644 index 0000000..5db06b7 --- /dev/null +++ b/progs/unparsable_programs/a621.py @@ -0,0 +1,3 @@ +def count_odd(array_nums):
 +   count_odd = len(list(filter(lambda x: (x%2 != 0) , array_nums)))
 +   return count_odd
\ No newline at end of file diff --git a/progs/unparsable_programs/a636.py b/progs/unparsable_programs/a636.py new file mode 100644 index 0000000..ab2de45 --- /dev/null +++ b/progs/unparsable_programs/a636.py @@ -0,0 +1,3 @@ +def substract_elements(test_tup1, test_tup2):
 +  res = tuple(map(lambda i, j: i - j, test_tup1, test_tup2))
 +  return (res) 
\ No newline at end of file diff --git a/progs/unparsable_programs/a640.py b/progs/unparsable_programs/a640.py new file mode 100644 index 0000000..6070126 --- /dev/null +++ b/progs/unparsable_programs/a640.py @@ -0,0 +1,3 @@ +def dict_filter(dict,n):
 + result = {key:value for (key, value) in dict.items() if value >=n}
 + return result
\ No newline at end of file diff --git a/progs/unparsable_programs/a645.py b/progs/unparsable_programs/a645.py new file mode 100644 index 0000000..140687a --- /dev/null +++ b/progs/unparsable_programs/a645.py @@ -0,0 +1,3 @@ +def sub_list(nums1,nums2):
 +  result = map(lambda x, y: x - y, nums1, nums2)
 +  return list(result)
\ No newline at end of file diff --git a/progs/unparsable_programs/a662.py b/progs/unparsable_programs/a662.py new file mode 100644 index 0000000..0ab4afb --- /dev/null +++ b/progs/unparsable_programs/a662.py @@ -0,0 +1,6 @@ +from collections import defaultdict
 +def max_aggregate(stdata):
 +    temp = defaultdict(int)
 +    for name, marks in stdata:
 +        temp[name] += marks
 +    return max(temp.items(), key=lambda x: x[1])
\ No newline at end of file diff --git a/progs/unparsable_programs/a68.py b/progs/unparsable_programs/a68.py new file mode 100644 index 0000000..f0c967a --- /dev/null +++ b/progs/unparsable_programs/a68.py @@ -0,0 +1,10 @@ +import re 
 +regex = '''^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 
 +			25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 
 +			25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.( 
 +			25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$'''
 +def check_IP(Ip): 
 +	if(re.search(regex, Ip)): 
 +		return ("Valid IP address") 
 +	else: 
 +		return ("Invalid IP address") 
\ No newline at end of file diff --git a/progs/unparsable_programs/a682.py b/progs/unparsable_programs/a682.py new file mode 100644 index 0000000..5c65e09 --- /dev/null +++ b/progs/unparsable_programs/a682.py @@ -0,0 +1,3 @@ +import re
 +def find_long_word(text):
 +  return (re.findall(r"\b\w{5}\b", text))
\ No newline at end of file diff --git a/progs/unparsable_programs/a693.py b/progs/unparsable_programs/a693.py new file mode 100644 index 0000000..a77dd15 --- /dev/null +++ b/progs/unparsable_programs/a693.py @@ -0,0 +1,3 @@ +import re
 +def find_char(text):
 +  return (re.findall(r"\b\w{3,5}\b", text))
\ No newline at end of file diff --git a/progs/unparsable_programs/a696.py b/progs/unparsable_programs/a696.py new file mode 100644 index 0000000..9ed1b12 --- /dev/null +++ b/progs/unparsable_programs/a696.py @@ -0,0 +1,3 @@ +def Sort(sub_li): 
 +    sub_li.sort(key = lambda x: x[1]) 
 +    return sub_li 
\ No newline at end of file diff --git a/progs/unparsable_programs/a705.py b/progs/unparsable_programs/a705.py new file mode 100644 index 0000000..a0b26fe --- /dev/null +++ b/progs/unparsable_programs/a705.py @@ -0,0 +1,26 @@ +from heapq import heappop, heappush
 +class Node:
 +    def __init__(self, value, list_num, index):
 +        self.value = value
 +        self.list_num = list_num
 +        self.index = index
 +    def __lt__(self, other):
 +        return self.value < other.value
 +def find_minimum_range(list):
 +    high = float('-inf')
 +    p = (0, float('inf'))
 +    pq = []
 +    for i in range(len(list)):
 +        heappush(pq, Node(list[i][0], i, 0))
 +        high = max(high, list[i][0])
 +    while True:
 +        top = heappop(pq)
 +        low = top.value
 +        i = top.list_num
 +        j = top.index
 +        if high - low < p[1] - p[0]:
 +            p = (low, high)
 +        if j == len(list[i]) - 1:
 +            return p
 +        heappush(pq, Node(list[i][j + 1], i, j + 1))
 +        high = max(high, list[i][j + 1])
\ No newline at end of file diff --git a/progs/unparsable_programs/a706.py b/progs/unparsable_programs/a706.py new file mode 100644 index 0000000..dcb86aa --- /dev/null +++ b/progs/unparsable_programs/a706.py @@ -0,0 +1,10 @@ +def dig_let(s):
 + d=l=0
 + for c in s:
 +    if c.isdigit():
 +        d=d+1
 +    elif c.isalpha():
 +        l=l+1
 +    else:
 +        pass
 + return (l,d)
\ No newline at end of file diff --git a/progs/unparsable_programs/a716.py b/progs/unparsable_programs/a716.py new file mode 100644 index 0000000..f37a36c --- /dev/null +++ b/progs/unparsable_programs/a716.py @@ -0,0 +1,4 @@ +def remove_column(list1, n):
 +   for i in list1: 
 +    del i[n] 
 +   return list1
\ No newline at end of file diff --git a/progs/unparsable_programs/a721.py b/progs/unparsable_programs/a721.py new file mode 100644 index 0000000..6822cbb --- /dev/null +++ b/progs/unparsable_programs/a721.py @@ -0,0 +1,3 @@ +def moddiv_list(nums1,nums2):
 +  result = map(lambda x, y: x % y, nums1, nums2)
 +  return list(result)
\ No newline at end of file diff --git a/progs/unparsable_programs/a733.py b/progs/unparsable_programs/a733.py new file mode 100644 index 0000000..ce0150e --- /dev/null +++ b/progs/unparsable_programs/a733.py @@ -0,0 +1,3 @@ +def float_sort(price):
 +  float_sort=sorted(price, key=lambda x: float(x[1]), reverse=True)
 +  return float_sort
\ No newline at end of file diff --git a/progs/unparsable_programs/a754.py b/progs/unparsable_programs/a754.py new file mode 100644 index 0000000..c453802 --- /dev/null +++ b/progs/unparsable_programs/a754.py @@ -0,0 +1,3 @@ +def convert_list_dictionary(l1, l2, l3):
 +     result = [{x: {y: z}} for (x, y, z) in zip(l1, l2, l3)]
 +     return result
\ No newline at end of file diff --git a/progs/unparsable_programs/a756.py b/progs/unparsable_programs/a756.py new file mode 100644 index 0000000..159b73d --- /dev/null +++ b/progs/unparsable_programs/a756.py @@ -0,0 +1,4 @@ +def max_length_list(input_list):
 +    max_length = max(len(x) for x in input_list )   
 +    max_list = max(input_list, key = lambda i: len(i))    
 +    return(max_length, max_list)
\ No newline at end of file diff --git a/progs/unparsable_programs/a759.py b/progs/unparsable_programs/a759.py new file mode 100644 index 0000000..25684b9 --- /dev/null +++ b/progs/unparsable_programs/a759.py @@ -0,0 +1,7 @@ +import re  
 +regex = r'^[a-z]$|^([a-z]).*\1$'
 +def check_char(string): 
 +	if(re.search(regex, string)): 
 +		return "Valid" 
 +	else: 
 +		return "Invalid" 
\ No newline at end of file diff --git a/progs/unparsable_programs/a770.py b/progs/unparsable_programs/a770.py new file mode 100644 index 0000000..01aa0da --- /dev/null +++ b/progs/unparsable_programs/a770.py @@ -0,0 +1,11 @@ +def rearrange_bigger(n):
 +    nums = list(str(n))
 +    for i in range(len(nums)-2,-1,-1):
 +        if nums[i] < nums[i+1]:
 +            z = nums[i:]
 +            y = min(filter(lambda x: x > z[0], z))
 +            z.remove(y)
 +            z.sort()
 +            nums[i:] = [y] + z
 +            return int("".join(nums))
 +    return False
\ No newline at end of file diff --git a/progs/unparsable_programs/a771.py b/progs/unparsable_programs/a771.py new file mode 100644 index 0000000..6343c44 --- /dev/null +++ b/progs/unparsable_programs/a771.py @@ -0,0 +1,15 @@ +import heapq
 +def k_smallest_pairs(nums1, nums2, k):
 +   queue = []
 +   def push(i, j):
 +       if i < len(nums1) and j < len(nums2):
 +           heapq.heappush(queue, [nums1[i] + nums2[j], i, j])
 +   push(0, 0)
 +   pairs = []
 +   while queue and len(pairs) < k:
 +       _, i, j = heapq.heappop(queue)
 +       pairs.append([nums1[i], nums2[j]])
 +       push(i, j + 1)
 +       if j == 0:
 +           push(i + 1, 0)
 +   return pairs
\ No newline at end of file diff --git a/progs/unparsable_programs/a790.py b/progs/unparsable_programs/a790.py new file mode 100644 index 0000000..a164a22 --- /dev/null +++ b/progs/unparsable_programs/a790.py @@ -0,0 +1,3 @@ +import re
 +def change_date_format(dt):
 +        return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt)
\ No newline at end of file diff --git a/progs/unparsable_programs/a803.py b/progs/unparsable_programs/a803.py new file mode 100644 index 0000000..e0ddfe1 --- /dev/null +++ b/progs/unparsable_programs/a803.py @@ -0,0 +1,4 @@ +import re
 +def find_adverb_position(text):
 + for m in re.finditer(r"\w+ly", text):
 +    return (m.start(), m.end(), m.group(0))
\ No newline at end of file diff --git a/progs/unparsable_programs/a81.py b/progs/unparsable_programs/a81.py new file mode 100644 index 0000000..b9ae819 --- /dev/null +++ b/progs/unparsable_programs/a81.py @@ -0,0 +1,3 @@ +def mul_list(nums1,nums2):
 +  result = map(lambda x, y: x * y, nums1, nums2)
 +  return list(result)
\ No newline at end of file diff --git a/progs/unparsable_programs/a810.py b/progs/unparsable_programs/a810.py new file mode 100644 index 0000000..3fff4aa --- /dev/null +++ b/progs/unparsable_programs/a810.py @@ -0,0 +1,3 @@ +def cube_nums(nums):
 + cube_nums = list(map(lambda x: x ** 3, nums))
 + return cube_nums
\ No newline at end of file diff --git a/progs/unparsable_programs/a814.py b/progs/unparsable_programs/a814.py new file mode 100644 index 0000000..2f895d0 --- /dev/null +++ b/progs/unparsable_programs/a814.py @@ -0,0 +1,3 @@ +import re
 +def remove_whitespaces(text1):
 +  return (re.sub(r'\s+', '',text1))
\ No newline at end of file diff --git a/progs/unparsable_programs/a822.py b/progs/unparsable_programs/a822.py new file mode 100644 index 0000000..246129f --- /dev/null +++ b/progs/unparsable_programs/a822.py @@ -0,0 +1,5 @@ +import re
 +def remove_uppercase(str1):
 +  remove_upper = lambda text: re.sub('[A-Z]', '', text)
 +  result =  remove_upper(str1)
 +  return (result)
\ No newline at end of file diff --git a/progs/unparsable_programs/a828.py b/progs/unparsable_programs/a828.py new file mode 100644 index 0000000..16ad291 --- /dev/null +++ b/progs/unparsable_programs/a828.py @@ -0,0 +1,3 @@ +def drop_empty(dict1):
 +  dict1 = {key:value for (key, value) in dict1.items() if value is not None}
 +  return dict1
\ No newline at end of file diff --git a/progs/unparsable_programs/a841.py b/progs/unparsable_programs/a841.py new file mode 100644 index 0000000..34e9fe1 --- /dev/null +++ b/progs/unparsable_programs/a841.py @@ -0,0 +1,5 @@ +import re
 +def remove_lowercase(str1):
 + remove_lower = lambda text: re.sub('[a-z]', '', text)
 + result =  remove_lower(str1)
 + return result
\ No newline at end of file diff --git a/progs/unparsable_programs/a858.py b/progs/unparsable_programs/a858.py new file mode 100644 index 0000000..1dcc6e1 --- /dev/null +++ b/progs/unparsable_programs/a858.py @@ -0,0 +1,5 @@ +import re
 +def remove_lowercase(str1):
 +  remove_lower = lambda text: re.sub('[a-z]', '', text)
 +  result =  remove_lower(str1)
 +  return (result)
\ No newline at end of file diff --git a/progs/unparsable_programs/a879.py b/progs/unparsable_programs/a879.py new file mode 100644 index 0000000..791dd76 --- /dev/null +++ b/progs/unparsable_programs/a879.py @@ -0,0 +1,18 @@ +def radix_sort(nums):
 +    RADIX = 10
 +    placement = 1
 +    max_digit = max(nums)
 +
 +    while placement < max_digit:
 +      buckets = [list() for _ in range( RADIX )]
 +      for i in nums:
 +        tmp = int((i / placement) % RADIX)
 +        buckets[tmp].append(i)
 +      a = 0
 +      for b in range( RADIX ):
 +        buck = buckets[b]
 +        for i in buck:
 +          nums[a] = i
 +          a += 1
 +      placement *= RADIX
 +    return nums
\ No newline at end of file diff --git a/progs/unparsable_programs/a886.py b/progs/unparsable_programs/a886.py new file mode 100644 index 0000000..9573668 --- /dev/null +++ b/progs/unparsable_programs/a886.py @@ -0,0 +1,10 @@ +def check_string(str1):
 +    messg = [
 +    lambda str1: any(x.isupper() for x in str1) or 'String must have 1 upper case character.',
 +    lambda str1: any(x.islower() for x in str1) or 'String must have 1 lower case character.',
 +    lambda str1: any(x.isdigit() for x in str1) or 'String must have 1 number.',
 +    lambda str1: len(str1) >= 7                 or 'String length should be atleast 8.',]
 +    result = [x for x in [i(str1) for i in messg] if x != True]
 +    if not result:
 +        result.append('Valid string.')
 +    return result  
\ No newline at end of file diff --git a/progs/unparsable_programs/a889.py b/progs/unparsable_programs/a889.py new file mode 100644 index 0000000..e9c0151 --- /dev/null +++ b/progs/unparsable_programs/a889.py @@ -0,0 +1,6 @@ +def capitalize_first_last_letters(str1):
 +     str1 = result = str1.title()
 +     result =  ""
 +     for word in str1.split():
 +        result += word[:-1] + word[-1].upper() + " "
 +     return result[:-1]  
\ No newline at end of file diff --git a/progs/unparsable_programs/a90.py b/progs/unparsable_programs/a90.py new file mode 100644 index 0000000..6ef8340 --- /dev/null +++ b/progs/unparsable_programs/a90.py @@ -0,0 +1,6 @@ +from itertools import groupby 
 +def group_element(test_list):
 +  res = dict()
 +  for key, val in groupby(sorted(test_list, key = lambda ele: ele[1]), key = lambda ele: ele[1]):
 +    res[key] = [ele[0] for ele in val] 
 +  return (res)
 diff --git a/progs/unparsable_programs/a926.py b/progs/unparsable_programs/a926.py new file mode 100644 index 0000000..f5a9cc8 --- /dev/null +++ b/progs/unparsable_programs/a926.py @@ -0,0 +1,3 @@ +import re
 +def extract_values(text):
 + return (re.findall(r'"(.*?)"', text))
\ No newline at end of file diff --git a/progs/unparsable_programs/a931.py b/progs/unparsable_programs/a931.py new file mode 100644 index 0000000..fc9e5a8 --- /dev/null +++ b/progs/unparsable_programs/a931.py @@ -0,0 +1,3 @@ +def empty_list(length):
 + empty_list = [{} for _ in range(length)]
 + return empty_list
\ No newline at end of file diff --git a/progs/unparsable_programs/a943.py b/progs/unparsable_programs/a943.py new file mode 100644 index 0000000..ddad129 --- /dev/null +++ b/progs/unparsable_programs/a943.py @@ -0,0 +1,11 @@ +def even_ele(test_tuple, even_fnc): 
 +	res = tuple() 
 +	for ele in test_tuple: 
 +		if isinstance(ele, tuple): 
 +			res += (even_ele(ele, even_fnc), ) 
 +		elif even_fnc(ele): 
 +			res += (ele, ) 
 +	return res 
 +def extract_even(test_tuple):
 +  res = even_ele(test_tuple, lambda x: x % 2 == 0)
 +  return (res) 
\ No newline at end of file diff --git a/progs/unparsable_programs/a947.py b/progs/unparsable_programs/a947.py new file mode 100644 index 0000000..9ef0cf1 --- /dev/null +++ b/progs/unparsable_programs/a947.py @@ -0,0 +1,4 @@ +import re
 +def find_adverbs(text):
 +  for m in re.finditer(r"\w+ly", text):
 +    return ('%d-%d: %s' % (m.start(), m.end(), m.group(0)))
\ No newline at end of file diff --git a/progs/unparsable_programs/a948.py b/progs/unparsable_programs/a948.py new file mode 100644 index 0000000..f42212f --- /dev/null +++ b/progs/unparsable_programs/a948.py @@ -0,0 +1,4 @@ +import heapq
 +def expensive_items(items,n):
 +  expensive_items = heapq.nlargest(n, items, key=lambda s: s['price'])
 +  return expensive_items
\ No newline at end of file diff --git a/progs/unparsable_programs/a96.py b/progs/unparsable_programs/a96.py new file mode 100644 index 0000000..b135674 --- /dev/null +++ b/progs/unparsable_programs/a96.py @@ -0,0 +1,3 @@ +def count_even(array_nums):
 +   count_even = len(list(filter(lambda x: (x%2 == 0) , array_nums)))
 +   return count_even
\ No newline at end of file diff --git a/progs/unparsable_programs/a97.py b/progs/unparsable_programs/a97.py new file mode 100644 index 0000000..3aabcc9 --- /dev/null +++ b/progs/unparsable_programs/a97.py @@ -0,0 +1,3 @@ +def sort_dict_item(test_dict):
 +  res = {key: test_dict[key] for key in sorted(test_dict.keys(), key = lambda ele: ele[1] * ele[0])}
 +  return  (res) 
 diff --git a/progs/unparsable_programs/a970.py b/progs/unparsable_programs/a970.py new file mode 100644 index 0000000..1fdbebb --- /dev/null +++ b/progs/unparsable_programs/a970.py @@ -0,0 +1,3 @@ +import re
 +def find_char_long(text):
 +  return (re.findall(r"\b\w{4,}\b", text))
\ No newline at end of file diff --git a/progs/unparsable_programs/a971.py b/progs/unparsable_programs/a971.py new file mode 100644 index 0000000..490613c --- /dev/null +++ b/progs/unparsable_programs/a971.py @@ -0,0 +1,3 @@ +def square_nums(nums):
 + square_nums = list(map(lambda x: x ** 2, nums))
 + return square_nums
\ No newline at end of file diff --git a/progs/wrong.py b/progs/wrong.py new file mode 100644 index 0000000..1bcd821 --- /dev/null +++ b/progs/wrong.py @@ -0,0 +1,4 @@ +fa dkfjd;slkjfdslakjf +jfsdj <<>>>><><><> + +klwsd diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..7fc9494 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,60 @@ +import java.io.InputStream; +import java.io.IOException; +import java.io.BufferedReader; +import java.io.FileReader; +import java.util.Objects; +import java.util.Arrays; +import java.io.File; +import java.io.FileInputStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.tree.*; +import org.antlr.v4.gui.TreeViewer; +import javax.swing.*; + + +public class Main { +	public static void main(String[] args) { +		for (File file: Objects.requireNonNull(new File("./progs/").listFiles())) { +			try { +				String fileStr = file.getPath(); +				fileStr = "./progs/test.py"; +				System.out.println(fileStr); + +				System.out.println(readFile(fileStr)); + +				CharStream cs = CharStreams.fromFileName(fileStr); +				Python3Lexer lexer = new Python3Lexer(cs); +				CommonTokenStream tokenStream = new CommonTokenStream(lexer); +				Python3Parser parser = new Python3Parser(tokenStream); +				Python3Parser.RootContext tree = parser.root(); +//				String treeStr = tree.toString(); +//				System.out.println(treeStr); +//				// Visualize the parse tree +				JFrame frame = new JFrame("Parse Tree"); +				JPanel panel = new JPanel(); +				TreeViewer viewer = new TreeViewer(Arrays.asList(parser.getRuleNames()), tree); +				viewer.setScale(1.5); // Zoom factor +				panel.add(viewer); +				frame.add(panel); +				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); +				frame.setSize(800, 600); +				frame.setVisible(true); +				break; +			} catch (Exception e) { +				e.printStackTrace(); +			} +		} +	} +	private static String readFile(String filePath) throws IOException { +		StringBuilder content = new StringBuilder(); +		try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { +			String line; +			while ((line = reader.readLine()) != null) { +				content.append(line).append("\n"); +			} +		} +		return content.toString(); +	} + +} + diff --git a/src/ParseAll.java b/src/ParseAll.java new file mode 100644 index 0000000..2a88afa --- /dev/null +++ b/src/ParseAll.java @@ -0,0 +1,101 @@ +import java.io.IOException; +import java.io.BufferedReader; +import java.io.FileReader; +import java.util.Objects; +import java.util.Arrays; +import java.io.File; + +import org.antlr.v4.runtime.*; +import org.antlr.v4.gui.TreeViewer; + +import javax.swing.*; + + +public class ParseAll { +    public static void main(String[] args) { +        for (File file: Objects.requireNonNull(new File("./progs").listFiles())) { +            String fileStr = file.getPath(); +//			fileStr = "./progs/wrong.py"; +            try { + +                if (!file.isFile() || !getExtension(file.getName()).equals("py")){ +                    System.err.println("Wont parse: " + fileStr); +                    continue; +                } else { +                    System.out.println(fileStr); +                } + +//				System.out.println(readFile(fileStr)); + +                CharStream cs = CharStreams.fromFileName(fileStr); +                Python3Lexer lexer = new Python3Lexer(cs); +                CommonTokenStream tokenStream = new CommonTokenStream(lexer); +                Python3Parser parser = new Python3Parser(tokenStream); + +                Python3Parser.RootContext tree = parser.root(); +                String treeStr = tree.toStringTree(); +//				System.out.println(treeStr); + +                TreeViewer viewer = new TreeViewer(Arrays.asList(parser.getRuleNames()), tree); +                viewer.setScale(1.5); +                saveTree(viewer, "./trees/" + removeExtension(file.getName()) + ".png"); +                if (parser.getNumberOfSyntaxErrors() != 0) { +                    System.err.println("Parse errors: " + fileStr); +                } + +            } catch (Exception e) { +                e.printStackTrace(); +                System.err.println(fileStr); +            } +        } +    } + +    private static String readFile(String filePath) throws IOException { +        StringBuilder content = new StringBuilder(); +        try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) { +            String line; +            while ((line = reader.readLine()) != null) { +                content.append(line).append("\n"); +            } +        } +        return content.toString(); +    } + +    private static void showTree(TreeViewer viewer) { +        JFrame frame = new JFrame("Parse Tree"); +        JPanel panel = new JPanel(); +        panel.add(viewer); +        frame.add(panel); +        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); +        frame.setSize(800, 600); +        frame.setVisible(true); +    } +    private static void saveTree(TreeViewer viewer, String name) { +        try { +            viewer.save(name); +        } catch (Exception e) { +            System.err.println(name); +            e.printStackTrace(); +        } +    } + +    public static String removeExtension(String fileName) { +        int extensionIndex = fileName.lastIndexOf('.'); +        if (extensionIndex == -1) { +            return fileName; +        } else { +            return fileName.substring(0, extensionIndex); +        } +    } + +    public static String getExtension(String fileName) { +        int extensionIndex = fileName.lastIndexOf('.'); +        if (extensionIndex == -1) { +            return fileName; +        } else { +            return fileName.substring(extensionIndex + 1); +        } +    } + +} + diff --git a/src/Python3Lexer.g4 b/src/Python3Lexer.g4 new file mode 100644 index 0000000..8d53301 --- /dev/null +++ b/src/Python3Lexer.g4 @@ -0,0 +1,131 @@ +/* + La grammatica di Python si trova a + https://docs.python.org/3/reference/grammar.html + + Questa e` stata elaborata da  Bart Kiers, bart@big-o.nl + e si trova a https://github.com/bkiers/python3-parser + + Semplificata ai fini del corso di CLP -- Marco Bertoni, Cosimo Laneve +*/ + +// $antlr-format alignTrailingComments true, columnLimit 150, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine true, allowShortBlocksOnASingleLine true, minEmptyLines 0, alignSemicolons ownLine +// $antlr-format alignColons trailing, singleLineOverrulesHangingColon true, alignLexerCommands true, alignLabels true, alignTrailers true + +lexer grammar Python3Lexer; + +tokens { +    INDENT, +    DEDENT +} + +options { +    superClass = Python3LexerBase; +} + +STRING  : '\'' (STRING_ESCAPE_SEQ | ~[\\\r\n\f'])* '\'' +        | '"' ( STRING_ESCAPE_SEQ | ~[\\\r\n\f"])* '"' +        ; + +NUMBER : DECIMAL_INTEGER | FLOAT_NUMBER ; + +AND        : 'and'; +AS         : 'as'; +DEF        : 'def'; +ELIF       : 'elif'; +ELSE       : 'else'; +FALSE      : 'False'; +FOR        : 'for'; +FROM       : 'from'; +IF         : 'if'; +IMPORT     : 'import'; +IN         : 'in'; +IS         : 'is'; +NONE       : 'None'; +NOT        : 'not'; +OR         : 'or'; +RETURN     : 'return'; +TRUE       : 'True'; +UNDERSCORE : '_'; +WHILE      : 'while'; + +NEWLINE: ({this.atStartOfInput()}? SPACES | ( '\r'? '\n' | '\r' | '\f') SPACES?) {this.onNewLine();}; + +NAME: ('_' | 'a'..'z' | 'A'..'Z') ('_' | 'a'..'z' | 'A'..'Z' | '0'..'9')*  +     ; + +DECIMAL_INTEGER: NON_ZERO_DIGIT DIGIT* | '0'+; + +FLOAT_NUMBER: POINT_FLOAT | EXPONENT_FLOAT; + +DOT                : '.'; +ELLIPSIS           : '...'; +STAR               : '*'; +OPEN_PAREN         : '(' {this.openBrace();}; +CLOSE_PAREN        : ')' {this.closeBrace();}; +COMMA              : ','; +COLON              : ':'; +SEMI_COLON         : ';'; +POWER              : '**'; +ASSIGN             : '='; +OPEN_BRACK         : '[' {this.openBrace();}; +CLOSE_BRACK        : ']' {this.closeBrace();}; +OR_OP              : '|'; +XOR                : '^'; +AND_OP             : '&'; +LEFT_SHIFT         : '<<'; +RIGHT_SHIFT        : '>>'; +ADD                : '+'; +MINUS              : '-'; +DIV                : '/'; +MOD                : '%'; +IDIV               : '//'; +NOT_OP             : '~'; +OPEN_BRACE         : '{' {this.openBrace();}; +CLOSE_BRACE        : '}' {this.closeBrace();}; +LESS_THAN          : '<'; +GREATER_THAN       : '>'; +EQUALS             : '=='; +GT_EQ              : '>='; +LT_EQ              : '<='; +NOT_EQ_1           : '<>'; +NOT_EQ_2           : '!='; +AT                 : '@'; +ARROW              : '->'; +ADD_ASSIGN         : '+='; +SUB_ASSIGN         : '-='; +MULT_ASSIGN        : '*='; +AT_ASSIGN          : '@='; +DIV_ASSIGN         : '/='; +MOD_ASSIGN         : '%='; +AND_ASSIGN         : '&='; +OR_ASSIGN          : '|='; +XOR_ASSIGN         : '^='; +LEFT_SHIFT_ASSIGN  : '<<='; +RIGHT_SHIFT_ASSIGN : '>>='; +POWER_ASSIGN       : '**='; +IDIV_ASSIGN        : '//='; + +SKIP_: ( SPACES | COMMENT | LINE_JOINING) -> skip; + +UNKNOWN_CHAR: .; + +fragment STRING_ESCAPE_SEQ: '\\' . | '\\' NEWLINE; + +fragment NON_ZERO_DIGIT: [1-9]; + +fragment DIGIT: [0-9]; + +fragment POINT_FLOAT: INT_PART? '.' DIGIT+ | INT_PART '.'; + +fragment EXPONENT_FLOAT: ( INT_PART | POINT_FLOAT) EXPONENT; + +fragment INT_PART: DIGIT+; + +fragment EXPONENT: [eE] [+-]? DIGIT+; + +fragment SPACES: [ \t]+; + +fragment COMMENT: '#' ~[\r\n\f]*; + +fragment LINE_JOINING: '\\' SPACES? ( '\r'? '\n' | '\r' | '\f');
\ No newline at end of file diff --git a/src/Python3Lexer.interp b/src/Python3Lexer.interp new file mode 100644 index 0000000..1f4208b --- /dev/null +++ b/src/Python3Lexer.interp @@ -0,0 +1,253 @@ +token literal names: +null +null +null +null +null +'and' +'as' +'def' +'elif' +'else' +'False' +'for' +'from' +'if' +'import' +'in' +'is' +'None' +'not' +'or' +'return' +'True' +'_' +'while' +null +null +null +null +'.' +'...' +'*' +'(' +')' +',' +':' +';' +'**' +'=' +'[' +']' +'|' +'^' +'&' +'<<' +'>>' +'+' +'-' +'/' +'%' +'//' +'~' +'{' +'}' +'<' +'>' +'==' +'>=' +'<=' +'<>' +'!=' +'@' +'->' +'+=' +'-=' +'*=' +'@=' +'/=' +'%=' +'&=' +'|=' +'^=' +'<<=' +'>>=' +'**=' +'//=' +null +null + +token symbolic names: +null +INDENT +DEDENT +STRING +NUMBER +AND +AS +DEF +ELIF +ELSE +FALSE +FOR +FROM +IF +IMPORT +IN +IS +NONE +NOT +OR +RETURN +TRUE +UNDERSCORE +WHILE +NEWLINE +NAME +DECIMAL_INTEGER +FLOAT_NUMBER +DOT +ELLIPSIS +STAR +OPEN_PAREN +CLOSE_PAREN +COMMA +COLON +SEMI_COLON +POWER +ASSIGN +OPEN_BRACK +CLOSE_BRACK +OR_OP +XOR +AND_OP +LEFT_SHIFT +RIGHT_SHIFT +ADD +MINUS +DIV +MOD +IDIV +NOT_OP +OPEN_BRACE +CLOSE_BRACE +LESS_THAN +GREATER_THAN +EQUALS +GT_EQ +LT_EQ +NOT_EQ_1 +NOT_EQ_2 +AT +ARROW +ADD_ASSIGN +SUB_ASSIGN +MULT_ASSIGN +AT_ASSIGN +DIV_ASSIGN +MOD_ASSIGN +AND_ASSIGN +OR_ASSIGN +XOR_ASSIGN +LEFT_SHIFT_ASSIGN +RIGHT_SHIFT_ASSIGN +POWER_ASSIGN +IDIV_ASSIGN +SKIP_ +UNKNOWN_CHAR + +rule names: +STRING +NUMBER +AND +AS +DEF +ELIF +ELSE +FALSE +FOR +FROM +IF +IMPORT +IN +IS +NONE +NOT +OR +RETURN +TRUE +UNDERSCORE +WHILE +NEWLINE +NAME +DECIMAL_INTEGER +FLOAT_NUMBER +DOT +ELLIPSIS +STAR +OPEN_PAREN +CLOSE_PAREN +COMMA +COLON +SEMI_COLON +POWER +ASSIGN +OPEN_BRACK +CLOSE_BRACK +OR_OP +XOR +AND_OP +LEFT_SHIFT +RIGHT_SHIFT +ADD +MINUS +DIV +MOD +IDIV +NOT_OP +OPEN_BRACE +CLOSE_BRACE +LESS_THAN +GREATER_THAN +EQUALS +GT_EQ +LT_EQ +NOT_EQ_1 +NOT_EQ_2 +AT +ARROW +ADD_ASSIGN +SUB_ASSIGN +MULT_ASSIGN +AT_ASSIGN +DIV_ASSIGN +MOD_ASSIGN +AND_ASSIGN +OR_ASSIGN +XOR_ASSIGN +LEFT_SHIFT_ASSIGN +RIGHT_SHIFT_ASSIGN +POWER_ASSIGN +IDIV_ASSIGN +SKIP_ +UNKNOWN_CHAR +STRING_ESCAPE_SEQ +NON_ZERO_DIGIT +DIGIT +POINT_FLOAT +EXPONENT_FLOAT +INT_PART +EXPONENT +SPACES +COMMENT +LINE_JOINING + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 76, 523, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 2, 61, 7, 61, 2, 62, 7, 62, 2, 63, 7, 63, 2, 64, 7, 64, 2, 65, 7, 65, 2, 66, 7, 66, 2, 67, 7, 67, 2, 68, 7, 68, 2, 69, 7, 69, 2, 70, 7, 70, 2, 71, 7, 71, 2, 72, 7, 72, 2, 73, 7, 73, 2, 74, 7, 74, 2, 75, 7, 75, 2, 76, 7, 76, 2, 77, 7, 77, 2, 78, 7, 78, 2, 79, 7, 79, 2, 80, 7, 80, 2, 81, 7, 81, 2, 82, 7, 82, 2, 83, 7, 83, 1, 0, 1, 0, 1, 0, 5, 0, 173, 8, 0, 10, 0, 12, 0, 176, 9, 0, 1, 0, 1, 0, 1, 0, 1, 0, 5, 0, 182, 8, 0, 10, 0, 12, 0, 185, 9, 0, 1, 0, 3, 0, 188, 8, 0, 1, 1, 1, 1, 3, 1, 192, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 21, 1, 21, 1, 21, 3, 21, 281, 8, 21, 1, 21, 1, 21, 3, 21, 285, 8, 21, 1, 21, 3, 21, 288, 8, 21, 3, 21, 290, 8, 21, 1, 21, 1, 21, 1, 22, 1, 22, 5, 22, 296, 8, 22, 10, 22, 12, 22, 299, 9, 22, 1, 23, 1, 23, 5, 23, 303, 8, 23, 10, 23, 12, 23, 306, 9, 23, 1, 23, 4, 23, 309, 8, 23, 11, 23, 12, 23, 310, 3, 23, 313, 8, 23, 1, 24, 1, 24, 3, 24, 317, 8, 24, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 28, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 31, 1, 31, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 37, 1, 37, 1, 38, 1, 38, 1, 39, 1, 39, 1, 40, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, 42, 1, 42, 1, 43, 1, 43, 1, 44, 1, 44, 1, 45, 1, 45, 1, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 1, 49, 1, 49, 1, 49, 1, 50, 1, 50, 1, 51, 1, 51, 1, 52, 1, 52, 1, 52, 1, 53, 1, 53, 1, 53, 1, 54, 1, 54, 1, 54, 1, 55, 1, 55, 1, 55, 1, 56, 1, 56, 1, 56, 1, 57, 1, 57, 1, 58, 1, 58, 1, 58, 1, 59, 1, 59, 1, 59, 1, 60, 1, 60, 1, 60, 1, 61, 1, 61, 1, 61, 1, 62, 1, 62, 1, 62, 1, 63, 1, 63, 1, 63, 1, 64, 1, 64, 1, 64, 1, 65, 1, 65, 1, 65, 1, 66, 1, 66, 1, 66, 1, 67, 1, 67, 1, 67, 1, 68, 1, 68, 1, 68, 1, 68, 1, 69, 1, 69, 1, 69, 1, 69, 1, 70, 1, 70, 1, 70, 1, 70, 1, 71, 1, 71, 1, 71, 1, 71, 1, 72, 1, 72, 1, 72, 3, 72, 451, 8, 72, 1, 72, 1, 72, 1, 73, 1, 73, 1, 74, 1, 74, 1, 74, 1, 74, 3, 74, 461, 8, 74, 1, 75, 1, 75, 1, 76, 1, 76, 1, 77, 3, 77, 468, 8, 77, 1, 77, 1, 77, 4, 77, 472, 8, 77, 11, 77, 12, 77, 473, 1, 77, 1, 77, 1, 77, 3, 77, 479, 8, 77, 1, 78, 1, 78, 3, 78, 483, 8, 78, 1, 78, 1, 78, 1, 79, 4, 79, 488, 8, 79, 11, 79, 12, 79, 489, 1, 80, 1, 80, 3, 80, 494, 8, 80, 1, 80, 4, 80, 497, 8, 80, 11, 80, 12, 80, 498, 1, 81, 4, 81, 502, 8, 81, 11, 81, 12, 81, 503, 1, 82, 1, 82, 5, 82, 508, 8, 82, 10, 82, 12, 82, 511, 9, 82, 1, 83, 1, 83, 3, 83, 515, 8, 83, 1, 83, 3, 83, 518, 8, 83, 1, 83, 1, 83, 3, 83, 522, 8, 83, 0, 0, 84, 1, 3, 3, 4, 5, 5, 7, 6, 9, 7, 11, 8, 13, 9, 15, 10, 17, 11, 19, 12, 21, 13, 23, 14, 25, 15, 27, 16, 29, 17, 31, 18, 33, 19, 35, 20, 37, 21, 39, 22, 41, 23, 43, 24, 45, 25, 47, 26, 49, 27, 51, 28, 53, 29, 55, 30, 57, 31, 59, 32, 61, 33, 63, 34, 65, 35, 67, 36, 69, 37, 71, 38, 73, 39, 75, 40, 77, 41, 79, 42, 81, 43, 83, 44, 85, 45, 87, 46, 89, 47, 91, 48, 93, 49, 95, 50, 97, 51, 99, 52, 101, 53, 103, 54, 105, 55, 107, 56, 109, 57, 111, 58, 113, 59, 115, 60, 117, 61, 119, 62, 121, 63, 123, 64, 125, 65, 127, 66, 129, 67, 131, 68, 133, 69, 135, 70, 137, 71, 139, 72, 141, 73, 143, 74, 145, 75, 147, 76, 149, 0, 151, 0, 153, 0, 155, 0, 157, 0, 159, 0, 161, 0, 163, 0, 165, 0, 167, 0, 1, 0, 10, 4, 0, 10, 10, 12, 13, 39, 39, 92, 92, 4, 0, 10, 10, 12, 13, 34, 34, 92, 92, 3, 0, 65, 90, 95, 95, 97, 122, 4, 0, 48, 57, 65, 90, 95, 95, 97, 122, 1, 0, 49, 57, 1, 0, 48, 57, 2, 0, 69, 69, 101, 101, 2, 0, 43, 43, 45, 45, 2, 0, 9, 9, 32, 32, 2, 0, 10, 10, 12, 13, 542, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 93, 1, 0, 0, 0, 0, 95, 1, 0, 0, 0, 0, 97, 1, 0, 0, 0, 0, 99, 1, 0, 0, 0, 0, 101, 1, 0, 0, 0, 0, 103, 1, 0, 0, 0, 0, 105, 1, 0, 0, 0, 0, 107, 1, 0, 0, 0, 0, 109, 1, 0, 0, 0, 0, 111, 1, 0, 0, 0, 0, 113, 1, 0, 0, 0, 0, 115, 1, 0, 0, 0, 0, 117, 1, 0, 0, 0, 0, 119, 1, 0, 0, 0, 0, 121, 1, 0, 0, 0, 0, 123, 1, 0, 0, 0, 0, 125, 1, 0, 0, 0, 0, 127, 1, 0, 0, 0, 0, 129, 1, 0, 0, 0, 0, 131, 1, 0, 0, 0, 0, 133, 1, 0, 0, 0, 0, 135, 1, 0, 0, 0, 0, 137, 1, 0, 0, 0, 0, 139, 1, 0, 0, 0, 0, 141, 1, 0, 0, 0, 0, 143, 1, 0, 0, 0, 0, 145, 1, 0, 0, 0, 0, 147, 1, 0, 0, 0, 1, 187, 1, 0, 0, 0, 3, 191, 1, 0, 0, 0, 5, 193, 1, 0, 0, 0, 7, 197, 1, 0, 0, 0, 9, 200, 1, 0, 0, 0, 11, 204, 1, 0, 0, 0, 13, 209, 1, 0, 0, 0, 15, 214, 1, 0, 0, 0, 17, 220, 1, 0, 0, 0, 19, 224, 1, 0, 0, 0, 21, 229, 1, 0, 0, 0, 23, 232, 1, 0, 0, 0, 25, 239, 1, 0, 0, 0, 27, 242, 1, 0, 0, 0, 29, 245, 1, 0, 0, 0, 31, 250, 1, 0, 0, 0, 33, 254, 1, 0, 0, 0, 35, 257, 1, 0, 0, 0, 37, 264, 1, 0, 0, 0, 39, 269, 1, 0, 0, 0, 41, 271, 1, 0, 0, 0, 43, 289, 1, 0, 0, 0, 45, 293, 1, 0, 0, 0, 47, 312, 1, 0, 0, 0, 49, 316, 1, 0, 0, 0, 51, 318, 1, 0, 0, 0, 53, 320, 1, 0, 0, 0, 55, 324, 1, 0, 0, 0, 57, 326, 1, 0, 0, 0, 59, 329, 1, 0, 0, 0, 61, 332, 1, 0, 0, 0, 63, 334, 1, 0, 0, 0, 65, 336, 1, 0, 0, 0, 67, 338, 1, 0, 0, 0, 69, 341, 1, 0, 0, 0, 71, 343, 1, 0, 0, 0, 73, 346, 1, 0, 0, 0, 75, 349, 1, 0, 0, 0, 77, 351, 1, 0, 0, 0, 79, 353, 1, 0, 0, 0, 81, 355, 1, 0, 0, 0, 83, 358, 1, 0, 0, 0, 85, 361, 1, 0, 0, 0, 87, 363, 1, 0, 0, 0, 89, 365, 1, 0, 0, 0, 91, 367, 1, 0, 0, 0, 93, 369, 1, 0, 0, 0, 95, 372, 1, 0, 0, 0, 97, 374, 1, 0, 0, 0, 99, 377, 1, 0, 0, 0, 101, 380, 1, 0, 0, 0, 103, 382, 1, 0, 0, 0, 105, 384, 1, 0, 0, 0, 107, 387, 1, 0, 0, 0, 109, 390, 1, 0, 0, 0, 111, 393, 1, 0, 0, 0, 113, 396, 1, 0, 0, 0, 115, 399, 1, 0, 0, 0, 117, 401, 1, 0, 0, 0, 119, 404, 1, 0, 0, 0, 121, 407, 1, 0, 0, 0, 123, 410, 1, 0, 0, 0, 125, 413, 1, 0, 0, 0, 127, 416, 1, 0, 0, 0, 129, 419, 1, 0, 0, 0, 131, 422, 1, 0, 0, 0, 133, 425, 1, 0, 0, 0, 135, 428, 1, 0, 0, 0, 137, 431, 1, 0, 0, 0, 139, 435, 1, 0, 0, 0, 141, 439, 1, 0, 0, 0, 143, 443, 1, 0, 0, 0, 145, 450, 1, 0, 0, 0, 147, 454, 1, 0, 0, 0, 149, 460, 1, 0, 0, 0, 151, 462, 1, 0, 0, 0, 153, 464, 1, 0, 0, 0, 155, 478, 1, 0, 0, 0, 157, 482, 1, 0, 0, 0, 159, 487, 1, 0, 0, 0, 161, 491, 1, 0, 0, 0, 163, 501, 1, 0, 0, 0, 165, 505, 1, 0, 0, 0, 167, 512, 1, 0, 0, 0, 169, 174, 5, 39, 0, 0, 170, 173, 3, 149, 74, 0, 171, 173, 8, 0, 0, 0, 172, 170, 1, 0, 0, 0, 172, 171, 1, 0, 0, 0, 173, 176, 1, 0, 0, 0, 174, 172, 1, 0, 0, 0, 174, 175, 1, 0, 0, 0, 175, 177, 1, 0, 0, 0, 176, 174, 1, 0, 0, 0, 177, 188, 5, 39, 0, 0, 178, 183, 5, 34, 0, 0, 179, 182, 3, 149, 74, 0, 180, 182, 8, 1, 0, 0, 181, 179, 1, 0, 0, 0, 181, 180, 1, 0, 0, 0, 182, 185, 1, 0, 0, 0, 183, 181, 1, 0, 0, 0, 183, 184, 1, 0, 0, 0, 184, 186, 1, 0, 0, 0, 185, 183, 1, 0, 0, 0, 186, 188, 5, 34, 0, 0, 187, 169, 1, 0, 0, 0, 187, 178, 1, 0, 0, 0, 188, 2, 1, 0, 0, 0, 189, 192, 3, 47, 23, 0, 190, 192, 3, 49, 24, 0, 191, 189, 1, 0, 0, 0, 191, 190, 1, 0, 0, 0, 192, 4, 1, 0, 0, 0, 193, 194, 5, 97, 0, 0, 194, 195, 5, 110, 0, 0, 195, 196, 5, 100, 0, 0, 196, 6, 1, 0, 0, 0, 197, 198, 5, 97, 0, 0, 198, 199, 5, 115, 0, 0, 199, 8, 1, 0, 0, 0, 200, 201, 5, 100, 0, 0, 201, 202, 5, 101, 0, 0, 202, 203, 5, 102, 0, 0, 203, 10, 1, 0, 0, 0, 204, 205, 5, 101, 0, 0, 205, 206, 5, 108, 0, 0, 206, 207, 5, 105, 0, 0, 207, 208, 5, 102, 0, 0, 208, 12, 1, 0, 0, 0, 209, 210, 5, 101, 0, 0, 210, 211, 5, 108, 0, 0, 211, 212, 5, 115, 0, 0, 212, 213, 5, 101, 0, 0, 213, 14, 1, 0, 0, 0, 214, 215, 5, 70, 0, 0, 215, 216, 5, 97, 0, 0, 216, 217, 5, 108, 0, 0, 217, 218, 5, 115, 0, 0, 218, 219, 5, 101, 0, 0, 219, 16, 1, 0, 0, 0, 220, 221, 5, 102, 0, 0, 221, 222, 5, 111, 0, 0, 222, 223, 5, 114, 0, 0, 223, 18, 1, 0, 0, 0, 224, 225, 5, 102, 0, 0, 225, 226, 5, 114, 0, 0, 226, 227, 5, 111, 0, 0, 227, 228, 5, 109, 0, 0, 228, 20, 1, 0, 0, 0, 229, 230, 5, 105, 0, 0, 230, 231, 5, 102, 0, 0, 231, 22, 1, 0, 0, 0, 232, 233, 5, 105, 0, 0, 233, 234, 5, 109, 0, 0, 234, 235, 5, 112, 0, 0, 235, 236, 5, 111, 0, 0, 236, 237, 5, 114, 0, 0, 237, 238, 5, 116, 0, 0, 238, 24, 1, 0, 0, 0, 239, 240, 5, 105, 0, 0, 240, 241, 5, 110, 0, 0, 241, 26, 1, 0, 0, 0, 242, 243, 5, 105, 0, 0, 243, 244, 5, 115, 0, 0, 244, 28, 1, 0, 0, 0, 245, 246, 5, 78, 0, 0, 246, 247, 5, 111, 0, 0, 247, 248, 5, 110, 0, 0, 248, 249, 5, 101, 0, 0, 249, 30, 1, 0, 0, 0, 250, 251, 5, 110, 0, 0, 251, 252, 5, 111, 0, 0, 252, 253, 5, 116, 0, 0, 253, 32, 1, 0, 0, 0, 254, 255, 5, 111, 0, 0, 255, 256, 5, 114, 0, 0, 256, 34, 1, 0, 0, 0, 257, 258, 5, 114, 0, 0, 258, 259, 5, 101, 0, 0, 259, 260, 5, 116, 0, 0, 260, 261, 5, 117, 0, 0, 261, 262, 5, 114, 0, 0, 262, 263, 5, 110, 0, 0, 263, 36, 1, 0, 0, 0, 264, 265, 5, 84, 0, 0, 265, 266, 5, 114, 0, 0, 266, 267, 5, 117, 0, 0, 267, 268, 5, 101, 0, 0, 268, 38, 1, 0, 0, 0, 269, 270, 5, 95, 0, 0, 270, 40, 1, 0, 0, 0, 271, 272, 5, 119, 0, 0, 272, 273, 5, 104, 0, 0, 273, 274, 5, 105, 0, 0, 274, 275, 5, 108, 0, 0, 275, 276, 5, 101, 0, 0, 276, 42, 1, 0, 0, 0, 277, 278, 4, 21, 0, 0, 278, 290, 3, 163, 81, 0, 279, 281, 5, 13, 0, 0, 280, 279, 1, 0, 0, 0, 280, 281, 1, 0, 0, 0, 281, 282, 1, 0, 0, 0, 282, 285, 5, 10, 0, 0, 283, 285, 2, 12, 13, 0, 284, 280, 1, 0, 0, 0, 284, 283, 1, 0, 0, 0, 285, 287, 1, 0, 0, 0, 286, 288, 3, 163, 81, 0, 287, 286, 1, 0, 0, 0, 287, 288, 1, 0, 0, 0, 288, 290, 1, 0, 0, 0, 289, 277, 1, 0, 0, 0, 289, 284, 1, 0, 0, 0, 290, 291, 1, 0, 0, 0, 291, 292, 6, 21, 0, 0, 292, 44, 1, 0, 0, 0, 293, 297, 7, 2, 0, 0, 294, 296, 7, 3, 0, 0, 295, 294, 1, 0, 0, 0, 296, 299, 1, 0, 0, 0, 297, 295, 1, 0, 0, 0, 297, 298, 1, 0, 0, 0, 298, 46, 1, 0, 0, 0, 299, 297, 1, 0, 0, 0, 300, 304, 3, 151, 75, 0, 301, 303, 3, 153, 76, 0, 302, 301, 1, 0, 0, 0, 303, 306, 1, 0, 0, 0, 304, 302, 1, 0, 0, 0, 304, 305, 1, 0, 0, 0, 305, 313, 1, 0, 0, 0, 306, 304, 1, 0, 0, 0, 307, 309, 5, 48, 0, 0, 308, 307, 1, 0, 0, 0, 309, 310, 1, 0, 0, 0, 310, 308, 1, 0, 0, 0, 310, 311, 1, 0, 0, 0, 311, 313, 1, 0, 0, 0, 312, 300, 1, 0, 0, 0, 312, 308, 1, 0, 0, 0, 313, 48, 1, 0, 0, 0, 314, 317, 3, 155, 77, 0, 315, 317, 3, 157, 78, 0, 316, 314, 1, 0, 0, 0, 316, 315, 1, 0, 0, 0, 317, 50, 1, 0, 0, 0, 318, 319, 5, 46, 0, 0, 319, 52, 1, 0, 0, 0, 320, 321, 5, 46, 0, 0, 321, 322, 5, 46, 0, 0, 322, 323, 5, 46, 0, 0, 323, 54, 1, 0, 0, 0, 324, 325, 5, 42, 0, 0, 325, 56, 1, 0, 0, 0, 326, 327, 5, 40, 0, 0, 327, 328, 6, 28, 1, 0, 328, 58, 1, 0, 0, 0, 329, 330, 5, 41, 0, 0, 330, 331, 6, 29, 2, 0, 331, 60, 1, 0, 0, 0, 332, 333, 5, 44, 0, 0, 333, 62, 1, 0, 0, 0, 334, 335, 5, 58, 0, 0, 335, 64, 1, 0, 0, 0, 336, 337, 5, 59, 0, 0, 337, 66, 1, 0, 0, 0, 338, 339, 5, 42, 0, 0, 339, 340, 5, 42, 0, 0, 340, 68, 1, 0, 0, 0, 341, 342, 5, 61, 0, 0, 342, 70, 1, 0, 0, 0, 343, 344, 5, 91, 0, 0, 344, 345, 6, 35, 3, 0, 345, 72, 1, 0, 0, 0, 346, 347, 5, 93, 0, 0, 347, 348, 6, 36, 4, 0, 348, 74, 1, 0, 0, 0, 349, 350, 5, 124, 0, 0, 350, 76, 1, 0, 0, 0, 351, 352, 5, 94, 0, 0, 352, 78, 1, 0, 0, 0, 353, 354, 5, 38, 0, 0, 354, 80, 1, 0, 0, 0, 355, 356, 5, 60, 0, 0, 356, 357, 5, 60, 0, 0, 357, 82, 1, 0, 0, 0, 358, 359, 5, 62, 0, 0, 359, 360, 5, 62, 0, 0, 360, 84, 1, 0, 0, 0, 361, 362, 5, 43, 0, 0, 362, 86, 1, 0, 0, 0, 363, 364, 5, 45, 0, 0, 364, 88, 1, 0, 0, 0, 365, 366, 5, 47, 0, 0, 366, 90, 1, 0, 0, 0, 367, 368, 5, 37, 0, 0, 368, 92, 1, 0, 0, 0, 369, 370, 5, 47, 0, 0, 370, 371, 5, 47, 0, 0, 371, 94, 1, 0, 0, 0, 372, 373, 5, 126, 0, 0, 373, 96, 1, 0, 0, 0, 374, 375, 5, 123, 0, 0, 375, 376, 6, 48, 5, 0, 376, 98, 1, 0, 0, 0, 377, 378, 5, 125, 0, 0, 378, 379, 6, 49, 6, 0, 379, 100, 1, 0, 0, 0, 380, 381, 5, 60, 0, 0, 381, 102, 1, 0, 0, 0, 382, 383, 5, 62, 0, 0, 383, 104, 1, 0, 0, 0, 384, 385, 5, 61, 0, 0, 385, 386, 5, 61, 0, 0, 386, 106, 1, 0, 0, 0, 387, 388, 5, 62, 0, 0, 388, 389, 5, 61, 0, 0, 389, 108, 1, 0, 0, 0, 390, 391, 5, 60, 0, 0, 391, 392, 5, 61, 0, 0, 392, 110, 1, 0, 0, 0, 393, 394, 5, 60, 0, 0, 394, 395, 5, 62, 0, 0, 395, 112, 1, 0, 0, 0, 396, 397, 5, 33, 0, 0, 397, 398, 5, 61, 0, 0, 398, 114, 1, 0, 0, 0, 399, 400, 5, 64, 0, 0, 400, 116, 1, 0, 0, 0, 401, 402, 5, 45, 0, 0, 402, 403, 5, 62, 0, 0, 403, 118, 1, 0, 0, 0, 404, 405, 5, 43, 0, 0, 405, 406, 5, 61, 0, 0, 406, 120, 1, 0, 0, 0, 407, 408, 5, 45, 0, 0, 408, 409, 5, 61, 0, 0, 409, 122, 1, 0, 0, 0, 410, 411, 5, 42, 0, 0, 411, 412, 5, 61, 0, 0, 412, 124, 1, 0, 0, 0, 413, 414, 5, 64, 0, 0, 414, 415, 5, 61, 0, 0, 415, 126, 1, 0, 0, 0, 416, 417, 5, 47, 0, 0, 417, 418, 5, 61, 0, 0, 418, 128, 1, 0, 0, 0, 419, 420, 5, 37, 0, 0, 420, 421, 5, 61, 0, 0, 421, 130, 1, 0, 0, 0, 422, 423, 5, 38, 0, 0, 423, 424, 5, 61, 0, 0, 424, 132, 1, 0, 0, 0, 425, 426, 5, 124, 0, 0, 426, 427, 5, 61, 0, 0, 427, 134, 1, 0, 0, 0, 428, 429, 5, 94, 0, 0, 429, 430, 5, 61, 0, 0, 430, 136, 1, 0, 0, 0, 431, 432, 5, 60, 0, 0, 432, 433, 5, 60, 0, 0, 433, 434, 5, 61, 0, 0, 434, 138, 1, 0, 0, 0, 435, 436, 5, 62, 0, 0, 436, 437, 5, 62, 0, 0, 437, 438, 5, 61, 0, 0, 438, 140, 1, 0, 0, 0, 439, 440, 5, 42, 0, 0, 440, 441, 5, 42, 0, 0, 441, 442, 5, 61, 0, 0, 442, 142, 1, 0, 0, 0, 443, 444, 5, 47, 0, 0, 444, 445, 5, 47, 0, 0, 445, 446, 5, 61, 0, 0, 446, 144, 1, 0, 0, 0, 447, 451, 3, 163, 81, 0, 448, 451, 3, 165, 82, 0, 449, 451, 3, 167, 83, 0, 450, 447, 1, 0, 0, 0, 450, 448, 1, 0, 0, 0, 450, 449, 1, 0, 0, 0, 451, 452, 1, 0, 0, 0, 452, 453, 6, 72, 7, 0, 453, 146, 1, 0, 0, 0, 454, 455, 9, 0, 0, 0, 455, 148, 1, 0, 0, 0, 456, 457, 5, 92, 0, 0, 457, 461, 9, 0, 0, 0, 458, 459, 5, 92, 0, 0, 459, 461, 3, 43, 21, 0, 460, 456, 1, 0, 0, 0, 460, 458, 1, 0, 0, 0, 461, 150, 1, 0, 0, 0, 462, 463, 7, 4, 0, 0, 463, 152, 1, 0, 0, 0, 464, 465, 7, 5, 0, 0, 465, 154, 1, 0, 0, 0, 466, 468, 3, 159, 79, 0, 467, 466, 1, 0, 0, 0, 467, 468, 1, 0, 0, 0, 468, 469, 1, 0, 0, 0, 469, 471, 5, 46, 0, 0, 470, 472, 3, 153, 76, 0, 471, 470, 1, 0, 0, 0, 472, 473, 1, 0, 0, 0, 473, 471, 1, 0, 0, 0, 473, 474, 1, 0, 0, 0, 474, 479, 1, 0, 0, 0, 475, 476, 3, 159, 79, 0, 476, 477, 5, 46, 0, 0, 477, 479, 1, 0, 0, 0, 478, 467, 1, 0, 0, 0, 478, 475, 1, 0, 0, 0, 479, 156, 1, 0, 0, 0, 480, 483, 3, 159, 79, 0, 481, 483, 3, 155, 77, 0, 482, 480, 1, 0, 0, 0, 482, 481, 1, 0, 0, 0, 483, 484, 1, 0, 0, 0, 484, 485, 3, 161, 80, 0, 485, 158, 1, 0, 0, 0, 486, 488, 3, 153, 76, 0, 487, 486, 1, 0, 0, 0, 488, 489, 1, 0, 0, 0, 489, 487, 1, 0, 0, 0, 489, 490, 1, 0, 0, 0, 490, 160, 1, 0, 0, 0, 491, 493, 7, 6, 0, 0, 492, 494, 7, 7, 0, 0, 493, 492, 1, 0, 0, 0, 493, 494, 1, 0, 0, 0, 494, 496, 1, 0, 0, 0, 495, 497, 3, 153, 76, 0, 496, 495, 1, 0, 0, 0, 497, 498, 1, 0, 0, 0, 498, 496, 1, 0, 0, 0, 498, 499, 1, 0, 0, 0, 499, 162, 1, 0, 0, 0, 500, 502, 7, 8, 0, 0, 501, 500, 1, 0, 0, 0, 502, 503, 1, 0, 0, 0, 503, 501, 1, 0, 0, 0, 503, 504, 1, 0, 0, 0, 504, 164, 1, 0, 0, 0, 505, 509, 5, 35, 0, 0, 506, 508, 8, 9, 0, 0, 507, 506, 1, 0, 0, 0, 508, 511, 1, 0, 0, 0, 509, 507, 1, 0, 0, 0, 509, 510, 1, 0, 0, 0, 510, 166, 1, 0, 0, 0, 511, 509, 1, 0, 0, 0, 512, 514, 5, 92, 0, 0, 513, 515, 3, 163, 81, 0, 514, 513, 1, 0, 0, 0, 514, 515, 1, 0, 0, 0, 515, 521, 1, 0, 0, 0, 516, 518, 5, 13, 0, 0, 517, 516, 1, 0, 0, 0, 517, 518, 1, 0, 0, 0, 518, 519, 1, 0, 0, 0, 519, 522, 5, 10, 0, 0, 520, 522, 2, 12, 13, 0, 521, 517, 1, 0, 0, 0, 521, 520, 1, 0, 0, 0, 522, 168, 1, 0, 0, 0, 30, 0, 172, 174, 181, 183, 187, 191, 280, 284, 287, 289, 297, 304, 310, 312, 316, 450, 460, 467, 473, 478, 482, 489, 493, 498, 503, 509, 514, 517, 521, 8, 1, 21, 0, 1, 28, 1, 1, 29, 2, 1, 35, 3, 1, 36, 4, 1, 48, 5, 1, 49, 6, 6, 0, 0]
\ No newline at end of file diff --git a/src/Python3Lexer.java b/src/Python3Lexer.java new file mode 100644 index 0000000..860d757 --- /dev/null +++ b/src/Python3Lexer.java @@ -0,0 +1,574 @@ +// Generated from src/Python3Lexer.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) +public class Python3Lexer extends Python3LexerBase { +	static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + +	protected static final DFA[] _decisionToDFA; +	protected static final PredictionContextCache _sharedContextCache = +		new PredictionContextCache(); +	public static final int +		INDENT=1, DEDENT=2, STRING=3, NUMBER=4, AND=5, AS=6, DEF=7, ELIF=8, ELSE=9,  +		FALSE=10, FOR=11, FROM=12, IF=13, IMPORT=14, IN=15, IS=16, NONE=17, NOT=18,  +		OR=19, RETURN=20, TRUE=21, UNDERSCORE=22, WHILE=23, NEWLINE=24, NAME=25,  +		DECIMAL_INTEGER=26, FLOAT_NUMBER=27, DOT=28, ELLIPSIS=29, STAR=30, OPEN_PAREN=31,  +		CLOSE_PAREN=32, COMMA=33, COLON=34, SEMI_COLON=35, POWER=36, ASSIGN=37,  +		OPEN_BRACK=38, CLOSE_BRACK=39, OR_OP=40, XOR=41, AND_OP=42, LEFT_SHIFT=43,  +		RIGHT_SHIFT=44, ADD=45, MINUS=46, DIV=47, MOD=48, IDIV=49, NOT_OP=50,  +		OPEN_BRACE=51, CLOSE_BRACE=52, LESS_THAN=53, GREATER_THAN=54, EQUALS=55,  +		GT_EQ=56, LT_EQ=57, NOT_EQ_1=58, NOT_EQ_2=59, AT=60, ARROW=61, ADD_ASSIGN=62,  +		SUB_ASSIGN=63, MULT_ASSIGN=64, AT_ASSIGN=65, DIV_ASSIGN=66, MOD_ASSIGN=67,  +		AND_ASSIGN=68, OR_ASSIGN=69, XOR_ASSIGN=70, LEFT_SHIFT_ASSIGN=71, RIGHT_SHIFT_ASSIGN=72,  +		POWER_ASSIGN=73, IDIV_ASSIGN=74, SKIP_=75, UNKNOWN_CHAR=76; +	public static String[] channelNames = { +		"DEFAULT_TOKEN_CHANNEL", "HIDDEN" +	}; + +	public static String[] modeNames = { +		"DEFAULT_MODE" +	}; + +	private static String[] makeRuleNames() { +		return new String[] { +			"STRING", "NUMBER", "AND", "AS", "DEF", "ELIF", "ELSE", "FALSE", "FOR",  +			"FROM", "IF", "IMPORT", "IN", "IS", "NONE", "NOT", "OR", "RETURN", "TRUE",  +			"UNDERSCORE", "WHILE", "NEWLINE", "NAME", "DECIMAL_INTEGER", "FLOAT_NUMBER",  +			"DOT", "ELLIPSIS", "STAR", "OPEN_PAREN", "CLOSE_PAREN", "COMMA", "COLON",  +			"SEMI_COLON", "POWER", "ASSIGN", "OPEN_BRACK", "CLOSE_BRACK", "OR_OP",  +			"XOR", "AND_OP", "LEFT_SHIFT", "RIGHT_SHIFT", "ADD", "MINUS", "DIV",  +			"MOD", "IDIV", "NOT_OP", "OPEN_BRACE", "CLOSE_BRACE", "LESS_THAN", "GREATER_THAN",  +			"EQUALS", "GT_EQ", "LT_EQ", "NOT_EQ_1", "NOT_EQ_2", "AT", "ARROW", "ADD_ASSIGN",  +			"SUB_ASSIGN", "MULT_ASSIGN", "AT_ASSIGN", "DIV_ASSIGN", "MOD_ASSIGN",  +			"AND_ASSIGN", "OR_ASSIGN", "XOR_ASSIGN", "LEFT_SHIFT_ASSIGN", "RIGHT_SHIFT_ASSIGN",  +			"POWER_ASSIGN", "IDIV_ASSIGN", "SKIP_", "UNKNOWN_CHAR", "STRING_ESCAPE_SEQ",  +			"NON_ZERO_DIGIT", "DIGIT", "POINT_FLOAT", "EXPONENT_FLOAT", "INT_PART",  +			"EXPONENT", "SPACES", "COMMENT", "LINE_JOINING" +		}; +	} +	public static final String[] ruleNames = makeRuleNames(); + +	private static String[] makeLiteralNames() { +		return new String[] { +			null, null, null, null, null, "'and'", "'as'", "'def'", "'elif'", "'else'",  +			"'False'", "'for'", "'from'", "'if'", "'import'", "'in'", "'is'", "'None'",  +			"'not'", "'or'", "'return'", "'True'", "'_'", "'while'", null, null,  +			null, null, "'.'", "'...'", "'*'", "'('", "')'", "','", "':'", "';'",  +			"'**'", "'='", "'['", "']'", "'|'", "'^'", "'&'", "'<<'", "'>>'", "'+'",  +			"'-'", "'/'", "'%'", "'//'", "'~'", "'{'", "'}'", "'<'", "'>'", "'=='",  +			"'>='", "'<='", "'<>'", "'!='", "'@'", "'->'", "'+='", "'-='", "'*='",  +			"'@='", "'/='", "'%='", "'&='", "'|='", "'^='", "'<<='", "'>>='", "'**='",  +			"'//='" +		}; +	} +	private static final String[] _LITERAL_NAMES = makeLiteralNames(); +	private static String[] makeSymbolicNames() { +		return new String[] { +			null, "INDENT", "DEDENT", "STRING", "NUMBER", "AND", "AS", "DEF", "ELIF",  +			"ELSE", "FALSE", "FOR", "FROM", "IF", "IMPORT", "IN", "IS", "NONE", "NOT",  +			"OR", "RETURN", "TRUE", "UNDERSCORE", "WHILE", "NEWLINE", "NAME", "DECIMAL_INTEGER",  +			"FLOAT_NUMBER", "DOT", "ELLIPSIS", "STAR", "OPEN_PAREN", "CLOSE_PAREN",  +			"COMMA", "COLON", "SEMI_COLON", "POWER", "ASSIGN", "OPEN_BRACK", "CLOSE_BRACK",  +			"OR_OP", "XOR", "AND_OP", "LEFT_SHIFT", "RIGHT_SHIFT", "ADD", "MINUS",  +			"DIV", "MOD", "IDIV", "NOT_OP", "OPEN_BRACE", "CLOSE_BRACE", "LESS_THAN",  +			"GREATER_THAN", "EQUALS", "GT_EQ", "LT_EQ", "NOT_EQ_1", "NOT_EQ_2", "AT",  +			"ARROW", "ADD_ASSIGN", "SUB_ASSIGN", "MULT_ASSIGN", "AT_ASSIGN", "DIV_ASSIGN",  +			"MOD_ASSIGN", "AND_ASSIGN", "OR_ASSIGN", "XOR_ASSIGN", "LEFT_SHIFT_ASSIGN",  +			"RIGHT_SHIFT_ASSIGN", "POWER_ASSIGN", "IDIV_ASSIGN", "SKIP_", "UNKNOWN_CHAR" +		}; +	} +	private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); +	public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + +	/** +	 * @deprecated Use {@link #VOCABULARY} instead. +	 */ +	@Deprecated +	public static final String[] tokenNames; +	static { +		tokenNames = new String[_SYMBOLIC_NAMES.length]; +		for (int i = 0; i < tokenNames.length; i++) { +			tokenNames[i] = VOCABULARY.getLiteralName(i); +			if (tokenNames[i] == null) { +				tokenNames[i] = VOCABULARY.getSymbolicName(i); +			} + +			if (tokenNames[i] == null) { +				tokenNames[i] = "<INVALID>"; +			} +		} +	} + +	@Override +	@Deprecated +	public String[] getTokenNames() { +		return tokenNames; +	} + +	@Override + +	public Vocabulary getVocabulary() { +		return VOCABULARY; +	} + + +	public Python3Lexer(CharStream input) { +		super(input); +		_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); +	} + +	@Override +	public String getGrammarFileName() { return "Python3Lexer.g4"; } + +	@Override +	public String[] getRuleNames() { return ruleNames; } + +	@Override +	public String getSerializedATN() { return _serializedATN; } + +	@Override +	public String[] getChannelNames() { return channelNames; } + +	@Override +	public String[] getModeNames() { return modeNames; } + +	@Override +	public ATN getATN() { return _ATN; } + +	@Override +	public void action(RuleContext _localctx, int ruleIndex, int actionIndex) { +		switch (ruleIndex) { +		case 21: +			NEWLINE_action((RuleContext)_localctx, actionIndex); +			break; +		case 28: +			OPEN_PAREN_action((RuleContext)_localctx, actionIndex); +			break; +		case 29: +			CLOSE_PAREN_action((RuleContext)_localctx, actionIndex); +			break; +		case 35: +			OPEN_BRACK_action((RuleContext)_localctx, actionIndex); +			break; +		case 36: +			CLOSE_BRACK_action((RuleContext)_localctx, actionIndex); +			break; +		case 48: +			OPEN_BRACE_action((RuleContext)_localctx, actionIndex); +			break; +		case 49: +			CLOSE_BRACE_action((RuleContext)_localctx, actionIndex); +			break; +		} +	} +	private void NEWLINE_action(RuleContext _localctx, int actionIndex) { +		switch (actionIndex) { +		case 0: +			this.onNewLine(); +			break; +		} +	} +	private void OPEN_PAREN_action(RuleContext _localctx, int actionIndex) { +		switch (actionIndex) { +		case 1: +			this.openBrace(); +			break; +		} +	} +	private void CLOSE_PAREN_action(RuleContext _localctx, int actionIndex) { +		switch (actionIndex) { +		case 2: +			this.closeBrace(); +			break; +		} +	} +	private void OPEN_BRACK_action(RuleContext _localctx, int actionIndex) { +		switch (actionIndex) { +		case 3: +			this.openBrace(); +			break; +		} +	} +	private void CLOSE_BRACK_action(RuleContext _localctx, int actionIndex) { +		switch (actionIndex) { +		case 4: +			this.closeBrace(); +			break; +		} +	} +	private void OPEN_BRACE_action(RuleContext _localctx, int actionIndex) { +		switch (actionIndex) { +		case 5: +			this.openBrace(); +			break; +		} +	} +	private void CLOSE_BRACE_action(RuleContext _localctx, int actionIndex) { +		switch (actionIndex) { +		case 6: +			this.closeBrace(); +			break; +		} +	} +	@Override +	public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { +		switch (ruleIndex) { +		case 21: +			return NEWLINE_sempred((RuleContext)_localctx, predIndex); +		} +		return true; +	} +	private boolean NEWLINE_sempred(RuleContext _localctx, int predIndex) { +		switch (predIndex) { +		case 0: +			return this.atStartOfInput(); +		} +		return true; +	} + +	public static final String _serializedATN = +		"\u0004\u0000L\u020b\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+ +		"\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+ +		"\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007"+ +		"\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b"+ +		"\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0002"+ +		"\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011\u0002"+ +		"\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014\u0002"+ +		"\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002"+ +		"\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0002"+ +		"\u001b\u0007\u001b\u0002\u001c\u0007\u001c\u0002\u001d\u0007\u001d\u0002"+ +		"\u001e\u0007\u001e\u0002\u001f\u0007\u001f\u0002 \u0007 \u0002!\u0007"+ +		"!\u0002\"\u0007\"\u0002#\u0007#\u0002$\u0007$\u0002%\u0007%\u0002&\u0007"+ +		"&\u0002\'\u0007\'\u0002(\u0007(\u0002)\u0007)\u0002*\u0007*\u0002+\u0007"+ +		"+\u0002,\u0007,\u0002-\u0007-\u0002.\u0007.\u0002/\u0007/\u00020\u0007"+ +		"0\u00021\u00071\u00022\u00072\u00023\u00073\u00024\u00074\u00025\u0007"+ +		"5\u00026\u00076\u00027\u00077\u00028\u00078\u00029\u00079\u0002:\u0007"+ +		":\u0002;\u0007;\u0002<\u0007<\u0002=\u0007=\u0002>\u0007>\u0002?\u0007"+ +		"?\u0002@\u0007@\u0002A\u0007A\u0002B\u0007B\u0002C\u0007C\u0002D\u0007"+ +		"D\u0002E\u0007E\u0002F\u0007F\u0002G\u0007G\u0002H\u0007H\u0002I\u0007"+ +		"I\u0002J\u0007J\u0002K\u0007K\u0002L\u0007L\u0002M\u0007M\u0002N\u0007"+ +		"N\u0002O\u0007O\u0002P\u0007P\u0002Q\u0007Q\u0002R\u0007R\u0002S\u0007"+ +		"S\u0001\u0000\u0001\u0000\u0001\u0000\u0005\u0000\u00ad\b\u0000\n\u0000"+ +		"\f\u0000\u00b0\t\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000"+ +		"\u0005\u0000\u00b6\b\u0000\n\u0000\f\u0000\u00b9\t\u0000\u0001\u0000\u0003"+ +		"\u0000\u00bc\b\u0000\u0001\u0001\u0001\u0001\u0003\u0001\u00c0\b\u0001"+ +		"\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+ +		"\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005"+ +		"\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006"+ +		"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0001\u0007"+ +		"\u0001\u0007\u0001\u0007\u0001\u0007\u0001\b\u0001\b\u0001\b\u0001\b\u0001"+ +		"\t\u0001\t\u0001\t\u0001\t\u0001\t\u0001\n\u0001\n\u0001\n\u0001\u000b"+ +		"\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b\u0001\u000b"+ +		"\u0001\f\u0001\f\u0001\f\u0001\r\u0001\r\u0001\r\u0001\u000e\u0001\u000e"+ +		"\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000f\u0001\u000f\u0001\u000f"+ +		"\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011"+ +		"\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0012"+ +		"\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0013\u0001\u0013"+ +		"\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014"+ +		"\u0001\u0015\u0001\u0015\u0001\u0015\u0003\u0015\u0119\b\u0015\u0001\u0015"+ +		"\u0001\u0015\u0003\u0015\u011d\b\u0015\u0001\u0015\u0003\u0015\u0120\b"+ +		"\u0015\u0003\u0015\u0122\b\u0015\u0001\u0015\u0001\u0015\u0001\u0016\u0001"+ +		"\u0016\u0005\u0016\u0128\b\u0016\n\u0016\f\u0016\u012b\t\u0016\u0001\u0017"+ +		"\u0001\u0017\u0005\u0017\u012f\b\u0017\n\u0017\f\u0017\u0132\t\u0017\u0001"+ +		"\u0017\u0004\u0017\u0135\b\u0017\u000b\u0017\f\u0017\u0136\u0003\u0017"+ +		"\u0139\b\u0017\u0001\u0018\u0001\u0018\u0003\u0018\u013d\b\u0018\u0001"+ +		"\u0019\u0001\u0019\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001a\u0001"+ +		"\u001b\u0001\u001b\u0001\u001c\u0001\u001c\u0001\u001c\u0001\u001d\u0001"+ +		"\u001d\u0001\u001d\u0001\u001e\u0001\u001e\u0001\u001f\u0001\u001f\u0001"+ +		" \u0001 \u0001!\u0001!\u0001!\u0001\"\u0001\"\u0001#\u0001#\u0001#\u0001"+ +		"$\u0001$\u0001$\u0001%\u0001%\u0001&\u0001&\u0001\'\u0001\'\u0001(\u0001"+ +		"(\u0001(\u0001)\u0001)\u0001)\u0001*\u0001*\u0001+\u0001+\u0001,\u0001"+ +		",\u0001-\u0001-\u0001.\u0001.\u0001.\u0001/\u0001/\u00010\u00010\u0001"+ +		"0\u00011\u00011\u00011\u00012\u00012\u00013\u00013\u00014\u00014\u0001"+ +		"4\u00015\u00015\u00015\u00016\u00016\u00016\u00017\u00017\u00017\u0001"+ +		"8\u00018\u00018\u00019\u00019\u0001:\u0001:\u0001:\u0001;\u0001;\u0001"+ +		";\u0001<\u0001<\u0001<\u0001=\u0001=\u0001=\u0001>\u0001>\u0001>\u0001"+ +		"?\u0001?\u0001?\u0001@\u0001@\u0001@\u0001A\u0001A\u0001A\u0001B\u0001"+ +		"B\u0001B\u0001C\u0001C\u0001C\u0001D\u0001D\u0001D\u0001D\u0001E\u0001"+ +		"E\u0001E\u0001E\u0001F\u0001F\u0001F\u0001F\u0001G\u0001G\u0001G\u0001"+ +		"G\u0001H\u0001H\u0001H\u0003H\u01c3\bH\u0001H\u0001H\u0001I\u0001I\u0001"+ +		"J\u0001J\u0001J\u0001J\u0003J\u01cd\bJ\u0001K\u0001K\u0001L\u0001L\u0001"+ +		"M\u0003M\u01d4\bM\u0001M\u0001M\u0004M\u01d8\bM\u000bM\fM\u01d9\u0001"+ +		"M\u0001M\u0001M\u0003M\u01df\bM\u0001N\u0001N\u0003N\u01e3\bN\u0001N\u0001"+ +		"N\u0001O\u0004O\u01e8\bO\u000bO\fO\u01e9\u0001P\u0001P\u0003P\u01ee\b"+ +		"P\u0001P\u0004P\u01f1\bP\u000bP\fP\u01f2\u0001Q\u0004Q\u01f6\bQ\u000b"+ +		"Q\fQ\u01f7\u0001R\u0001R\u0005R\u01fc\bR\nR\fR\u01ff\tR\u0001S\u0001S"+ +		"\u0003S\u0203\bS\u0001S\u0003S\u0206\bS\u0001S\u0001S\u0003S\u020a\bS"+ +		"\u0000\u0000T\u0001\u0003\u0003\u0004\u0005\u0005\u0007\u0006\t\u0007"+ +		"\u000b\b\r\t\u000f\n\u0011\u000b\u0013\f\u0015\r\u0017\u000e\u0019\u000f"+ +		"\u001b\u0010\u001d\u0011\u001f\u0012!\u0013#\u0014%\u0015\'\u0016)\u0017"+ +		"+\u0018-\u0019/\u001a1\u001b3\u001c5\u001d7\u001e9\u001f; =!?\"A#C$E%"+ +		"G&I\'K(M)O*Q+S,U-W.Y/[0]1_2a3c4e5g6i7k8m9o:q;s<u=w>y?{@}A\u007fB\u0081"+ +		"C\u0083D\u0085E\u0087F\u0089G\u008bH\u008dI\u008fJ\u0091K\u0093L\u0095"+ +		"\u0000\u0097\u0000\u0099\u0000\u009b\u0000\u009d\u0000\u009f\u0000\u00a1"+ +		"\u0000\u00a3\u0000\u00a5\u0000\u00a7\u0000\u0001\u0000\n\u0004\u0000\n"+ +		"\n\f\r\'\'\\\\\u0004\u0000\n\n\f\r\"\"\\\\\u0003\u0000AZ__az\u0004\u0000"+ +		"09AZ__az\u0001\u000019\u0001\u000009\u0002\u0000EEee\u0002\u0000++--\u0002"+ +		"\u0000\t\t  \u0002\u0000\n\n\f\r\u021e\u0000\u0001\u0001\u0000\u0000\u0000"+ +		"\u0000\u0003\u0001\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000\u0000"+ +		"\u0000\u0007\u0001\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000\u0000"+ +		"\u000b\u0001\u0000\u0000\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000\u000f"+ +		"\u0001\u0000\u0000\u0000\u0000\u0011\u0001\u0000\u0000\u0000\u0000\u0013"+ +		"\u0001\u0000\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u0000\u0017"+ +		"\u0001\u0000\u0000\u0000\u0000\u0019\u0001\u0000\u0000\u0000\u0000\u001b"+ +		"\u0001\u0000\u0000\u0000\u0000\u001d\u0001\u0000\u0000\u0000\u0000\u001f"+ +		"\u0001\u0000\u0000\u0000\u0000!\u0001\u0000\u0000\u0000\u0000#\u0001\u0000"+ +		"\u0000\u0000\u0000%\u0001\u0000\u0000\u0000\u0000\'\u0001\u0000\u0000"+ +		"\u0000\u0000)\u0001\u0000\u0000\u0000\u0000+\u0001\u0000\u0000\u0000\u0000"+ +		"-\u0001\u0000\u0000\u0000\u0000/\u0001\u0000\u0000\u0000\u00001\u0001"+ +		"\u0000\u0000\u0000\u00003\u0001\u0000\u0000\u0000\u00005\u0001\u0000\u0000"+ +		"\u0000\u00007\u0001\u0000\u0000\u0000\u00009\u0001\u0000\u0000\u0000\u0000"+ +		";\u0001\u0000\u0000\u0000\u0000=\u0001\u0000\u0000\u0000\u0000?\u0001"+ +		"\u0000\u0000\u0000\u0000A\u0001\u0000\u0000\u0000\u0000C\u0001\u0000\u0000"+ +		"\u0000\u0000E\u0001\u0000\u0000\u0000\u0000G\u0001\u0000\u0000\u0000\u0000"+ +		"I\u0001\u0000\u0000\u0000\u0000K\u0001\u0000\u0000\u0000\u0000M\u0001"+ +		"\u0000\u0000\u0000\u0000O\u0001\u0000\u0000\u0000\u0000Q\u0001\u0000\u0000"+ +		"\u0000\u0000S\u0001\u0000\u0000\u0000\u0000U\u0001\u0000\u0000\u0000\u0000"+ +		"W\u0001\u0000\u0000\u0000\u0000Y\u0001\u0000\u0000\u0000\u0000[\u0001"+ +		"\u0000\u0000\u0000\u0000]\u0001\u0000\u0000\u0000\u0000_\u0001\u0000\u0000"+ +		"\u0000\u0000a\u0001\u0000\u0000\u0000\u0000c\u0001\u0000\u0000\u0000\u0000"+ +		"e\u0001\u0000\u0000\u0000\u0000g\u0001\u0000\u0000\u0000\u0000i\u0001"+ +		"\u0000\u0000\u0000\u0000k\u0001\u0000\u0000\u0000\u0000m\u0001\u0000\u0000"+ +		"\u0000\u0000o\u0001\u0000\u0000\u0000\u0000q\u0001\u0000\u0000\u0000\u0000"+ +		"s\u0001\u0000\u0000\u0000\u0000u\u0001\u0000\u0000\u0000\u0000w\u0001"+ +		"\u0000\u0000\u0000\u0000y\u0001\u0000\u0000\u0000\u0000{\u0001\u0000\u0000"+ +		"\u0000\u0000}\u0001\u0000\u0000\u0000\u0000\u007f\u0001\u0000\u0000\u0000"+ +		"\u0000\u0081\u0001\u0000\u0000\u0000\u0000\u0083\u0001\u0000\u0000\u0000"+ +		"\u0000\u0085\u0001\u0000\u0000\u0000\u0000\u0087\u0001\u0000\u0000\u0000"+ +		"\u0000\u0089\u0001\u0000\u0000\u0000\u0000\u008b\u0001\u0000\u0000\u0000"+ +		"\u0000\u008d\u0001\u0000\u0000\u0000\u0000\u008f\u0001\u0000\u0000\u0000"+ +		"\u0000\u0091\u0001\u0000\u0000\u0000\u0000\u0093\u0001\u0000\u0000\u0000"+ +		"\u0001\u00bb\u0001\u0000\u0000\u0000\u0003\u00bf\u0001\u0000\u0000\u0000"+ +		"\u0005\u00c1\u0001\u0000\u0000\u0000\u0007\u00c5\u0001\u0000\u0000\u0000"+ +		"\t\u00c8\u0001\u0000\u0000\u0000\u000b\u00cc\u0001\u0000\u0000\u0000\r"+ +		"\u00d1\u0001\u0000\u0000\u0000\u000f\u00d6\u0001\u0000\u0000\u0000\u0011"+ +		"\u00dc\u0001\u0000\u0000\u0000\u0013\u00e0\u0001\u0000\u0000\u0000\u0015"+ +		"\u00e5\u0001\u0000\u0000\u0000\u0017\u00e8\u0001\u0000\u0000\u0000\u0019"+ +		"\u00ef\u0001\u0000\u0000\u0000\u001b\u00f2\u0001\u0000\u0000\u0000\u001d"+ +		"\u00f5\u0001\u0000\u0000\u0000\u001f\u00fa\u0001\u0000\u0000\u0000!\u00fe"+ +		"\u0001\u0000\u0000\u0000#\u0101\u0001\u0000\u0000\u0000%\u0108\u0001\u0000"+ +		"\u0000\u0000\'\u010d\u0001\u0000\u0000\u0000)\u010f\u0001\u0000\u0000"+ +		"\u0000+\u0121\u0001\u0000\u0000\u0000-\u0125\u0001\u0000\u0000\u0000/"+ +		"\u0138\u0001\u0000\u0000\u00001\u013c\u0001\u0000\u0000\u00003\u013e\u0001"+ +		"\u0000\u0000\u00005\u0140\u0001\u0000\u0000\u00007\u0144\u0001\u0000\u0000"+ +		"\u00009\u0146\u0001\u0000\u0000\u0000;\u0149\u0001\u0000\u0000\u0000="+ +		"\u014c\u0001\u0000\u0000\u0000?\u014e\u0001\u0000\u0000\u0000A\u0150\u0001"+ +		"\u0000\u0000\u0000C\u0152\u0001\u0000\u0000\u0000E\u0155\u0001\u0000\u0000"+ +		"\u0000G\u0157\u0001\u0000\u0000\u0000I\u015a\u0001\u0000\u0000\u0000K"+ +		"\u015d\u0001\u0000\u0000\u0000M\u015f\u0001\u0000\u0000\u0000O\u0161\u0001"+ +		"\u0000\u0000\u0000Q\u0163\u0001\u0000\u0000\u0000S\u0166\u0001\u0000\u0000"+ +		"\u0000U\u0169\u0001\u0000\u0000\u0000W\u016b\u0001\u0000\u0000\u0000Y"+ +		"\u016d\u0001\u0000\u0000\u0000[\u016f\u0001\u0000\u0000\u0000]\u0171\u0001"+ +		"\u0000\u0000\u0000_\u0174\u0001\u0000\u0000\u0000a\u0176\u0001\u0000\u0000"+ +		"\u0000c\u0179\u0001\u0000\u0000\u0000e\u017c\u0001\u0000\u0000\u0000g"+ +		"\u017e\u0001\u0000\u0000\u0000i\u0180\u0001\u0000\u0000\u0000k\u0183\u0001"+ +		"\u0000\u0000\u0000m\u0186\u0001\u0000\u0000\u0000o\u0189\u0001\u0000\u0000"+ +		"\u0000q\u018c\u0001\u0000\u0000\u0000s\u018f\u0001\u0000\u0000\u0000u"+ +		"\u0191\u0001\u0000\u0000\u0000w\u0194\u0001\u0000\u0000\u0000y\u0197\u0001"+ +		"\u0000\u0000\u0000{\u019a\u0001\u0000\u0000\u0000}\u019d\u0001\u0000\u0000"+ +		"\u0000\u007f\u01a0\u0001\u0000\u0000\u0000\u0081\u01a3\u0001\u0000\u0000"+ +		"\u0000\u0083\u01a6\u0001\u0000\u0000\u0000\u0085\u01a9\u0001\u0000\u0000"+ +		"\u0000\u0087\u01ac\u0001\u0000\u0000\u0000\u0089\u01af\u0001\u0000\u0000"+ +		"\u0000\u008b\u01b3\u0001\u0000\u0000\u0000\u008d\u01b7\u0001\u0000\u0000"+ +		"\u0000\u008f\u01bb\u0001\u0000\u0000\u0000\u0091\u01c2\u0001\u0000\u0000"+ +		"\u0000\u0093\u01c6\u0001\u0000\u0000\u0000\u0095\u01cc\u0001\u0000\u0000"+ +		"\u0000\u0097\u01ce\u0001\u0000\u0000\u0000\u0099\u01d0\u0001\u0000\u0000"+ +		"\u0000\u009b\u01de\u0001\u0000\u0000\u0000\u009d\u01e2\u0001\u0000\u0000"+ +		"\u0000\u009f\u01e7\u0001\u0000\u0000\u0000\u00a1\u01eb\u0001\u0000\u0000"+ +		"\u0000\u00a3\u01f5\u0001\u0000\u0000\u0000\u00a5\u01f9\u0001\u0000\u0000"+ +		"\u0000\u00a7\u0200\u0001\u0000\u0000\u0000\u00a9\u00ae\u0005\'\u0000\u0000"+ +		"\u00aa\u00ad\u0003\u0095J\u0000\u00ab\u00ad\b\u0000\u0000\u0000\u00ac"+ +		"\u00aa\u0001\u0000\u0000\u0000\u00ac\u00ab\u0001\u0000\u0000\u0000\u00ad"+ +		"\u00b0\u0001\u0000\u0000\u0000\u00ae\u00ac\u0001\u0000\u0000\u0000\u00ae"+ +		"\u00af\u0001\u0000\u0000\u0000\u00af\u00b1\u0001\u0000\u0000\u0000\u00b0"+ +		"\u00ae\u0001\u0000\u0000\u0000\u00b1\u00bc\u0005\'\u0000\u0000\u00b2\u00b7"+ +		"\u0005\"\u0000\u0000\u00b3\u00b6\u0003\u0095J\u0000\u00b4\u00b6\b\u0001"+ +		"\u0000\u0000\u00b5\u00b3\u0001\u0000\u0000\u0000\u00b5\u00b4\u0001\u0000"+ +		"\u0000\u0000\u00b6\u00b9\u0001\u0000\u0000\u0000\u00b7\u00b5\u0001\u0000"+ +		"\u0000\u0000\u00b7\u00b8\u0001\u0000\u0000\u0000\u00b8\u00ba\u0001\u0000"+ +		"\u0000\u0000\u00b9\u00b7\u0001\u0000\u0000\u0000\u00ba\u00bc\u0005\"\u0000"+ +		"\u0000\u00bb\u00a9\u0001\u0000\u0000\u0000\u00bb\u00b2\u0001\u0000\u0000"+ +		"\u0000\u00bc\u0002\u0001\u0000\u0000\u0000\u00bd\u00c0\u0003/\u0017\u0000"+ +		"\u00be\u00c0\u00031\u0018\u0000\u00bf\u00bd\u0001\u0000\u0000\u0000\u00bf"+ +		"\u00be\u0001\u0000\u0000\u0000\u00c0\u0004\u0001\u0000\u0000\u0000\u00c1"+ +		"\u00c2\u0005a\u0000\u0000\u00c2\u00c3\u0005n\u0000\u0000\u00c3\u00c4\u0005"+ +		"d\u0000\u0000\u00c4\u0006\u0001\u0000\u0000\u0000\u00c5\u00c6\u0005a\u0000"+ +		"\u0000\u00c6\u00c7\u0005s\u0000\u0000\u00c7\b\u0001\u0000\u0000\u0000"+ +		"\u00c8\u00c9\u0005d\u0000\u0000\u00c9\u00ca\u0005e\u0000\u0000\u00ca\u00cb"+ +		"\u0005f\u0000\u0000\u00cb\n\u0001\u0000\u0000\u0000\u00cc\u00cd\u0005"+ +		"e\u0000\u0000\u00cd\u00ce\u0005l\u0000\u0000\u00ce\u00cf\u0005i\u0000"+ +		"\u0000\u00cf\u00d0\u0005f\u0000\u0000\u00d0\f\u0001\u0000\u0000\u0000"+ +		"\u00d1\u00d2\u0005e\u0000\u0000\u00d2\u00d3\u0005l\u0000\u0000\u00d3\u00d4"+ +		"\u0005s\u0000\u0000\u00d4\u00d5\u0005e\u0000\u0000\u00d5\u000e\u0001\u0000"+ +		"\u0000\u0000\u00d6\u00d7\u0005F\u0000\u0000\u00d7\u00d8\u0005a\u0000\u0000"+ +		"\u00d8\u00d9\u0005l\u0000\u0000\u00d9\u00da\u0005s\u0000\u0000\u00da\u00db"+ +		"\u0005e\u0000\u0000\u00db\u0010\u0001\u0000\u0000\u0000\u00dc\u00dd\u0005"+ +		"f\u0000\u0000\u00dd\u00de\u0005o\u0000\u0000\u00de\u00df\u0005r\u0000"+ +		"\u0000\u00df\u0012\u0001\u0000\u0000\u0000\u00e0\u00e1\u0005f\u0000\u0000"+ +		"\u00e1\u00e2\u0005r\u0000\u0000\u00e2\u00e3\u0005o\u0000\u0000\u00e3\u00e4"+ +		"\u0005m\u0000\u0000\u00e4\u0014\u0001\u0000\u0000\u0000\u00e5\u00e6\u0005"+ +		"i\u0000\u0000\u00e6\u00e7\u0005f\u0000\u0000\u00e7\u0016\u0001\u0000\u0000"+ +		"\u0000\u00e8\u00e9\u0005i\u0000\u0000\u00e9\u00ea\u0005m\u0000\u0000\u00ea"+ +		"\u00eb\u0005p\u0000\u0000\u00eb\u00ec\u0005o\u0000\u0000\u00ec\u00ed\u0005"+ +		"r\u0000\u0000\u00ed\u00ee\u0005t\u0000\u0000\u00ee\u0018\u0001\u0000\u0000"+ +		"\u0000\u00ef\u00f0\u0005i\u0000\u0000\u00f0\u00f1\u0005n\u0000\u0000\u00f1"+ +		"\u001a\u0001\u0000\u0000\u0000\u00f2\u00f3\u0005i\u0000\u0000\u00f3\u00f4"+ +		"\u0005s\u0000\u0000\u00f4\u001c\u0001\u0000\u0000\u0000\u00f5\u00f6\u0005"+ +		"N\u0000\u0000\u00f6\u00f7\u0005o\u0000\u0000\u00f7\u00f8\u0005n\u0000"+ +		"\u0000\u00f8\u00f9\u0005e\u0000\u0000\u00f9\u001e\u0001\u0000\u0000\u0000"+ +		"\u00fa\u00fb\u0005n\u0000\u0000\u00fb\u00fc\u0005o\u0000\u0000\u00fc\u00fd"+ +		"\u0005t\u0000\u0000\u00fd \u0001\u0000\u0000\u0000\u00fe\u00ff\u0005o"+ +		"\u0000\u0000\u00ff\u0100\u0005r\u0000\u0000\u0100\"\u0001\u0000\u0000"+ +		"\u0000\u0101\u0102\u0005r\u0000\u0000\u0102\u0103\u0005e\u0000\u0000\u0103"+ +		"\u0104\u0005t\u0000\u0000\u0104\u0105\u0005u\u0000\u0000\u0105\u0106\u0005"+ +		"r\u0000\u0000\u0106\u0107\u0005n\u0000\u0000\u0107$\u0001\u0000\u0000"+ +		"\u0000\u0108\u0109\u0005T\u0000\u0000\u0109\u010a\u0005r\u0000\u0000\u010a"+ +		"\u010b\u0005u\u0000\u0000\u010b\u010c\u0005e\u0000\u0000\u010c&\u0001"+ +		"\u0000\u0000\u0000\u010d\u010e\u0005_\u0000\u0000\u010e(\u0001\u0000\u0000"+ +		"\u0000\u010f\u0110\u0005w\u0000\u0000\u0110\u0111\u0005h\u0000\u0000\u0111"+ +		"\u0112\u0005i\u0000\u0000\u0112\u0113\u0005l\u0000\u0000\u0113\u0114\u0005"+ +		"e\u0000\u0000\u0114*\u0001\u0000\u0000\u0000\u0115\u0116\u0004\u0015\u0000"+ +		"\u0000\u0116\u0122\u0003\u00a3Q\u0000\u0117\u0119\u0005\r\u0000\u0000"+ +		"\u0118\u0117\u0001\u0000\u0000\u0000\u0118\u0119\u0001\u0000\u0000\u0000"+ +		"\u0119\u011a\u0001\u0000\u0000\u0000\u011a\u011d\u0005\n\u0000\u0000\u011b"+ +		"\u011d\u0002\f\r\u0000\u011c\u0118\u0001\u0000\u0000\u0000\u011c\u011b"+ +		"\u0001\u0000\u0000\u0000\u011d\u011f\u0001\u0000\u0000\u0000\u011e\u0120"+ +		"\u0003\u00a3Q\u0000\u011f\u011e\u0001\u0000\u0000\u0000\u011f\u0120\u0001"+ +		"\u0000\u0000\u0000\u0120\u0122\u0001\u0000\u0000\u0000\u0121\u0115\u0001"+ +		"\u0000\u0000\u0000\u0121\u011c\u0001\u0000\u0000\u0000\u0122\u0123\u0001"+ +		"\u0000\u0000\u0000\u0123\u0124\u0006\u0015\u0000\u0000\u0124,\u0001\u0000"+ +		"\u0000\u0000\u0125\u0129\u0007\u0002\u0000\u0000\u0126\u0128\u0007\u0003"+ +		"\u0000\u0000\u0127\u0126\u0001\u0000\u0000\u0000\u0128\u012b\u0001\u0000"+ +		"\u0000\u0000\u0129\u0127\u0001\u0000\u0000\u0000\u0129\u012a\u0001\u0000"+ +		"\u0000\u0000\u012a.\u0001\u0000\u0000\u0000\u012b\u0129\u0001\u0000\u0000"+ +		"\u0000\u012c\u0130\u0003\u0097K\u0000\u012d\u012f\u0003\u0099L\u0000\u012e"+ +		"\u012d\u0001\u0000\u0000\u0000\u012f\u0132\u0001\u0000\u0000\u0000\u0130"+ +		"\u012e\u0001\u0000\u0000\u0000\u0130\u0131\u0001\u0000\u0000\u0000\u0131"+ +		"\u0139\u0001\u0000\u0000\u0000\u0132\u0130\u0001\u0000\u0000\u0000\u0133"+ +		"\u0135\u00050\u0000\u0000\u0134\u0133\u0001\u0000\u0000\u0000\u0135\u0136"+ +		"\u0001\u0000\u0000\u0000\u0136\u0134\u0001\u0000\u0000\u0000\u0136\u0137"+ +		"\u0001\u0000\u0000\u0000\u0137\u0139\u0001\u0000\u0000\u0000\u0138\u012c"+ +		"\u0001\u0000\u0000\u0000\u0138\u0134\u0001\u0000\u0000\u0000\u01390\u0001"+ +		"\u0000\u0000\u0000\u013a\u013d\u0003\u009bM\u0000\u013b\u013d\u0003\u009d"+ +		"N\u0000\u013c\u013a\u0001\u0000\u0000\u0000\u013c\u013b\u0001\u0000\u0000"+ +		"\u0000\u013d2\u0001\u0000\u0000\u0000\u013e\u013f\u0005.\u0000\u0000\u013f"+ +		"4\u0001\u0000\u0000\u0000\u0140\u0141\u0005.\u0000\u0000\u0141\u0142\u0005"+ +		".\u0000\u0000\u0142\u0143\u0005.\u0000\u0000\u01436\u0001\u0000\u0000"+ +		"\u0000\u0144\u0145\u0005*\u0000\u0000\u01458\u0001\u0000\u0000\u0000\u0146"+ +		"\u0147\u0005(\u0000\u0000\u0147\u0148\u0006\u001c\u0001\u0000\u0148:\u0001"+ +		"\u0000\u0000\u0000\u0149\u014a\u0005)\u0000\u0000\u014a\u014b\u0006\u001d"+ +		"\u0002\u0000\u014b<\u0001\u0000\u0000\u0000\u014c\u014d\u0005,\u0000\u0000"+ +		"\u014d>\u0001\u0000\u0000\u0000\u014e\u014f\u0005:\u0000\u0000\u014f@"+ +		"\u0001\u0000\u0000\u0000\u0150\u0151\u0005;\u0000\u0000\u0151B\u0001\u0000"+ +		"\u0000\u0000\u0152\u0153\u0005*\u0000\u0000\u0153\u0154\u0005*\u0000\u0000"+ +		"\u0154D\u0001\u0000\u0000\u0000\u0155\u0156\u0005=\u0000\u0000\u0156F"+ +		"\u0001\u0000\u0000\u0000\u0157\u0158\u0005[\u0000\u0000\u0158\u0159\u0006"+ +		"#\u0003\u0000\u0159H\u0001\u0000\u0000\u0000\u015a\u015b\u0005]\u0000"+ +		"\u0000\u015b\u015c\u0006$\u0004\u0000\u015cJ\u0001\u0000\u0000\u0000\u015d"+ +		"\u015e\u0005|\u0000\u0000\u015eL\u0001\u0000\u0000\u0000\u015f\u0160\u0005"+ +		"^\u0000\u0000\u0160N\u0001\u0000\u0000\u0000\u0161\u0162\u0005&\u0000"+ +		"\u0000\u0162P\u0001\u0000\u0000\u0000\u0163\u0164\u0005<\u0000\u0000\u0164"+ +		"\u0165\u0005<\u0000\u0000\u0165R\u0001\u0000\u0000\u0000\u0166\u0167\u0005"+ +		">\u0000\u0000\u0167\u0168\u0005>\u0000\u0000\u0168T\u0001\u0000\u0000"+ +		"\u0000\u0169\u016a\u0005+\u0000\u0000\u016aV\u0001\u0000\u0000\u0000\u016b"+ +		"\u016c\u0005-\u0000\u0000\u016cX\u0001\u0000\u0000\u0000\u016d\u016e\u0005"+ +		"/\u0000\u0000\u016eZ\u0001\u0000\u0000\u0000\u016f\u0170\u0005%\u0000"+ +		"\u0000\u0170\\\u0001\u0000\u0000\u0000\u0171\u0172\u0005/\u0000\u0000"+ +		"\u0172\u0173\u0005/\u0000\u0000\u0173^\u0001\u0000\u0000\u0000\u0174\u0175"+ +		"\u0005~\u0000\u0000\u0175`\u0001\u0000\u0000\u0000\u0176\u0177\u0005{"+ +		"\u0000\u0000\u0177\u0178\u00060\u0005\u0000\u0178b\u0001\u0000\u0000\u0000"+ +		"\u0179\u017a\u0005}\u0000\u0000\u017a\u017b\u00061\u0006\u0000\u017bd"+ +		"\u0001\u0000\u0000\u0000\u017c\u017d\u0005<\u0000\u0000\u017df\u0001\u0000"+ +		"\u0000\u0000\u017e\u017f\u0005>\u0000\u0000\u017fh\u0001\u0000\u0000\u0000"+ +		"\u0180\u0181\u0005=\u0000\u0000\u0181\u0182\u0005=\u0000\u0000\u0182j"+ +		"\u0001\u0000\u0000\u0000\u0183\u0184\u0005>\u0000\u0000\u0184\u0185\u0005"+ +		"=\u0000\u0000\u0185l\u0001\u0000\u0000\u0000\u0186\u0187\u0005<\u0000"+ +		"\u0000\u0187\u0188\u0005=\u0000\u0000\u0188n\u0001\u0000\u0000\u0000\u0189"+ +		"\u018a\u0005<\u0000\u0000\u018a\u018b\u0005>\u0000\u0000\u018bp\u0001"+ +		"\u0000\u0000\u0000\u018c\u018d\u0005!\u0000\u0000\u018d\u018e\u0005=\u0000"+ +		"\u0000\u018er\u0001\u0000\u0000\u0000\u018f\u0190\u0005@\u0000\u0000\u0190"+ +		"t\u0001\u0000\u0000\u0000\u0191\u0192\u0005-\u0000\u0000\u0192\u0193\u0005"+ +		">\u0000\u0000\u0193v\u0001\u0000\u0000\u0000\u0194\u0195\u0005+\u0000"+ +		"\u0000\u0195\u0196\u0005=\u0000\u0000\u0196x\u0001\u0000\u0000\u0000\u0197"+ +		"\u0198\u0005-\u0000\u0000\u0198\u0199\u0005=\u0000\u0000\u0199z\u0001"+ +		"\u0000\u0000\u0000\u019a\u019b\u0005*\u0000\u0000\u019b\u019c\u0005=\u0000"+ +		"\u0000\u019c|\u0001\u0000\u0000\u0000\u019d\u019e\u0005@\u0000\u0000\u019e"+ +		"\u019f\u0005=\u0000\u0000\u019f~\u0001\u0000\u0000\u0000\u01a0\u01a1\u0005"+ +		"/\u0000\u0000\u01a1\u01a2\u0005=\u0000\u0000\u01a2\u0080\u0001\u0000\u0000"+ +		"\u0000\u01a3\u01a4\u0005%\u0000\u0000\u01a4\u01a5\u0005=\u0000\u0000\u01a5"+ +		"\u0082\u0001\u0000\u0000\u0000\u01a6\u01a7\u0005&\u0000\u0000\u01a7\u01a8"+ +		"\u0005=\u0000\u0000\u01a8\u0084\u0001\u0000\u0000\u0000\u01a9\u01aa\u0005"+ +		"|\u0000\u0000\u01aa\u01ab\u0005=\u0000\u0000\u01ab\u0086\u0001\u0000\u0000"+ +		"\u0000\u01ac\u01ad\u0005^\u0000\u0000\u01ad\u01ae\u0005=\u0000\u0000\u01ae"+ +		"\u0088\u0001\u0000\u0000\u0000\u01af\u01b0\u0005<\u0000\u0000\u01b0\u01b1"+ +		"\u0005<\u0000\u0000\u01b1\u01b2\u0005=\u0000\u0000\u01b2\u008a\u0001\u0000"+ +		"\u0000\u0000\u01b3\u01b4\u0005>\u0000\u0000\u01b4\u01b5\u0005>\u0000\u0000"+ +		"\u01b5\u01b6\u0005=\u0000\u0000\u01b6\u008c\u0001\u0000\u0000\u0000\u01b7"+ +		"\u01b8\u0005*\u0000\u0000\u01b8\u01b9\u0005*\u0000\u0000\u01b9\u01ba\u0005"+ +		"=\u0000\u0000\u01ba\u008e\u0001\u0000\u0000\u0000\u01bb\u01bc\u0005/\u0000"+ +		"\u0000\u01bc\u01bd\u0005/\u0000\u0000\u01bd\u01be\u0005=\u0000\u0000\u01be"+ +		"\u0090\u0001\u0000\u0000\u0000\u01bf\u01c3\u0003\u00a3Q\u0000\u01c0\u01c3"+ +		"\u0003\u00a5R\u0000\u01c1\u01c3\u0003\u00a7S\u0000\u01c2\u01bf\u0001\u0000"+ +		"\u0000\u0000\u01c2\u01c0\u0001\u0000\u0000\u0000\u01c2\u01c1\u0001\u0000"+ +		"\u0000\u0000\u01c3\u01c4\u0001\u0000\u0000\u0000\u01c4\u01c5\u0006H\u0007"+ +		"\u0000\u01c5\u0092\u0001\u0000\u0000\u0000\u01c6\u01c7\t\u0000\u0000\u0000"+ +		"\u01c7\u0094\u0001\u0000\u0000\u0000\u01c8\u01c9\u0005\\\u0000\u0000\u01c9"+ +		"\u01cd\t\u0000\u0000\u0000\u01ca\u01cb\u0005\\\u0000\u0000\u01cb\u01cd"+ +		"\u0003+\u0015\u0000\u01cc\u01c8\u0001\u0000\u0000\u0000\u01cc\u01ca\u0001"+ +		"\u0000\u0000\u0000\u01cd\u0096\u0001\u0000\u0000\u0000\u01ce\u01cf\u0007"+ +		"\u0004\u0000\u0000\u01cf\u0098\u0001\u0000\u0000\u0000\u01d0\u01d1\u0007"+ +		"\u0005\u0000\u0000\u01d1\u009a\u0001\u0000\u0000\u0000\u01d2\u01d4\u0003"+ +		"\u009fO\u0000\u01d3\u01d2\u0001\u0000\u0000\u0000\u01d3\u01d4\u0001\u0000"+ +		"\u0000\u0000\u01d4\u01d5\u0001\u0000\u0000\u0000\u01d5\u01d7\u0005.\u0000"+ +		"\u0000\u01d6\u01d8\u0003\u0099L\u0000\u01d7\u01d6\u0001\u0000\u0000\u0000"+ +		"\u01d8\u01d9\u0001\u0000\u0000\u0000\u01d9\u01d7\u0001\u0000\u0000\u0000"+ +		"\u01d9\u01da\u0001\u0000\u0000\u0000\u01da\u01df\u0001\u0000\u0000\u0000"+ +		"\u01db\u01dc\u0003\u009fO\u0000\u01dc\u01dd\u0005.\u0000\u0000\u01dd\u01df"+ +		"\u0001\u0000\u0000\u0000\u01de\u01d3\u0001\u0000\u0000\u0000\u01de\u01db"+ +		"\u0001\u0000\u0000\u0000\u01df\u009c\u0001\u0000\u0000\u0000\u01e0\u01e3"+ +		"\u0003\u009fO\u0000\u01e1\u01e3\u0003\u009bM\u0000\u01e2\u01e0\u0001\u0000"+ +		"\u0000\u0000\u01e2\u01e1\u0001\u0000\u0000\u0000\u01e3\u01e4\u0001\u0000"+ +		"\u0000\u0000\u01e4\u01e5\u0003\u00a1P\u0000\u01e5\u009e\u0001\u0000\u0000"+ +		"\u0000\u01e6\u01e8\u0003\u0099L\u0000\u01e7\u01e6\u0001\u0000\u0000\u0000"+ +		"\u01e8\u01e9\u0001\u0000\u0000\u0000\u01e9\u01e7\u0001\u0000\u0000\u0000"+ +		"\u01e9\u01ea\u0001\u0000\u0000\u0000\u01ea\u00a0\u0001\u0000\u0000\u0000"+ +		"\u01eb\u01ed\u0007\u0006\u0000\u0000\u01ec\u01ee\u0007\u0007\u0000\u0000"+ +		"\u01ed\u01ec\u0001\u0000\u0000\u0000\u01ed\u01ee\u0001\u0000\u0000\u0000"+ +		"\u01ee\u01f0\u0001\u0000\u0000\u0000\u01ef\u01f1\u0003\u0099L\u0000\u01f0"+ +		"\u01ef\u0001\u0000\u0000\u0000\u01f1\u01f2\u0001\u0000\u0000\u0000\u01f2"+ +		"\u01f0\u0001\u0000\u0000\u0000\u01f2\u01f3\u0001\u0000\u0000\u0000\u01f3"+ +		"\u00a2\u0001\u0000\u0000\u0000\u01f4\u01f6\u0007\b\u0000\u0000\u01f5\u01f4"+ +		"\u0001\u0000\u0000\u0000\u01f6\u01f7\u0001\u0000\u0000\u0000\u01f7\u01f5"+ +		"\u0001\u0000\u0000\u0000\u01f7\u01f8\u0001\u0000\u0000\u0000\u01f8\u00a4"+ +		"\u0001\u0000\u0000\u0000\u01f9\u01fd\u0005#\u0000\u0000\u01fa\u01fc\b"+ +		"\t\u0000\u0000\u01fb\u01fa\u0001\u0000\u0000\u0000\u01fc\u01ff\u0001\u0000"+ +		"\u0000\u0000\u01fd\u01fb\u0001\u0000\u0000\u0000\u01fd\u01fe\u0001\u0000"+ +		"\u0000\u0000\u01fe\u00a6\u0001\u0000\u0000\u0000\u01ff\u01fd\u0001\u0000"+ +		"\u0000\u0000\u0200\u0202\u0005\\\u0000\u0000\u0201\u0203\u0003\u00a3Q"+ +		"\u0000\u0202\u0201\u0001\u0000\u0000\u0000\u0202\u0203\u0001\u0000\u0000"+ +		"\u0000\u0203\u0209\u0001\u0000\u0000\u0000\u0204\u0206\u0005\r\u0000\u0000"+ +		"\u0205\u0204\u0001\u0000\u0000\u0000\u0205\u0206\u0001\u0000\u0000\u0000"+ +		"\u0206\u0207\u0001\u0000\u0000\u0000\u0207\u020a\u0005\n\u0000\u0000\u0208"+ +		"\u020a\u0002\f\r\u0000\u0209\u0205\u0001\u0000\u0000\u0000\u0209\u0208"+ +		"\u0001\u0000\u0000\u0000\u020a\u00a8\u0001\u0000\u0000\u0000\u001e\u0000"+ +		"\u00ac\u00ae\u00b5\u00b7\u00bb\u00bf\u0118\u011c\u011f\u0121\u0129\u0130"+ +		"\u0136\u0138\u013c\u01c2\u01cc\u01d3\u01d9\u01de\u01e2\u01e9\u01ed\u01f2"+ +		"\u01f7\u01fd\u0202\u0205\u0209\b\u0001\u0015\u0000\u0001\u001c\u0001\u0001"+ +		"\u001d\u0002\u0001#\u0003\u0001$\u0004\u00010\u0005\u00011\u0006\u0006"+ +		"\u0000\u0000"; +	public static final ATN _ATN = +		new ATNDeserializer().deserialize(_serializedATN.toCharArray()); +	static { +		_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; +		for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { +			_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); +		} +	} +}
\ No newline at end of file diff --git a/src/Python3Lexer.tokens b/src/Python3Lexer.tokens new file mode 100644 index 0000000..0f817cc --- /dev/null +++ b/src/Python3Lexer.tokens @@ -0,0 +1,142 @@ +INDENT=1 +DEDENT=2 +STRING=3 +NUMBER=4 +AND=5 +AS=6 +DEF=7 +ELIF=8 +ELSE=9 +FALSE=10 +FOR=11 +FROM=12 +IF=13 +IMPORT=14 +IN=15 +IS=16 +NONE=17 +NOT=18 +OR=19 +RETURN=20 +TRUE=21 +UNDERSCORE=22 +WHILE=23 +NEWLINE=24 +NAME=25 +DECIMAL_INTEGER=26 +FLOAT_NUMBER=27 +DOT=28 +ELLIPSIS=29 +STAR=30 +OPEN_PAREN=31 +CLOSE_PAREN=32 +COMMA=33 +COLON=34 +SEMI_COLON=35 +POWER=36 +ASSIGN=37 +OPEN_BRACK=38 +CLOSE_BRACK=39 +OR_OP=40 +XOR=41 +AND_OP=42 +LEFT_SHIFT=43 +RIGHT_SHIFT=44 +ADD=45 +MINUS=46 +DIV=47 +MOD=48 +IDIV=49 +NOT_OP=50 +OPEN_BRACE=51 +CLOSE_BRACE=52 +LESS_THAN=53 +GREATER_THAN=54 +EQUALS=55 +GT_EQ=56 +LT_EQ=57 +NOT_EQ_1=58 +NOT_EQ_2=59 +AT=60 +ARROW=61 +ADD_ASSIGN=62 +SUB_ASSIGN=63 +MULT_ASSIGN=64 +AT_ASSIGN=65 +DIV_ASSIGN=66 +MOD_ASSIGN=67 +AND_ASSIGN=68 +OR_ASSIGN=69 +XOR_ASSIGN=70 +LEFT_SHIFT_ASSIGN=71 +RIGHT_SHIFT_ASSIGN=72 +POWER_ASSIGN=73 +IDIV_ASSIGN=74 +SKIP_=75 +UNKNOWN_CHAR=76 +'and'=5 +'as'=6 +'def'=7 +'elif'=8 +'else'=9 +'False'=10 +'for'=11 +'from'=12 +'if'=13 +'import'=14 +'in'=15 +'is'=16 +'None'=17 +'not'=18 +'or'=19 +'return'=20 +'True'=21 +'_'=22 +'while'=23 +'.'=28 +'...'=29 +'*'=30 +'('=31 +')'=32 +','=33 +':'=34 +';'=35 +'**'=36 +'='=37 +'['=38 +']'=39 +'|'=40 +'^'=41 +'&'=42 +'<<'=43 +'>>'=44 +'+'=45 +'-'=46 +'/'=47 +'%'=48 +'//'=49 +'~'=50 +'{'=51 +'}'=52 +'<'=53 +'>'=54 +'=='=55 +'>='=56 +'<='=57 +'<>'=58 +'!='=59 +'@'=60 +'->'=61 +'+='=62 +'-='=63 +'*='=64 +'@='=65 +'/='=66 +'%='=67 +'&='=68 +'|='=69 +'^='=70 +'<<='=71 +'>>='=72 +'**='=73 +'//='=74 diff --git a/src/Python3LexerBase.java b/src/Python3LexerBase.java new file mode 100644 index 0000000..4041747 --- /dev/null +++ b/src/Python3LexerBase.java @@ -0,0 +1,152 @@ +import org.antlr.v4.runtime.*; + +import java.util.ArrayDeque; +import java.util.Deque; + +abstract class Python3LexerBase extends Lexer { +    // A queue where extra tokens are pushed on (see the NEWLINE lexer rule). +    private java.util.LinkedList<Token> tokens = new java.util.LinkedList<>(); +    // The stack that keeps track of the indentation level. +    private Deque<Integer> indents = new ArrayDeque<>(); +    // The amount of opened braces, brackets and parenthesis. +    private int opened = 0; +    // The most recently produced token. +    private Token lastToken = null; + +    protected Python3LexerBase(CharStream input) { +        super(input); +    } + +    @Override +    public void emit(Token t) { +        super.setToken(t); +        tokens.offer(t); +    } + +    @Override +    public Token nextToken() { +        // Check if the end-of-file is ahead and there are still some DEDENTS expected. +        if (_input.LA(1) == EOF && !this.indents.isEmpty()) { +            // Remove any trailing EOF tokens from our buffer. +            for (int i = tokens.size() - 1; i >= 0; i--) { +                if (tokens.get(i).getType() == EOF) { +                    tokens.remove(i); +                } +            } + +            // First emit an extra line break that serves as the end of the statement. +            this.emit(commonToken(Python3Lexer.NEWLINE, "\n")); + +            // Now emit as much DEDENT tokens as needed. +            while (!indents.isEmpty()) { +                this.emit(createDedent()); +                indents.pop(); +            } + +            // Put the EOF back on the token stream. +            this.emit(commonToken(Python3Lexer.EOF, "<EOF>")); +        } + +        Token next = super.nextToken(); + +        if (next.getChannel() == Token.DEFAULT_CHANNEL) { +            // Keep track of the last token on the default channel. +            this.lastToken = next; +        } + +        return tokens.isEmpty() ? next : tokens.poll(); +    } + +    private Token createDedent() { +        CommonToken dedent = commonToken(Python3Lexer.DEDENT, ""); +        dedent.setLine(this.lastToken.getLine()); +        return dedent; +    } + +    private CommonToken commonToken(int type, String text) { +        int stop = this.getCharIndex() - 1; +        int start = text.isEmpty() ? stop : stop - text.length() + 1; +        return new CommonToken(this._tokenFactorySourcePair, type, DEFAULT_TOKEN_CHANNEL, start, stop); +    } + +    // Calculates the indentation of the provided spaces, taking the +    // following rules into account: +    // +    // "Tabs are replaced (from left to right) by one to eight spaces +    //  such that the total number of characters up to and including +    //  the replacement is a multiple of eight [...]" +    // +    //  -- https://docs.python.org/3.1/reference/lexical_analysis.html#indentation +    static int getIndentationCount(String spaces) { +        int count = 0; +        for (char ch : spaces.toCharArray()) { +            switch (ch) { +                case '\t': +                    count += 8 - (count % 8); +                    break; +                default: +                    // A normal space char. +                    count++; +            } +        } + +        return count; +    } + +    boolean atStartOfInput() { +        return super.getCharPositionInLine() == 0 && super.getLine() == 1; +    } + +    void openBrace(){ +        this.opened++; +    } + +    void closeBrace(){ +        this.opened--; +    } + +    void onNewLine(){ +        String newLine = getText().replaceAll("[^\r\n\f]+", ""); +        String spaces = getText().replaceAll("[\r\n\f]+", ""); + +        // Strip newlines inside open clauses except if we are near EOF. We keep NEWLINEs near EOF to +        // satisfy the final newline needed by the single_put rule used by the REPL. +        int next = _input.LA(1); +        int nextnext = _input.LA(2); +        if (opened > 0 || (nextnext != -1 && (next == '\r' || next == '\n' || next == '\f' || next == '#'))) { +            // If we're inside a list or on a blank line, ignore all indents, +            // dedents and line breaks. +            skip(); +        } +        else { +            emit(commonToken(Python3Lexer.NEWLINE, newLine)); +            int indent = getIndentationCount(spaces); +            int previous = indents.isEmpty() ? 0 : indents.peek(); +            if (indent == previous) { +                // skip indents of the same size as the present indent-size +                skip(); +            } +            else if (indent > previous) { +                indents.push(indent); +                emit(commonToken(Python3Lexer.INDENT, spaces)); +            } +            else { +                // Possibly emit more than 1 DEDENT token. +                while(!indents.isEmpty() && indents.peek() > indent) { +                    this.emit(createDedent()); +                    indents.pop(); +                } +            } +        } +    } + +    @Override +    public void reset() +    { +        tokens = new java.util.LinkedList<>(); +        indents = new ArrayDeque<>(); +        opened = 0; +        lastToken = null; +        super.reset(); +    } +}
\ No newline at end of file diff --git a/src/Python3Parser.g4 b/src/Python3Parser.g4 new file mode 100644 index 0000000..c145e56 --- /dev/null +++ b/src/Python3Parser.g4 @@ -0,0 +1,181 @@ +/* + La grammatica di Python si trova a + https://docs.python.org/3/reference/grammar.html + + Questa e` stata elaborata da  Bart Kiers, bart@big-o.nl + e si trova a https://github.com/bkiers/python3-parser + + Semplificata ai fini del corso di CLP -- Marco Bertoni, Cosimo Laneve +*/ + +// $antlr-format alignTrailingComments true, columnLimit 150, minEmptyLines 1, maxEmptyLinesToKeep 1, reflowComments false, useTab false +// $antlr-format allowShortRulesOnASingleLine false, allowShortBlocksOnASingleLine true, alignSemicolons hanging, alignColons hanging + +parser grammar Python3Parser; + +options { +    superClass = Python3ParserBase; +    tokenVocab = Python3Lexer; +} + +root +    : NEWLINE* (simple_stmts | compound_stmt)* EOF +    ; + +simple_stmts +    : simple_stmt (';' simple_stmt)* ';'? NEWLINE +    ; + +compound_stmt +    : if_stmt +    | while_stmt +    | for_stmt +    | funcdef +    ; + +simple_stmt +    : assignment +    | expr +    | return_stmt +    | import_stm +    ; + +assignment +    : exprlist augassign exprlist +    ; + +return_stmt +    : 'return' exprlist? +    ; + +import_stm +    : 'import' dotted_name ('as' NAME)? +    | 'from' dotted_name 'import' (NAME  (',' NAME)*  | '*') +    ; + +dotted_name +    : NAME ('.' NAME)* +    ; + +funcdef +    : 'def' NAME '(' paramlist? ')' ':' block +    ; + +paramlist +    : paramdef ('=' expr)? (',' paramdef ('=' expr)?)* +    ; + +paramdef +    : NAME (':' expr)? +    ; + +augassign +    : '=' +    | '+=' +    | '-=' +    | '*=' +    | '@=' +    | '/=' +    | '%=' +    | '&=' +    | '|=' +    | '^=' +    | '<<=' +    | '>>=' +    | '**=' +    | '//=' +    ; + +if_stmt +    : 'if' expr ':' block ('elif' expr ':' block)* ('else' ':' block)? +    ; + +while_stmt +    : 'while' expr ':' block ('else' ':' block)? +    ; + +for_stmt +    : 'for' exprlist ':' block ('else' ':' block)? +    ; + +block +    : simple_stmts +    | NEWLINE INDENT (simple_stmts | compound_stmt)+ DEDENT +    ; + +comp_op +    : '<' +    | '>' +    | '==' +    | '>=' +    | '<=' +    | '<>' +    | '!=' +    | 'in' +    | 'not' 'in' +    | 'is' +    | 'is' 'not' +    ; + +expr +    : atom trailer* +    | expr '**' expr +    | ('+' | '-' | '~')+ expr +    | expr ('*' | '@' | '/' | '%' | '//') expr +    | expr ('+' | '-') expr +    | expr ('<<' | '>>') expr +    | expr '&' expr +    | expr '^' expr +    | expr '|' expr +    | 'not' expr +    | expr comp_op expr +    | expr 'and' expr +    | expr 'or' expr +    | expr 'if' expr 'else' expr +    ; +atom +    : '(' testlist_comp? ')' +    | '[' testlist_comp? ']' +    | '{' testlist_comp? '}' +    | NAME +    | NUMBER +    | STRING+ +    | '...' +    | 'None' +    | 'True' +    | 'False' +    ; + +testlist_comp    : expr (comp_for |  (',' expr)* ','?) +       ; +trailer +    : '(' arglist? ')' +    | '[' expr (',' expr)* ','? ']' +    | '.' NAME +    | '[' expr? ':' expr? (':' expr? )? ']' +    ; + +exprlist +    : expr (',' expr )* ','? +    ; + +arglist +    : argument (',' argument)* ','? +    ; + +argument +    : expr comp_for? | expr '=' expr +    ; + +comp_iter +    : comp_for +    | comp_if +    ; + +comp_for +    : 'for' exprlist 'in' expr comp_iter? +    ; + +comp_if +    : 'if' expr comp_iter? +    ;
\ No newline at end of file diff --git a/src/Python3Parser.interp b/src/Python3Parser.interp new file mode 100644 index 0000000..0baca5a --- /dev/null +++ b/src/Python3Parser.interp @@ -0,0 +1,190 @@ +token literal names: +null +null +null +null +null +'and' +'as' +'def' +'elif' +'else' +'False' +'for' +'from' +'if' +'import' +'in' +'is' +'None' +'not' +'or' +'return' +'True' +'_' +'while' +null +null +null +null +'.' +'...' +'*' +'(' +')' +',' +':' +';' +'**' +'=' +'[' +']' +'|' +'^' +'&' +'<<' +'>>' +'+' +'-' +'/' +'%' +'//' +'~' +'{' +'}' +'<' +'>' +'==' +'>=' +'<=' +'<>' +'!=' +'@' +'->' +'+=' +'-=' +'*=' +'@=' +'/=' +'%=' +'&=' +'|=' +'^=' +'<<=' +'>>=' +'**=' +'//=' +null +null + +token symbolic names: +null +INDENT +DEDENT +STRING +NUMBER +AND +AS +DEF +ELIF +ELSE +FALSE +FOR +FROM +IF +IMPORT +IN +IS +NONE +NOT +OR +RETURN +TRUE +UNDERSCORE +WHILE +NEWLINE +NAME +DECIMAL_INTEGER +FLOAT_NUMBER +DOT +ELLIPSIS +STAR +OPEN_PAREN +CLOSE_PAREN +COMMA +COLON +SEMI_COLON +POWER +ASSIGN +OPEN_BRACK +CLOSE_BRACK +OR_OP +XOR +AND_OP +LEFT_SHIFT +RIGHT_SHIFT +ADD +MINUS +DIV +MOD +IDIV +NOT_OP +OPEN_BRACE +CLOSE_BRACE +LESS_THAN +GREATER_THAN +EQUALS +GT_EQ +LT_EQ +NOT_EQ_1 +NOT_EQ_2 +AT +ARROW +ADD_ASSIGN +SUB_ASSIGN +MULT_ASSIGN +AT_ASSIGN +DIV_ASSIGN +MOD_ASSIGN +AND_ASSIGN +OR_ASSIGN +XOR_ASSIGN +LEFT_SHIFT_ASSIGN +RIGHT_SHIFT_ASSIGN +POWER_ASSIGN +IDIV_ASSIGN +SKIP_ +UNKNOWN_CHAR + +rule names: +root +simple_stmts +compound_stmt +simple_stmt +assignment +return_stmt +import_stm +dotted_name +funcdef +paramlist +paramdef +augassign +if_stmt +while_stmt +for_stmt +block +comp_op +expr +atom +testlist_comp +trailer +exprlist +arglist +argument +comp_iter +comp_for +comp_if + + +atn: +[4, 1, 76, 419, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 1, 0, 5, 0, 56, 8, 0, 10, 0, 12, 0, 59, 9, 0, 1, 0, 1, 0, 5, 0, 63, 8, 0, 10, 0, 12, 0, 66, 9, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 5, 1, 73, 8, 1, 10, 1, 12, 1, 76, 9, 1, 1, 1, 3, 1, 79, 8, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 87, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 93, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 3, 5, 101, 8, 5, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 107, 8, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 5, 6, 115, 8, 6, 10, 6, 12, 6, 118, 9, 6, 1, 6, 3, 6, 121, 8, 6, 3, 6, 123, 8, 6, 1, 7, 1, 7, 1, 7, 5, 7, 128, 8, 7, 10, 7, 12, 7, 131, 9, 7, 1, 8, 1, 8, 1, 8, 1, 8, 3, 8, 137, 8, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 3, 9, 146, 8, 9, 1, 9, 1, 9, 1, 9, 1, 9, 3, 9, 152, 8, 9, 5, 9, 154, 8, 9, 10, 9, 12, 9, 157, 9, 9, 1, 10, 1, 10, 1, 10, 3, 10, 162, 8, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 5, 12, 175, 8, 12, 10, 12, 12, 12, 178, 9, 12, 1, 12, 1, 12, 1, 12, 3, 12, 183, 8, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 3, 13, 192, 8, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 1, 14, 3, 14, 201, 8, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 4, 15, 208, 8, 15, 11, 15, 12, 15, 209, 1, 15, 1, 15, 3, 15, 214, 8, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 229, 8, 16, 1, 17, 1, 17, 1, 17, 5, 17, 234, 8, 17, 10, 17, 12, 17, 237, 9, 17, 1, 17, 4, 17, 240, 8, 17, 11, 17, 12, 17, 241, 1, 17, 1, 17, 1, 17, 3, 17, 247, 8, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 5, 17, 286, 8, 17, 10, 17, 12, 17, 289, 9, 17, 1, 18, 1, 18, 3, 18, 293, 8, 18, 1, 18, 1, 18, 1, 18, 3, 18, 298, 8, 18, 1, 18, 1, 18, 1, 18, 3, 18, 303, 8, 18, 1, 18, 1, 18, 1, 18, 1, 18, 4, 18, 309, 8, 18, 11, 18, 12, 18, 310, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 317, 8, 18, 1, 19, 1, 19, 1, 19, 1, 19, 5, 19, 323, 8, 19, 10, 19, 12, 19, 326, 9, 19, 1, 19, 3, 19, 329, 8, 19, 3, 19, 331, 8, 19, 1, 20, 1, 20, 3, 20, 335, 8, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 5, 20, 342, 8, 20, 10, 20, 12, 20, 345, 9, 20, 1, 20, 3, 20, 348, 8, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 356, 8, 20, 1, 20, 1, 20, 3, 20, 360, 8, 20, 1, 20, 1, 20, 3, 20, 364, 8, 20, 3, 20, 366, 8, 20, 1, 20, 3, 20, 369, 8, 20, 1, 21, 1, 21, 1, 21, 5, 21, 374, 8, 21, 10, 21, 12, 21, 377, 9, 21, 1, 21, 3, 21, 380, 8, 21, 1, 22, 1, 22, 1, 22, 5, 22, 385, 8, 22, 10, 22, 12, 22, 388, 9, 22, 1, 22, 3, 22, 391, 8, 22, 1, 23, 1, 23, 3, 23, 395, 8, 23, 1, 23, 1, 23, 1, 23, 1, 23, 3, 23, 401, 8, 23, 1, 24, 1, 24, 3, 24, 405, 8, 24, 1, 25, 1, 25, 1, 25, 1, 25, 1, 25, 3, 25, 412, 8, 25, 1, 26, 1, 26, 1, 26, 3, 26, 417, 8, 26, 1, 26, 0, 1, 34, 27, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 0, 5, 2, 0, 37, 37, 62, 74, 2, 0, 45, 46, 50, 50, 3, 0, 30, 30, 47, 49, 60, 60, 1, 0, 45, 46, 1, 0, 43, 44, 480, 0, 57, 1, 0, 0, 0, 2, 69, 1, 0, 0, 0, 4, 86, 1, 0, 0, 0, 6, 92, 1, 0, 0, 0, 8, 94, 1, 0, 0, 0, 10, 98, 1, 0, 0, 0, 12, 122, 1, 0, 0, 0, 14, 124, 1, 0, 0, 0, 16, 132, 1, 0, 0, 0, 18, 142, 1, 0, 0, 0, 20, 158, 1, 0, 0, 0, 22, 163, 1, 0, 0, 0, 24, 165, 1, 0, 0, 0, 26, 184, 1, 0, 0, 0, 28, 193, 1, 0, 0, 0, 30, 213, 1, 0, 0, 0, 32, 228, 1, 0, 0, 0, 34, 246, 1, 0, 0, 0, 36, 316, 1, 0, 0, 0, 38, 318, 1, 0, 0, 0, 40, 368, 1, 0, 0, 0, 42, 370, 1, 0, 0, 0, 44, 381, 1, 0, 0, 0, 46, 400, 1, 0, 0, 0, 48, 404, 1, 0, 0, 0, 50, 406, 1, 0, 0, 0, 52, 413, 1, 0, 0, 0, 54, 56, 5, 24, 0, 0, 55, 54, 1, 0, 0, 0, 56, 59, 1, 0, 0, 0, 57, 55, 1, 0, 0, 0, 57, 58, 1, 0, 0, 0, 58, 64, 1, 0, 0, 0, 59, 57, 1, 0, 0, 0, 60, 63, 3, 2, 1, 0, 61, 63, 3, 4, 2, 0, 62, 60, 1, 0, 0, 0, 62, 61, 1, 0, 0, 0, 63, 66, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 64, 65, 1, 0, 0, 0, 65, 67, 1, 0, 0, 0, 66, 64, 1, 0, 0, 0, 67, 68, 5, 0, 0, 1, 68, 1, 1, 0, 0, 0, 69, 74, 3, 6, 3, 0, 70, 71, 5, 35, 0, 0, 71, 73, 3, 6, 3, 0, 72, 70, 1, 0, 0, 0, 73, 76, 1, 0, 0, 0, 74, 72, 1, 0, 0, 0, 74, 75, 1, 0, 0, 0, 75, 78, 1, 0, 0, 0, 76, 74, 1, 0, 0, 0, 77, 79, 5, 35, 0, 0, 78, 77, 1, 0, 0, 0, 78, 79, 1, 0, 0, 0, 79, 80, 1, 0, 0, 0, 80, 81, 5, 24, 0, 0, 81, 3, 1, 0, 0, 0, 82, 87, 3, 24, 12, 0, 83, 87, 3, 26, 13, 0, 84, 87, 3, 28, 14, 0, 85, 87, 3, 16, 8, 0, 86, 82, 1, 0, 0, 0, 86, 83, 1, 0, 0, 0, 86, 84, 1, 0, 0, 0, 86, 85, 1, 0, 0, 0, 87, 5, 1, 0, 0, 0, 88, 93, 3, 8, 4, 0, 89, 93, 3, 34, 17, 0, 90, 93, 3, 10, 5, 0, 91, 93, 3, 12, 6, 0, 92, 88, 1, 0, 0, 0, 92, 89, 1, 0, 0, 0, 92, 90, 1, 0, 0, 0, 92, 91, 1, 0, 0, 0, 93, 7, 1, 0, 0, 0, 94, 95, 3, 42, 21, 0, 95, 96, 3, 22, 11, 0, 96, 97, 3, 42, 21, 0, 97, 9, 1, 0, 0, 0, 98, 100, 5, 20, 0, 0, 99, 101, 3, 42, 21, 0, 100, 99, 1, 0, 0, 0, 100, 101, 1, 0, 0, 0, 101, 11, 1, 0, 0, 0, 102, 103, 5, 14, 0, 0, 103, 106, 3, 14, 7, 0, 104, 105, 5, 6, 0, 0, 105, 107, 5, 25, 0, 0, 106, 104, 1, 0, 0, 0, 106, 107, 1, 0, 0, 0, 107, 123, 1, 0, 0, 0, 108, 109, 5, 12, 0, 0, 109, 110, 3, 14, 7, 0, 110, 120, 5, 14, 0, 0, 111, 116, 5, 25, 0, 0, 112, 113, 5, 33, 0, 0, 113, 115, 5, 25, 0, 0, 114, 112, 1, 0, 0, 0, 115, 118, 1, 0, 0, 0, 116, 114, 1, 0, 0, 0, 116, 117, 1, 0, 0, 0, 117, 121, 1, 0, 0, 0, 118, 116, 1, 0, 0, 0, 119, 121, 5, 30, 0, 0, 120, 111, 1, 0, 0, 0, 120, 119, 1, 0, 0, 0, 121, 123, 1, 0, 0, 0, 122, 102, 1, 0, 0, 0, 122, 108, 1, 0, 0, 0, 123, 13, 1, 0, 0, 0, 124, 129, 5, 25, 0, 0, 125, 126, 5, 28, 0, 0, 126, 128, 5, 25, 0, 0, 127, 125, 1, 0, 0, 0, 128, 131, 1, 0, 0, 0, 129, 127, 1, 0, 0, 0, 129, 130, 1, 0, 0, 0, 130, 15, 1, 0, 0, 0, 131, 129, 1, 0, 0, 0, 132, 133, 5, 7, 0, 0, 133, 134, 5, 25, 0, 0, 134, 136, 5, 31, 0, 0, 135, 137, 3, 18, 9, 0, 136, 135, 1, 0, 0, 0, 136, 137, 1, 0, 0, 0, 137, 138, 1, 0, 0, 0, 138, 139, 5, 32, 0, 0, 139, 140, 5, 34, 0, 0, 140, 141, 3, 30, 15, 0, 141, 17, 1, 0, 0, 0, 142, 145, 3, 20, 10, 0, 143, 144, 5, 37, 0, 0, 144, 146, 3, 34, 17, 0, 145, 143, 1, 0, 0, 0, 145, 146, 1, 0, 0, 0, 146, 155, 1, 0, 0, 0, 147, 148, 5, 33, 0, 0, 148, 151, 3, 20, 10, 0, 149, 150, 5, 37, 0, 0, 150, 152, 3, 34, 17, 0, 151, 149, 1, 0, 0, 0, 151, 152, 1, 0, 0, 0, 152, 154, 1, 0, 0, 0, 153, 147, 1, 0, 0, 0, 154, 157, 1, 0, 0, 0, 155, 153, 1, 0, 0, 0, 155, 156, 1, 0, 0, 0, 156, 19, 1, 0, 0, 0, 157, 155, 1, 0, 0, 0, 158, 161, 5, 25, 0, 0, 159, 160, 5, 34, 0, 0, 160, 162, 3, 34, 17, 0, 161, 159, 1, 0, 0, 0, 161, 162, 1, 0, 0, 0, 162, 21, 1, 0, 0, 0, 163, 164, 7, 0, 0, 0, 164, 23, 1, 0, 0, 0, 165, 166, 5, 13, 0, 0, 166, 167, 3, 34, 17, 0, 167, 168, 5, 34, 0, 0, 168, 176, 3, 30, 15, 0, 169, 170, 5, 8, 0, 0, 170, 171, 3, 34, 17, 0, 171, 172, 5, 34, 0, 0, 172, 173, 3, 30, 15, 0, 173, 175, 1, 0, 0, 0, 174, 169, 1, 0, 0, 0, 175, 178, 1, 0, 0, 0, 176, 174, 1, 0, 0, 0, 176, 177, 1, 0, 0, 0, 177, 182, 1, 0, 0, 0, 178, 176, 1, 0, 0, 0, 179, 180, 5, 9, 0, 0, 180, 181, 5, 34, 0, 0, 181, 183, 3, 30, 15, 0, 182, 179, 1, 0, 0, 0, 182, 183, 1, 0, 0, 0, 183, 25, 1, 0, 0, 0, 184, 185, 5, 23, 0, 0, 185, 186, 3, 34, 17, 0, 186, 187, 5, 34, 0, 0, 187, 191, 3, 30, 15, 0, 188, 189, 5, 9, 0, 0, 189, 190, 5, 34, 0, 0, 190, 192, 3, 30, 15, 0, 191, 188, 1, 0, 0, 0, 191, 192, 1, 0, 0, 0, 192, 27, 1, 0, 0, 0, 193, 194, 5, 11, 0, 0, 194, 195, 3, 42, 21, 0, 195, 196, 5, 34, 0, 0, 196, 200, 3, 30, 15, 0, 197, 198, 5, 9, 0, 0, 198, 199, 5, 34, 0, 0, 199, 201, 3, 30, 15, 0, 200, 197, 1, 0, 0, 0, 200, 201, 1, 0, 0, 0, 201, 29, 1, 0, 0, 0, 202, 214, 3, 2, 1, 0, 203, 204, 5, 24, 0, 0, 204, 207, 5, 1, 0, 0, 205, 208, 3, 2, 1, 0, 206, 208, 3, 4, 2, 0, 207, 205, 1, 0, 0, 0, 207, 206, 1, 0, 0, 0, 208, 209, 1, 0, 0, 0, 209, 207, 1, 0, 0, 0, 209, 210, 1, 0, 0, 0, 210, 211, 1, 0, 0, 0, 211, 212, 5, 2, 0, 0, 212, 214, 1, 0, 0, 0, 213, 202, 1, 0, 0, 0, 213, 203, 1, 0, 0, 0, 214, 31, 1, 0, 0, 0, 215, 229, 5, 53, 0, 0, 216, 229, 5, 54, 0, 0, 217, 229, 5, 55, 0, 0, 218, 229, 5, 56, 0, 0, 219, 229, 5, 57, 0, 0, 220, 229, 5, 58, 0, 0, 221, 229, 5, 59, 0, 0, 222, 229, 5, 15, 0, 0, 223, 224, 5, 18, 0, 0, 224, 229, 5, 15, 0, 0, 225, 229, 5, 16, 0, 0, 226, 227, 5, 16, 0, 0, 227, 229, 5, 18, 0, 0, 228, 215, 1, 0, 0, 0, 228, 216, 1, 0, 0, 0, 228, 217, 1, 0, 0, 0, 228, 218, 1, 0, 0, 0, 228, 219, 1, 0, 0, 0, 228, 220, 1, 0, 0, 0, 228, 221, 1, 0, 0, 0, 228, 222, 1, 0, 0, 0, 228, 223, 1, 0, 0, 0, 228, 225, 1, 0, 0, 0, 228, 226, 1, 0, 0, 0, 229, 33, 1, 0, 0, 0, 230, 231, 6, 17, -1, 0, 231, 235, 3, 36, 18, 0, 232, 234, 3, 40, 20, 0, 233, 232, 1, 0, 0, 0, 234, 237, 1, 0, 0, 0, 235, 233, 1, 0, 0, 0, 235, 236, 1, 0, 0, 0, 236, 247, 1, 0, 0, 0, 237, 235, 1, 0, 0, 0, 238, 240, 7, 1, 0, 0, 239, 238, 1, 0, 0, 0, 240, 241, 1, 0, 0, 0, 241, 239, 1, 0, 0, 0, 241, 242, 1, 0, 0, 0, 242, 243, 1, 0, 0, 0, 243, 247, 3, 34, 17, 12, 244, 245, 5, 18, 0, 0, 245, 247, 3, 34, 17, 5, 246, 230, 1, 0, 0, 0, 246, 239, 1, 0, 0, 0, 246, 244, 1, 0, 0, 0, 247, 287, 1, 0, 0, 0, 248, 249, 10, 13, 0, 0, 249, 250, 5, 36, 0, 0, 250, 286, 3, 34, 17, 14, 251, 252, 10, 11, 0, 0, 252, 253, 7, 2, 0, 0, 253, 286, 3, 34, 17, 12, 254, 255, 10, 10, 0, 0, 255, 256, 7, 3, 0, 0, 256, 286, 3, 34, 17, 11, 257, 258, 10, 9, 0, 0, 258, 259, 7, 4, 0, 0, 259, 286, 3, 34, 17, 10, 260, 261, 10, 8, 0, 0, 261, 262, 5, 42, 0, 0, 262, 286, 3, 34, 17, 9, 263, 264, 10, 7, 0, 0, 264, 265, 5, 41, 0, 0, 265, 286, 3, 34, 17, 8, 266, 267, 10, 6, 0, 0, 267, 268, 5, 40, 0, 0, 268, 286, 3, 34, 17, 7, 269, 270, 10, 4, 0, 0, 270, 271, 3, 32, 16, 0, 271, 272, 3, 34, 17, 5, 272, 286, 1, 0, 0, 0, 273, 274, 10, 3, 0, 0, 274, 275, 5, 5, 0, 0, 275, 286, 3, 34, 17, 4, 276, 277, 10, 2, 0, 0, 277, 278, 5, 19, 0, 0, 278, 286, 3, 34, 17, 3, 279, 280, 10, 1, 0, 0, 280, 281, 5, 13, 0, 0, 281, 282, 3, 34, 17, 0, 282, 283, 5, 9, 0, 0, 283, 284, 3, 34, 17, 2, 284, 286, 1, 0, 0, 0, 285, 248, 1, 0, 0, 0, 285, 251, 1, 0, 0, 0, 285, 254, 1, 0, 0, 0, 285, 257, 1, 0, 0, 0, 285, 260, 1, 0, 0, 0, 285, 263, 1, 0, 0, 0, 285, 266, 1, 0, 0, 0, 285, 269, 1, 0, 0, 0, 285, 273, 1, 0, 0, 0, 285, 276, 1, 0, 0, 0, 285, 279, 1, 0, 0, 0, 286, 289, 1, 0, 0, 0, 287, 285, 1, 0, 0, 0, 287, 288, 1, 0, 0, 0, 288, 35, 1, 0, 0, 0, 289, 287, 1, 0, 0, 0, 290, 292, 5, 31, 0, 0, 291, 293, 3, 38, 19, 0, 292, 291, 1, 0, 0, 0, 292, 293, 1, 0, 0, 0, 293, 294, 1, 0, 0, 0, 294, 317, 5, 32, 0, 0, 295, 297, 5, 38, 0, 0, 296, 298, 3, 38, 19, 0, 297, 296, 1, 0, 0, 0, 297, 298, 1, 0, 0, 0, 298, 299, 1, 0, 0, 0, 299, 317, 5, 39, 0, 0, 300, 302, 5, 51, 0, 0, 301, 303, 3, 38, 19, 0, 302, 301, 1, 0, 0, 0, 302, 303, 1, 0, 0, 0, 303, 304, 1, 0, 0, 0, 304, 317, 5, 52, 0, 0, 305, 317, 5, 25, 0, 0, 306, 317, 5, 4, 0, 0, 307, 309, 5, 3, 0, 0, 308, 307, 1, 0, 0, 0, 309, 310, 1, 0, 0, 0, 310, 308, 1, 0, 0, 0, 310, 311, 1, 0, 0, 0, 311, 317, 1, 0, 0, 0, 312, 317, 5, 29, 0, 0, 313, 317, 5, 17, 0, 0, 314, 317, 5, 21, 0, 0, 315, 317, 5, 10, 0, 0, 316, 290, 1, 0, 0, 0, 316, 295, 1, 0, 0, 0, 316, 300, 1, 0, 0, 0, 316, 305, 1, 0, 0, 0, 316, 306, 1, 0, 0, 0, 316, 308, 1, 0, 0, 0, 316, 312, 1, 0, 0, 0, 316, 313, 1, 0, 0, 0, 316, 314, 1, 0, 0, 0, 316, 315, 1, 0, 0, 0, 317, 37, 1, 0, 0, 0, 318, 330, 3, 34, 17, 0, 319, 331, 3, 50, 25, 0, 320, 321, 5, 33, 0, 0, 321, 323, 3, 34, 17, 0, 322, 320, 1, 0, 0, 0, 323, 326, 1, 0, 0, 0, 324, 322, 1, 0, 0, 0, 324, 325, 1, 0, 0, 0, 325, 328, 1, 0, 0, 0, 326, 324, 1, 0, 0, 0, 327, 329, 5, 33, 0, 0, 328, 327, 1, 0, 0, 0, 328, 329, 1, 0, 0, 0, 329, 331, 1, 0, 0, 0, 330, 319, 1, 0, 0, 0, 330, 324, 1, 0, 0, 0, 331, 39, 1, 0, 0, 0, 332, 334, 5, 31, 0, 0, 333, 335, 3, 44, 22, 0, 334, 333, 1, 0, 0, 0, 334, 335, 1, 0, 0, 0, 335, 336, 1, 0, 0, 0, 336, 369, 5, 32, 0, 0, 337, 338, 5, 38, 0, 0, 338, 343, 3, 34, 17, 0, 339, 340, 5, 33, 0, 0, 340, 342, 3, 34, 17, 0, 341, 339, 1, 0, 0, 0, 342, 345, 1, 0, 0, 0, 343, 341, 1, 0, 0, 0, 343, 344, 1, 0, 0, 0, 344, 347, 1, 0, 0, 0, 345, 343, 1, 0, 0, 0, 346, 348, 5, 33, 0, 0, 347, 346, 1, 0, 0, 0, 347, 348, 1, 0, 0, 0, 348, 349, 1, 0, 0, 0, 349, 350, 5, 39, 0, 0, 350, 369, 1, 0, 0, 0, 351, 352, 5, 28, 0, 0, 352, 369, 5, 25, 0, 0, 353, 355, 5, 38, 0, 0, 354, 356, 3, 34, 17, 0, 355, 354, 1, 0, 0, 0, 355, 356, 1, 0, 0, 0, 356, 357, 1, 0, 0, 0, 357, 359, 5, 34, 0, 0, 358, 360, 3, 34, 17, 0, 359, 358, 1, 0, 0, 0, 359, 360, 1, 0, 0, 0, 360, 365, 1, 0, 0, 0, 361, 363, 5, 34, 0, 0, 362, 364, 3, 34, 17, 0, 363, 362, 1, 0, 0, 0, 363, 364, 1, 0, 0, 0, 364, 366, 1, 0, 0, 0, 365, 361, 1, 0, 0, 0, 365, 366, 1, 0, 0, 0, 366, 367, 1, 0, 0, 0, 367, 369, 5, 39, 0, 0, 368, 332, 1, 0, 0, 0, 368, 337, 1, 0, 0, 0, 368, 351, 1, 0, 0, 0, 368, 353, 1, 0, 0, 0, 369, 41, 1, 0, 0, 0, 370, 375, 3, 34, 17, 0, 371, 372, 5, 33, 0, 0, 372, 374, 3, 34, 17, 0, 373, 371, 1, 0, 0, 0, 374, 377, 1, 0, 0, 0, 375, 373, 1, 0, 0, 0, 375, 376, 1, 0, 0, 0, 376, 379, 1, 0, 0, 0, 377, 375, 1, 0, 0, 0, 378, 380, 5, 33, 0, 0, 379, 378, 1, 0, 0, 0, 379, 380, 1, 0, 0, 0, 380, 43, 1, 0, 0, 0, 381, 386, 3, 46, 23, 0, 382, 383, 5, 33, 0, 0, 383, 385, 3, 46, 23, 0, 384, 382, 1, 0, 0, 0, 385, 388, 1, 0, 0, 0, 386, 384, 1, 0, 0, 0, 386, 387, 1, 0, 0, 0, 387, 390, 1, 0, 0, 0, 388, 386, 1, 0, 0, 0, 389, 391, 5, 33, 0, 0, 390, 389, 1, 0, 0, 0, 390, 391, 1, 0, 0, 0, 391, 45, 1, 0, 0, 0, 392, 394, 3, 34, 17, 0, 393, 395, 3, 50, 25, 0, 394, 393, 1, 0, 0, 0, 394, 395, 1, 0, 0, 0, 395, 401, 1, 0, 0, 0, 396, 397, 3, 34, 17, 0, 397, 398, 5, 37, 0, 0, 398, 399, 3, 34, 17, 0, 399, 401, 1, 0, 0, 0, 400, 392, 1, 0, 0, 0, 400, 396, 1, 0, 0, 0, 401, 47, 1, 0, 0, 0, 402, 405, 3, 50, 25, 0, 403, 405, 3, 52, 26, 0, 404, 402, 1, 0, 0, 0, 404, 403, 1, 0, 0, 0, 405, 49, 1, 0, 0, 0, 406, 407, 5, 11, 0, 0, 407, 408, 3, 42, 21, 0, 408, 409, 5, 15, 0, 0, 409, 411, 3, 34, 17, 0, 410, 412, 3, 48, 24, 0, 411, 410, 1, 0, 0, 0, 411, 412, 1, 0, 0, 0, 412, 51, 1, 0, 0, 0, 413, 414, 5, 13, 0, 0, 414, 416, 3, 34, 17, 0, 415, 417, 3, 48, 24, 0, 416, 415, 1, 0, 0, 0, 416, 417, 1, 0, 0, 0, 417, 53, 1, 0, 0, 0, 56, 57, 62, 64, 74, 78, 86, 92, 100, 106, 116, 120, 122, 129, 136, 145, 151, 155, 161, 176, 182, 191, 200, 207, 209, 213, 228, 235, 241, 246, 285, 287, 292, 297, 302, 310, 316, 324, 328, 330, 334, 343, 347, 355, 359, 363, 365, 368, 375, 379, 386, 390, 394, 400, 404, 411, 416]
\ No newline at end of file diff --git a/src/Python3Parser.java b/src/Python3Parser.java new file mode 100644 index 0000000..99dab31 --- /dev/null +++ b/src/Python3Parser.java @@ -0,0 +1,3110 @@ +// Generated from src/Python3Parser.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; +import java.util.List; +import java.util.Iterator; +import java.util.ArrayList; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) +public class Python3Parser extends Python3ParserBase { +	static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + +	protected static final DFA[] _decisionToDFA; +	protected static final PredictionContextCache _sharedContextCache = +		new PredictionContextCache(); +	public static final int +		INDENT=1, DEDENT=2, STRING=3, NUMBER=4, AND=5, AS=6, DEF=7, ELIF=8, ELSE=9,  +		FALSE=10, FOR=11, FROM=12, IF=13, IMPORT=14, IN=15, IS=16, NONE=17, NOT=18,  +		OR=19, RETURN=20, TRUE=21, UNDERSCORE=22, WHILE=23, NEWLINE=24, NAME=25,  +		DECIMAL_INTEGER=26, FLOAT_NUMBER=27, DOT=28, ELLIPSIS=29, STAR=30, OPEN_PAREN=31,  +		CLOSE_PAREN=32, COMMA=33, COLON=34, SEMI_COLON=35, POWER=36, ASSIGN=37,  +		OPEN_BRACK=38, CLOSE_BRACK=39, OR_OP=40, XOR=41, AND_OP=42, LEFT_SHIFT=43,  +		RIGHT_SHIFT=44, ADD=45, MINUS=46, DIV=47, MOD=48, IDIV=49, NOT_OP=50,  +		OPEN_BRACE=51, CLOSE_BRACE=52, LESS_THAN=53, GREATER_THAN=54, EQUALS=55,  +		GT_EQ=56, LT_EQ=57, NOT_EQ_1=58, NOT_EQ_2=59, AT=60, ARROW=61, ADD_ASSIGN=62,  +		SUB_ASSIGN=63, MULT_ASSIGN=64, AT_ASSIGN=65, DIV_ASSIGN=66, MOD_ASSIGN=67,  +		AND_ASSIGN=68, OR_ASSIGN=69, XOR_ASSIGN=70, LEFT_SHIFT_ASSIGN=71, RIGHT_SHIFT_ASSIGN=72,  +		POWER_ASSIGN=73, IDIV_ASSIGN=74, SKIP_=75, UNKNOWN_CHAR=76; +	public static final int +		RULE_root = 0, RULE_simple_stmts = 1, RULE_compound_stmt = 2, RULE_simple_stmt = 3,  +		RULE_assignment = 4, RULE_return_stmt = 5, RULE_import_stm = 6, RULE_dotted_name = 7,  +		RULE_funcdef = 8, RULE_paramlist = 9, RULE_paramdef = 10, RULE_augassign = 11,  +		RULE_if_stmt = 12, RULE_while_stmt = 13, RULE_for_stmt = 14, RULE_block = 15,  +		RULE_comp_op = 16, RULE_expr = 17, RULE_atom = 18, RULE_testlist_comp = 19,  +		RULE_trailer = 20, RULE_exprlist = 21, RULE_arglist = 22, RULE_argument = 23,  +		RULE_comp_iter = 24, RULE_comp_for = 25, RULE_comp_if = 26; +	private static String[] makeRuleNames() { +		return new String[] { +			"root", "simple_stmts", "compound_stmt", "simple_stmt", "assignment",  +			"return_stmt", "import_stm", "dotted_name", "funcdef", "paramlist", "paramdef",  +			"augassign", "if_stmt", "while_stmt", "for_stmt", "block", "comp_op",  +			"expr", "atom", "testlist_comp", "trailer", "exprlist", "arglist", "argument",  +			"comp_iter", "comp_for", "comp_if" +		}; +	} +	public static final String[] ruleNames = makeRuleNames(); + +	private static String[] makeLiteralNames() { +		return new String[] { +			null, null, null, null, null, "'and'", "'as'", "'def'", "'elif'", "'else'",  +			"'False'", "'for'", "'from'", "'if'", "'import'", "'in'", "'is'", "'None'",  +			"'not'", "'or'", "'return'", "'True'", "'_'", "'while'", null, null,  +			null, null, "'.'", "'...'", "'*'", "'('", "')'", "','", "':'", "';'",  +			"'**'", "'='", "'['", "']'", "'|'", "'^'", "'&'", "'<<'", "'>>'", "'+'",  +			"'-'", "'/'", "'%'", "'//'", "'~'", "'{'", "'}'", "'<'", "'>'", "'=='",  +			"'>='", "'<='", "'<>'", "'!='", "'@'", "'->'", "'+='", "'-='", "'*='",  +			"'@='", "'/='", "'%='", "'&='", "'|='", "'^='", "'<<='", "'>>='", "'**='",  +			"'//='" +		}; +	} +	private static final String[] _LITERAL_NAMES = makeLiteralNames(); +	private static String[] makeSymbolicNames() { +		return new String[] { +			null, "INDENT", "DEDENT", "STRING", "NUMBER", "AND", "AS", "DEF", "ELIF",  +			"ELSE", "FALSE", "FOR", "FROM", "IF", "IMPORT", "IN", "IS", "NONE", "NOT",  +			"OR", "RETURN", "TRUE", "UNDERSCORE", "WHILE", "NEWLINE", "NAME", "DECIMAL_INTEGER",  +			"FLOAT_NUMBER", "DOT", "ELLIPSIS", "STAR", "OPEN_PAREN", "CLOSE_PAREN",  +			"COMMA", "COLON", "SEMI_COLON", "POWER", "ASSIGN", "OPEN_BRACK", "CLOSE_BRACK",  +			"OR_OP", "XOR", "AND_OP", "LEFT_SHIFT", "RIGHT_SHIFT", "ADD", "MINUS",  +			"DIV", "MOD", "IDIV", "NOT_OP", "OPEN_BRACE", "CLOSE_BRACE", "LESS_THAN",  +			"GREATER_THAN", "EQUALS", "GT_EQ", "LT_EQ", "NOT_EQ_1", "NOT_EQ_2", "AT",  +			"ARROW", "ADD_ASSIGN", "SUB_ASSIGN", "MULT_ASSIGN", "AT_ASSIGN", "DIV_ASSIGN",  +			"MOD_ASSIGN", "AND_ASSIGN", "OR_ASSIGN", "XOR_ASSIGN", "LEFT_SHIFT_ASSIGN",  +			"RIGHT_SHIFT_ASSIGN", "POWER_ASSIGN", "IDIV_ASSIGN", "SKIP_", "UNKNOWN_CHAR" +		}; +	} +	private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); +	public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + +	/** +	 * @deprecated Use {@link #VOCABULARY} instead. +	 */ +	@Deprecated +	public static final String[] tokenNames; +	static { +		tokenNames = new String[_SYMBOLIC_NAMES.length]; +		for (int i = 0; i < tokenNames.length; i++) { +			tokenNames[i] = VOCABULARY.getLiteralName(i); +			if (tokenNames[i] == null) { +				tokenNames[i] = VOCABULARY.getSymbolicName(i); +			} + +			if (tokenNames[i] == null) { +				tokenNames[i] = "<INVALID>"; +			} +		} +	} + +	@Override +	@Deprecated +	public String[] getTokenNames() { +		return tokenNames; +	} + +	@Override + +	public Vocabulary getVocabulary() { +		return VOCABULARY; +	} + +	@Override +	public String getGrammarFileName() { return "Python3Parser.g4"; } + +	@Override +	public String[] getRuleNames() { return ruleNames; } + +	@Override +	public String getSerializedATN() { return _serializedATN; } + +	@Override +	public ATN getATN() { return _ATN; } + +	public Python3Parser(TokenStream input) { +		super(input); +		_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class RootContext extends ParserRuleContext { +		public TerminalNode EOF() { return getToken(Python3Parser.EOF, 0); } +		public List<TerminalNode> NEWLINE() { return getTokens(Python3Parser.NEWLINE); } +		public TerminalNode NEWLINE(int i) { +			return getToken(Python3Parser.NEWLINE, i); +		} +		public List<Simple_stmtsContext> simple_stmts() { +			return getRuleContexts(Simple_stmtsContext.class); +		} +		public Simple_stmtsContext simple_stmts(int i) { +			return getRuleContext(Simple_stmtsContext.class,i); +		} +		public List<Compound_stmtContext> compound_stmt() { +			return getRuleContexts(Compound_stmtContext.class); +		} +		public Compound_stmtContext compound_stmt(int i) { +			return getRuleContext(Compound_stmtContext.class,i); +		} +		public RootContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_root; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterRoot(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitRoot(this); +		} +	} + +	public final RootContext root() throws RecognitionException { +		RootContext _localctx = new RootContext(_ctx, getState()); +		enterRule(_localctx, 0, RULE_root); +		int _la; +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(57); +			_errHandler.sync(this); +			_la = _input.LA(1); +			while (_la==NEWLINE) { +				{ +				{ +				setState(54); +				match(NEWLINE); +				} +				} +				setState(59); +				_errHandler.sync(this); +				_la = _input.LA(1); +			} +			setState(64); +			_errHandler.sync(this); +			_la = _input.LA(1); +			while ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3483530444569752L) != 0)) { +				{ +				setState(62); +				_errHandler.sync(this); +				switch (_input.LA(1)) { +				case STRING: +				case NUMBER: +				case FALSE: +				case FROM: +				case IMPORT: +				case NONE: +				case NOT: +				case RETURN: +				case TRUE: +				case NAME: +				case ELLIPSIS: +				case OPEN_PAREN: +				case OPEN_BRACK: +				case ADD: +				case MINUS: +				case NOT_OP: +				case OPEN_BRACE: +					{ +					setState(60); +					simple_stmts(); +					} +					break; +				case DEF: +				case FOR: +				case IF: +				case WHILE: +					{ +					setState(61); +					compound_stmt(); +					} +					break; +				default: +					throw new NoViableAltException(this); +				} +				} +				setState(66); +				_errHandler.sync(this); +				_la = _input.LA(1); +			} +			setState(67); +			match(EOF); +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class Simple_stmtsContext extends ParserRuleContext { +		public List<Simple_stmtContext> simple_stmt() { +			return getRuleContexts(Simple_stmtContext.class); +		} +		public Simple_stmtContext simple_stmt(int i) { +			return getRuleContext(Simple_stmtContext.class,i); +		} +		public TerminalNode NEWLINE() { return getToken(Python3Parser.NEWLINE, 0); } +		public List<TerminalNode> SEMI_COLON() { return getTokens(Python3Parser.SEMI_COLON); } +		public TerminalNode SEMI_COLON(int i) { +			return getToken(Python3Parser.SEMI_COLON, i); +		} +		public Simple_stmtsContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_simple_stmts; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterSimple_stmts(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitSimple_stmts(this); +		} +	} + +	public final Simple_stmtsContext simple_stmts() throws RecognitionException { +		Simple_stmtsContext _localctx = new Simple_stmtsContext(_ctx, getState()); +		enterRule(_localctx, 2, RULE_simple_stmts); +		int _la; +		try { +			int _alt; +			enterOuterAlt(_localctx, 1); +			{ +			setState(69); +			simple_stmt(); +			setState(74); +			_errHandler.sync(this); +			_alt = getInterpreter().adaptivePredict(_input,3,_ctx); +			while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { +				if ( _alt==1 ) { +					{ +					{ +					setState(70); +					match(SEMI_COLON); +					setState(71); +					simple_stmt(); +					} +					}  +				} +				setState(76); +				_errHandler.sync(this); +				_alt = getInterpreter().adaptivePredict(_input,3,_ctx); +			} +			setState(78); +			_errHandler.sync(this); +			_la = _input.LA(1); +			if (_la==SEMI_COLON) { +				{ +				setState(77); +				match(SEMI_COLON); +				} +			} + +			setState(80); +			match(NEWLINE); +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class Compound_stmtContext extends ParserRuleContext { +		public If_stmtContext if_stmt() { +			return getRuleContext(If_stmtContext.class,0); +		} +		public While_stmtContext while_stmt() { +			return getRuleContext(While_stmtContext.class,0); +		} +		public For_stmtContext for_stmt() { +			return getRuleContext(For_stmtContext.class,0); +		} +		public FuncdefContext funcdef() { +			return getRuleContext(FuncdefContext.class,0); +		} +		public Compound_stmtContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_compound_stmt; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterCompound_stmt(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitCompound_stmt(this); +		} +	} + +	public final Compound_stmtContext compound_stmt() throws RecognitionException { +		Compound_stmtContext _localctx = new Compound_stmtContext(_ctx, getState()); +		enterRule(_localctx, 4, RULE_compound_stmt); +		try { +			setState(86); +			_errHandler.sync(this); +			switch (_input.LA(1)) { +			case IF: +				enterOuterAlt(_localctx, 1); +				{ +				setState(82); +				if_stmt(); +				} +				break; +			case WHILE: +				enterOuterAlt(_localctx, 2); +				{ +				setState(83); +				while_stmt(); +				} +				break; +			case FOR: +				enterOuterAlt(_localctx, 3); +				{ +				setState(84); +				for_stmt(); +				} +				break; +			case DEF: +				enterOuterAlt(_localctx, 4); +				{ +				setState(85); +				funcdef(); +				} +				break; +			default: +				throw new NoViableAltException(this); +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class Simple_stmtContext extends ParserRuleContext { +		public AssignmentContext assignment() { +			return getRuleContext(AssignmentContext.class,0); +		} +		public ExprContext expr() { +			return getRuleContext(ExprContext.class,0); +		} +		public Return_stmtContext return_stmt() { +			return getRuleContext(Return_stmtContext.class,0); +		} +		public Import_stmContext import_stm() { +			return getRuleContext(Import_stmContext.class,0); +		} +		public Simple_stmtContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_simple_stmt; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterSimple_stmt(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitSimple_stmt(this); +		} +	} + +	public final Simple_stmtContext simple_stmt() throws RecognitionException { +		Simple_stmtContext _localctx = new Simple_stmtContext(_ctx, getState()); +		enterRule(_localctx, 6, RULE_simple_stmt); +		try { +			setState(92); +			_errHandler.sync(this); +			switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) { +			case 1: +				enterOuterAlt(_localctx, 1); +				{ +				setState(88); +				assignment(); +				} +				break; +			case 2: +				enterOuterAlt(_localctx, 2); +				{ +				setState(89); +				expr(0); +				} +				break; +			case 3: +				enterOuterAlt(_localctx, 3); +				{ +				setState(90); +				return_stmt(); +				} +				break; +			case 4: +				enterOuterAlt(_localctx, 4); +				{ +				setState(91); +				import_stm(); +				} +				break; +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class AssignmentContext extends ParserRuleContext { +		public List<ExprlistContext> exprlist() { +			return getRuleContexts(ExprlistContext.class); +		} +		public ExprlistContext exprlist(int i) { +			return getRuleContext(ExprlistContext.class,i); +		} +		public AugassignContext augassign() { +			return getRuleContext(AugassignContext.class,0); +		} +		public AssignmentContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_assignment; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterAssignment(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitAssignment(this); +		} +	} + +	public final AssignmentContext assignment() throws RecognitionException { +		AssignmentContext _localctx = new AssignmentContext(_ctx, getState()); +		enterRule(_localctx, 8, RULE_assignment); +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(94); +			exprlist(); +			setState(95); +			augassign(); +			setState(96); +			exprlist(); +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class Return_stmtContext extends ParserRuleContext { +		public TerminalNode RETURN() { return getToken(Python3Parser.RETURN, 0); } +		public ExprlistContext exprlist() { +			return getRuleContext(ExprlistContext.class,0); +		} +		public Return_stmtContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_return_stmt; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterReturn_stmt(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitReturn_stmt(this); +		} +	} + +	public final Return_stmtContext return_stmt() throws RecognitionException { +		Return_stmtContext _localctx = new Return_stmtContext(_ctx, getState()); +		enterRule(_localctx, 10, RULE_return_stmt); +		int _la; +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(98); +			match(RETURN); +			setState(100); +			_errHandler.sync(this); +			_la = _input.LA(1); +			if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3483530435101720L) != 0)) { +				{ +				setState(99); +				exprlist(); +				} +			} + +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class Import_stmContext extends ParserRuleContext { +		public TerminalNode IMPORT() { return getToken(Python3Parser.IMPORT, 0); } +		public Dotted_nameContext dotted_name() { +			return getRuleContext(Dotted_nameContext.class,0); +		} +		public TerminalNode AS() { return getToken(Python3Parser.AS, 0); } +		public List<TerminalNode> NAME() { return getTokens(Python3Parser.NAME); } +		public TerminalNode NAME(int i) { +			return getToken(Python3Parser.NAME, i); +		} +		public TerminalNode FROM() { return getToken(Python3Parser.FROM, 0); } +		public TerminalNode STAR() { return getToken(Python3Parser.STAR, 0); } +		public List<TerminalNode> COMMA() { return getTokens(Python3Parser.COMMA); } +		public TerminalNode COMMA(int i) { +			return getToken(Python3Parser.COMMA, i); +		} +		public Import_stmContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_import_stm; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterImport_stm(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitImport_stm(this); +		} +	} + +	public final Import_stmContext import_stm() throws RecognitionException { +		Import_stmContext _localctx = new Import_stmContext(_ctx, getState()); +		enterRule(_localctx, 12, RULE_import_stm); +		int _la; +		try { +			setState(122); +			_errHandler.sync(this); +			switch (_input.LA(1)) { +			case IMPORT: +				enterOuterAlt(_localctx, 1); +				{ +				setState(102); +				match(IMPORT); +				setState(103); +				dotted_name(); +				setState(106); +				_errHandler.sync(this); +				_la = _input.LA(1); +				if (_la==AS) { +					{ +					setState(104); +					match(AS); +					setState(105); +					match(NAME); +					} +				} + +				} +				break; +			case FROM: +				enterOuterAlt(_localctx, 2); +				{ +				setState(108); +				match(FROM); +				setState(109); +				dotted_name(); +				setState(110); +				match(IMPORT); +				setState(120); +				_errHandler.sync(this); +				switch (_input.LA(1)) { +				case NAME: +					{ +					setState(111); +					match(NAME); +					setState(116); +					_errHandler.sync(this); +					_la = _input.LA(1); +					while (_la==COMMA) { +						{ +						{ +						setState(112); +						match(COMMA); +						setState(113); +						match(NAME); +						} +						} +						setState(118); +						_errHandler.sync(this); +						_la = _input.LA(1); +					} +					} +					break; +				case STAR: +					{ +					setState(119); +					match(STAR); +					} +					break; +				default: +					throw new NoViableAltException(this); +				} +				} +				break; +			default: +				throw new NoViableAltException(this); +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class Dotted_nameContext extends ParserRuleContext { +		public List<TerminalNode> NAME() { return getTokens(Python3Parser.NAME); } +		public TerminalNode NAME(int i) { +			return getToken(Python3Parser.NAME, i); +		} +		public List<TerminalNode> DOT() { return getTokens(Python3Parser.DOT); } +		public TerminalNode DOT(int i) { +			return getToken(Python3Parser.DOT, i); +		} +		public Dotted_nameContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_dotted_name; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterDotted_name(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitDotted_name(this); +		} +	} + +	public final Dotted_nameContext dotted_name() throws RecognitionException { +		Dotted_nameContext _localctx = new Dotted_nameContext(_ctx, getState()); +		enterRule(_localctx, 14, RULE_dotted_name); +		int _la; +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(124); +			match(NAME); +			setState(129); +			_errHandler.sync(this); +			_la = _input.LA(1); +			while (_la==DOT) { +				{ +				{ +				setState(125); +				match(DOT); +				setState(126); +				match(NAME); +				} +				} +				setState(131); +				_errHandler.sync(this); +				_la = _input.LA(1); +			} +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class FuncdefContext extends ParserRuleContext { +		public TerminalNode DEF() { return getToken(Python3Parser.DEF, 0); } +		public TerminalNode NAME() { return getToken(Python3Parser.NAME, 0); } +		public TerminalNode OPEN_PAREN() { return getToken(Python3Parser.OPEN_PAREN, 0); } +		public TerminalNode CLOSE_PAREN() { return getToken(Python3Parser.CLOSE_PAREN, 0); } +		public TerminalNode COLON() { return getToken(Python3Parser.COLON, 0); } +		public BlockContext block() { +			return getRuleContext(BlockContext.class,0); +		} +		public ParamlistContext paramlist() { +			return getRuleContext(ParamlistContext.class,0); +		} +		public FuncdefContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_funcdef; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterFuncdef(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitFuncdef(this); +		} +	} + +	public final FuncdefContext funcdef() throws RecognitionException { +		FuncdefContext _localctx = new FuncdefContext(_ctx, getState()); +		enterRule(_localctx, 16, RULE_funcdef); +		int _la; +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(132); +			match(DEF); +			setState(133); +			match(NAME); +			setState(134); +			match(OPEN_PAREN); +			setState(136); +			_errHandler.sync(this); +			_la = _input.LA(1); +			if (_la==NAME) { +				{ +				setState(135); +				paramlist(); +				} +			} + +			setState(138); +			match(CLOSE_PAREN); +			setState(139); +			match(COLON); +			setState(140); +			block(); +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class ParamlistContext extends ParserRuleContext { +		public List<ParamdefContext> paramdef() { +			return getRuleContexts(ParamdefContext.class); +		} +		public ParamdefContext paramdef(int i) { +			return getRuleContext(ParamdefContext.class,i); +		} +		public List<TerminalNode> ASSIGN() { return getTokens(Python3Parser.ASSIGN); } +		public TerminalNode ASSIGN(int i) { +			return getToken(Python3Parser.ASSIGN, i); +		} +		public List<ExprContext> expr() { +			return getRuleContexts(ExprContext.class); +		} +		public ExprContext expr(int i) { +			return getRuleContext(ExprContext.class,i); +		} +		public List<TerminalNode> COMMA() { return getTokens(Python3Parser.COMMA); } +		public TerminalNode COMMA(int i) { +			return getToken(Python3Parser.COMMA, i); +		} +		public ParamlistContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_paramlist; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterParamlist(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitParamlist(this); +		} +	} + +	public final ParamlistContext paramlist() throws RecognitionException { +		ParamlistContext _localctx = new ParamlistContext(_ctx, getState()); +		enterRule(_localctx, 18, RULE_paramlist); +		int _la; +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(142); +			paramdef(); +			setState(145); +			_errHandler.sync(this); +			_la = _input.LA(1); +			if (_la==ASSIGN) { +				{ +				setState(143); +				match(ASSIGN); +				setState(144); +				expr(0); +				} +			} + +			setState(155); +			_errHandler.sync(this); +			_la = _input.LA(1); +			while (_la==COMMA) { +				{ +				{ +				setState(147); +				match(COMMA); +				setState(148); +				paramdef(); +				setState(151); +				_errHandler.sync(this); +				_la = _input.LA(1); +				if (_la==ASSIGN) { +					{ +					setState(149); +					match(ASSIGN); +					setState(150); +					expr(0); +					} +				} + +				} +				} +				setState(157); +				_errHandler.sync(this); +				_la = _input.LA(1); +			} +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class ParamdefContext extends ParserRuleContext { +		public TerminalNode NAME() { return getToken(Python3Parser.NAME, 0); } +		public TerminalNode COLON() { return getToken(Python3Parser.COLON, 0); } +		public ExprContext expr() { +			return getRuleContext(ExprContext.class,0); +		} +		public ParamdefContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_paramdef; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterParamdef(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitParamdef(this); +		} +	} + +	public final ParamdefContext paramdef() throws RecognitionException { +		ParamdefContext _localctx = new ParamdefContext(_ctx, getState()); +		enterRule(_localctx, 20, RULE_paramdef); +		int _la; +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(158); +			match(NAME); +			setState(161); +			_errHandler.sync(this); +			_la = _input.LA(1); +			if (_la==COLON) { +				{ +				setState(159); +				match(COLON); +				setState(160); +				expr(0); +				} +			} + +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class AugassignContext extends ParserRuleContext { +		public TerminalNode ASSIGN() { return getToken(Python3Parser.ASSIGN, 0); } +		public TerminalNode ADD_ASSIGN() { return getToken(Python3Parser.ADD_ASSIGN, 0); } +		public TerminalNode SUB_ASSIGN() { return getToken(Python3Parser.SUB_ASSIGN, 0); } +		public TerminalNode MULT_ASSIGN() { return getToken(Python3Parser.MULT_ASSIGN, 0); } +		public TerminalNode AT_ASSIGN() { return getToken(Python3Parser.AT_ASSIGN, 0); } +		public TerminalNode DIV_ASSIGN() { return getToken(Python3Parser.DIV_ASSIGN, 0); } +		public TerminalNode MOD_ASSIGN() { return getToken(Python3Parser.MOD_ASSIGN, 0); } +		public TerminalNode AND_ASSIGN() { return getToken(Python3Parser.AND_ASSIGN, 0); } +		public TerminalNode OR_ASSIGN() { return getToken(Python3Parser.OR_ASSIGN, 0); } +		public TerminalNode XOR_ASSIGN() { return getToken(Python3Parser.XOR_ASSIGN, 0); } +		public TerminalNode LEFT_SHIFT_ASSIGN() { return getToken(Python3Parser.LEFT_SHIFT_ASSIGN, 0); } +		public TerminalNode RIGHT_SHIFT_ASSIGN() { return getToken(Python3Parser.RIGHT_SHIFT_ASSIGN, 0); } +		public TerminalNode POWER_ASSIGN() { return getToken(Python3Parser.POWER_ASSIGN, 0); } +		public TerminalNode IDIV_ASSIGN() { return getToken(Python3Parser.IDIV_ASSIGN, 0); } +		public AugassignContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_augassign; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterAugassign(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitAugassign(this); +		} +	} + +	public final AugassignContext augassign() throws RecognitionException { +		AugassignContext _localctx = new AugassignContext(_ctx, getState()); +		enterRule(_localctx, 22, RULE_augassign); +		int _la; +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(163); +			_la = _input.LA(1); +			if ( !(((((_la - 37)) & ~0x3f) == 0 && ((1L << (_la - 37)) & 274844352513L) != 0)) ) { +			_errHandler.recoverInline(this); +			} +			else { +				if ( _input.LA(1)==Token.EOF ) matchedEOF = true; +				_errHandler.reportMatch(this); +				consume(); +			} +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class If_stmtContext extends ParserRuleContext { +		public TerminalNode IF() { return getToken(Python3Parser.IF, 0); } +		public List<ExprContext> expr() { +			return getRuleContexts(ExprContext.class); +		} +		public ExprContext expr(int i) { +			return getRuleContext(ExprContext.class,i); +		} +		public List<TerminalNode> COLON() { return getTokens(Python3Parser.COLON); } +		public TerminalNode COLON(int i) { +			return getToken(Python3Parser.COLON, i); +		} +		public List<BlockContext> block() { +			return getRuleContexts(BlockContext.class); +		} +		public BlockContext block(int i) { +			return getRuleContext(BlockContext.class,i); +		} +		public List<TerminalNode> ELIF() { return getTokens(Python3Parser.ELIF); } +		public TerminalNode ELIF(int i) { +			return getToken(Python3Parser.ELIF, i); +		} +		public TerminalNode ELSE() { return getToken(Python3Parser.ELSE, 0); } +		public If_stmtContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_if_stmt; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterIf_stmt(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitIf_stmt(this); +		} +	} + +	public final If_stmtContext if_stmt() throws RecognitionException { +		If_stmtContext _localctx = new If_stmtContext(_ctx, getState()); +		enterRule(_localctx, 24, RULE_if_stmt); +		int _la; +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(165); +			match(IF); +			setState(166); +			expr(0); +			setState(167); +			match(COLON); +			setState(168); +			block(); +			setState(176); +			_errHandler.sync(this); +			_la = _input.LA(1); +			while (_la==ELIF) { +				{ +				{ +				setState(169); +				match(ELIF); +				setState(170); +				expr(0); +				setState(171); +				match(COLON); +				setState(172); +				block(); +				} +				} +				setState(178); +				_errHandler.sync(this); +				_la = _input.LA(1); +			} +			setState(182); +			_errHandler.sync(this); +			_la = _input.LA(1); +			if (_la==ELSE) { +				{ +				setState(179); +				match(ELSE); +				setState(180); +				match(COLON); +				setState(181); +				block(); +				} +			} + +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class While_stmtContext extends ParserRuleContext { +		public TerminalNode WHILE() { return getToken(Python3Parser.WHILE, 0); } +		public ExprContext expr() { +			return getRuleContext(ExprContext.class,0); +		} +		public List<TerminalNode> COLON() { return getTokens(Python3Parser.COLON); } +		public TerminalNode COLON(int i) { +			return getToken(Python3Parser.COLON, i); +		} +		public List<BlockContext> block() { +			return getRuleContexts(BlockContext.class); +		} +		public BlockContext block(int i) { +			return getRuleContext(BlockContext.class,i); +		} +		public TerminalNode ELSE() { return getToken(Python3Parser.ELSE, 0); } +		public While_stmtContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_while_stmt; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterWhile_stmt(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitWhile_stmt(this); +		} +	} + +	public final While_stmtContext while_stmt() throws RecognitionException { +		While_stmtContext _localctx = new While_stmtContext(_ctx, getState()); +		enterRule(_localctx, 26, RULE_while_stmt); +		int _la; +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(184); +			match(WHILE); +			setState(185); +			expr(0); +			setState(186); +			match(COLON); +			setState(187); +			block(); +			setState(191); +			_errHandler.sync(this); +			_la = _input.LA(1); +			if (_la==ELSE) { +				{ +				setState(188); +				match(ELSE); +				setState(189); +				match(COLON); +				setState(190); +				block(); +				} +			} + +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class For_stmtContext extends ParserRuleContext { +		public TerminalNode FOR() { return getToken(Python3Parser.FOR, 0); } +		public ExprlistContext exprlist() { +			return getRuleContext(ExprlistContext.class,0); +		} +		public List<TerminalNode> COLON() { return getTokens(Python3Parser.COLON); } +		public TerminalNode COLON(int i) { +			return getToken(Python3Parser.COLON, i); +		} +		public List<BlockContext> block() { +			return getRuleContexts(BlockContext.class); +		} +		public BlockContext block(int i) { +			return getRuleContext(BlockContext.class,i); +		} +		public TerminalNode ELSE() { return getToken(Python3Parser.ELSE, 0); } +		public For_stmtContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_for_stmt; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterFor_stmt(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitFor_stmt(this); +		} +	} + +	public final For_stmtContext for_stmt() throws RecognitionException { +		For_stmtContext _localctx = new For_stmtContext(_ctx, getState()); +		enterRule(_localctx, 28, RULE_for_stmt); +		int _la; +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(193); +			match(FOR); +			setState(194); +			exprlist(); +			setState(195); +			match(COLON); +			setState(196); +			block(); +			setState(200); +			_errHandler.sync(this); +			_la = _input.LA(1); +			if (_la==ELSE) { +				{ +				setState(197); +				match(ELSE); +				setState(198); +				match(COLON); +				setState(199); +				block(); +				} +			} + +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class BlockContext extends ParserRuleContext { +		public List<Simple_stmtsContext> simple_stmts() { +			return getRuleContexts(Simple_stmtsContext.class); +		} +		public Simple_stmtsContext simple_stmts(int i) { +			return getRuleContext(Simple_stmtsContext.class,i); +		} +		public TerminalNode NEWLINE() { return getToken(Python3Parser.NEWLINE, 0); } +		public TerminalNode INDENT() { return getToken(Python3Parser.INDENT, 0); } +		public TerminalNode DEDENT() { return getToken(Python3Parser.DEDENT, 0); } +		public List<Compound_stmtContext> compound_stmt() { +			return getRuleContexts(Compound_stmtContext.class); +		} +		public Compound_stmtContext compound_stmt(int i) { +			return getRuleContext(Compound_stmtContext.class,i); +		} +		public BlockContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_block; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterBlock(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitBlock(this); +		} +	} + +	public final BlockContext block() throws RecognitionException { +		BlockContext _localctx = new BlockContext(_ctx, getState()); +		enterRule(_localctx, 30, RULE_block); +		int _la; +		try { +			setState(213); +			_errHandler.sync(this); +			switch (_input.LA(1)) { +			case STRING: +			case NUMBER: +			case FALSE: +			case FROM: +			case IMPORT: +			case NONE: +			case NOT: +			case RETURN: +			case TRUE: +			case NAME: +			case ELLIPSIS: +			case OPEN_PAREN: +			case OPEN_BRACK: +			case ADD: +			case MINUS: +			case NOT_OP: +			case OPEN_BRACE: +				enterOuterAlt(_localctx, 1); +				{ +				setState(202); +				simple_stmts(); +				} +				break; +			case NEWLINE: +				enterOuterAlt(_localctx, 2); +				{ +				setState(203); +				match(NEWLINE); +				setState(204); +				match(INDENT); +				setState(207);  +				_errHandler.sync(this); +				_la = _input.LA(1); +				do { +					{ +					setState(207); +					_errHandler.sync(this); +					switch (_input.LA(1)) { +					case STRING: +					case NUMBER: +					case FALSE: +					case FROM: +					case IMPORT: +					case NONE: +					case NOT: +					case RETURN: +					case TRUE: +					case NAME: +					case ELLIPSIS: +					case OPEN_PAREN: +					case OPEN_BRACK: +					case ADD: +					case MINUS: +					case NOT_OP: +					case OPEN_BRACE: +						{ +						setState(205); +						simple_stmts(); +						} +						break; +					case DEF: +					case FOR: +					case IF: +					case WHILE: +						{ +						setState(206); +						compound_stmt(); +						} +						break; +					default: +						throw new NoViableAltException(this); +					} +					} +					setState(209);  +					_errHandler.sync(this); +					_la = _input.LA(1); +				} while ( (((_la) & ~0x3f) == 0 && ((1L << _la) & 3483530444569752L) != 0) ); +				setState(211); +				match(DEDENT); +				} +				break; +			default: +				throw new NoViableAltException(this); +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class Comp_opContext extends ParserRuleContext { +		public TerminalNode LESS_THAN() { return getToken(Python3Parser.LESS_THAN, 0); } +		public TerminalNode GREATER_THAN() { return getToken(Python3Parser.GREATER_THAN, 0); } +		public TerminalNode EQUALS() { return getToken(Python3Parser.EQUALS, 0); } +		public TerminalNode GT_EQ() { return getToken(Python3Parser.GT_EQ, 0); } +		public TerminalNode LT_EQ() { return getToken(Python3Parser.LT_EQ, 0); } +		public TerminalNode NOT_EQ_1() { return getToken(Python3Parser.NOT_EQ_1, 0); } +		public TerminalNode NOT_EQ_2() { return getToken(Python3Parser.NOT_EQ_2, 0); } +		public TerminalNode IN() { return getToken(Python3Parser.IN, 0); } +		public TerminalNode NOT() { return getToken(Python3Parser.NOT, 0); } +		public TerminalNode IS() { return getToken(Python3Parser.IS, 0); } +		public Comp_opContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_comp_op; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterComp_op(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitComp_op(this); +		} +	} + +	public final Comp_opContext comp_op() throws RecognitionException { +		Comp_opContext _localctx = new Comp_opContext(_ctx, getState()); +		enterRule(_localctx, 32, RULE_comp_op); +		try { +			setState(228); +			_errHandler.sync(this); +			switch ( getInterpreter().adaptivePredict(_input,25,_ctx) ) { +			case 1: +				enterOuterAlt(_localctx, 1); +				{ +				setState(215); +				match(LESS_THAN); +				} +				break; +			case 2: +				enterOuterAlt(_localctx, 2); +				{ +				setState(216); +				match(GREATER_THAN); +				} +				break; +			case 3: +				enterOuterAlt(_localctx, 3); +				{ +				setState(217); +				match(EQUALS); +				} +				break; +			case 4: +				enterOuterAlt(_localctx, 4); +				{ +				setState(218); +				match(GT_EQ); +				} +				break; +			case 5: +				enterOuterAlt(_localctx, 5); +				{ +				setState(219); +				match(LT_EQ); +				} +				break; +			case 6: +				enterOuterAlt(_localctx, 6); +				{ +				setState(220); +				match(NOT_EQ_1); +				} +				break; +			case 7: +				enterOuterAlt(_localctx, 7); +				{ +				setState(221); +				match(NOT_EQ_2); +				} +				break; +			case 8: +				enterOuterAlt(_localctx, 8); +				{ +				setState(222); +				match(IN); +				} +				break; +			case 9: +				enterOuterAlt(_localctx, 9); +				{ +				setState(223); +				match(NOT); +				setState(224); +				match(IN); +				} +				break; +			case 10: +				enterOuterAlt(_localctx, 10); +				{ +				setState(225); +				match(IS); +				} +				break; +			case 11: +				enterOuterAlt(_localctx, 11); +				{ +				setState(226); +				match(IS); +				setState(227); +				match(NOT); +				} +				break; +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class ExprContext extends ParserRuleContext { +		public AtomContext atom() { +			return getRuleContext(AtomContext.class,0); +		} +		public List<TrailerContext> trailer() { +			return getRuleContexts(TrailerContext.class); +		} +		public TrailerContext trailer(int i) { +			return getRuleContext(TrailerContext.class,i); +		} +		public List<ExprContext> expr() { +			return getRuleContexts(ExprContext.class); +		} +		public ExprContext expr(int i) { +			return getRuleContext(ExprContext.class,i); +		} +		public List<TerminalNode> ADD() { return getTokens(Python3Parser.ADD); } +		public TerminalNode ADD(int i) { +			return getToken(Python3Parser.ADD, i); +		} +		public List<TerminalNode> MINUS() { return getTokens(Python3Parser.MINUS); } +		public TerminalNode MINUS(int i) { +			return getToken(Python3Parser.MINUS, i); +		} +		public List<TerminalNode> NOT_OP() { return getTokens(Python3Parser.NOT_OP); } +		public TerminalNode NOT_OP(int i) { +			return getToken(Python3Parser.NOT_OP, i); +		} +		public TerminalNode NOT() { return getToken(Python3Parser.NOT, 0); } +		public TerminalNode POWER() { return getToken(Python3Parser.POWER, 0); } +		public TerminalNode STAR() { return getToken(Python3Parser.STAR, 0); } +		public TerminalNode AT() { return getToken(Python3Parser.AT, 0); } +		public TerminalNode DIV() { return getToken(Python3Parser.DIV, 0); } +		public TerminalNode MOD() { return getToken(Python3Parser.MOD, 0); } +		public TerminalNode IDIV() { return getToken(Python3Parser.IDIV, 0); } +		public TerminalNode LEFT_SHIFT() { return getToken(Python3Parser.LEFT_SHIFT, 0); } +		public TerminalNode RIGHT_SHIFT() { return getToken(Python3Parser.RIGHT_SHIFT, 0); } +		public TerminalNode AND_OP() { return getToken(Python3Parser.AND_OP, 0); } +		public TerminalNode XOR() { return getToken(Python3Parser.XOR, 0); } +		public TerminalNode OR_OP() { return getToken(Python3Parser.OR_OP, 0); } +		public Comp_opContext comp_op() { +			return getRuleContext(Comp_opContext.class,0); +		} +		public TerminalNode AND() { return getToken(Python3Parser.AND, 0); } +		public TerminalNode OR() { return getToken(Python3Parser.OR, 0); } +		public TerminalNode IF() { return getToken(Python3Parser.IF, 0); } +		public TerminalNode ELSE() { return getToken(Python3Parser.ELSE, 0); } +		public ExprContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_expr; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterExpr(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitExpr(this); +		} +	} + +	public final ExprContext expr() throws RecognitionException { +		return expr(0); +	} + +	private ExprContext expr(int _p) throws RecognitionException { +		ParserRuleContext _parentctx = _ctx; +		int _parentState = getState(); +		ExprContext _localctx = new ExprContext(_ctx, _parentState); +		ExprContext _prevctx = _localctx; +		int _startState = 34; +		enterRecursionRule(_localctx, 34, RULE_expr, _p); +		int _la; +		try { +			int _alt; +			enterOuterAlt(_localctx, 1); +			{ +			setState(246); +			_errHandler.sync(this); +			switch (_input.LA(1)) { +			case STRING: +			case NUMBER: +			case FALSE: +			case NONE: +			case TRUE: +			case NAME: +			case ELLIPSIS: +			case OPEN_PAREN: +			case OPEN_BRACK: +			case OPEN_BRACE: +				{ +				setState(231); +				atom(); +				setState(235); +				_errHandler.sync(this); +				_alt = getInterpreter().adaptivePredict(_input,26,_ctx); +				while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { +					if ( _alt==1 ) { +						{ +						{ +						setState(232); +						trailer(); +						} +						}  +					} +					setState(237); +					_errHandler.sync(this); +					_alt = getInterpreter().adaptivePredict(_input,26,_ctx); +				} +				} +				break; +			case ADD: +			case MINUS: +			case NOT_OP: +				{ +				setState(239);  +				_errHandler.sync(this); +				_alt = 1; +				do { +					switch (_alt) { +					case 1: +						{ +						{ +						setState(238); +						_la = _input.LA(1); +						if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 1231453023109120L) != 0)) ) { +						_errHandler.recoverInline(this); +						} +						else { +							if ( _input.LA(1)==Token.EOF ) matchedEOF = true; +							_errHandler.reportMatch(this); +							consume(); +						} +						} +						} +						break; +					default: +						throw new NoViableAltException(this); +					} +					setState(241);  +					_errHandler.sync(this); +					_alt = getInterpreter().adaptivePredict(_input,27,_ctx); +				} while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); +				setState(243); +				expr(12); +				} +				break; +			case NOT: +				{ +				setState(244); +				match(NOT); +				setState(245); +				expr(5); +				} +				break; +			default: +				throw new NoViableAltException(this); +			} +			_ctx.stop = _input.LT(-1); +			setState(287); +			_errHandler.sync(this); +			_alt = getInterpreter().adaptivePredict(_input,30,_ctx); +			while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { +				if ( _alt==1 ) { +					if ( _parseListeners!=null ) triggerExitRuleEvent(); +					_prevctx = _localctx; +					{ +					setState(285); +					_errHandler.sync(this); +					switch ( getInterpreter().adaptivePredict(_input,29,_ctx) ) { +					case 1: +						{ +						_localctx = new ExprContext(_parentctx, _parentState); +						pushNewRecursionContext(_localctx, _startState, RULE_expr); +						setState(248); +						if (!(precpred(_ctx, 13))) throw new FailedPredicateException(this, "precpred(_ctx, 13)"); +						setState(249); +						match(POWER); +						setState(250); +						expr(14); +						} +						break; +					case 2: +						{ +						_localctx = new ExprContext(_parentctx, _parentState); +						pushNewRecursionContext(_localctx, _startState, RULE_expr); +						setState(251); +						if (!(precpred(_ctx, 11))) throw new FailedPredicateException(this, "precpred(_ctx, 11)"); +						setState(252); +						_la = _input.LA(1); +						if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & 1153906668099076096L) != 0)) ) { +						_errHandler.recoverInline(this); +						} +						else { +							if ( _input.LA(1)==Token.EOF ) matchedEOF = true; +							_errHandler.reportMatch(this); +							consume(); +						} +						setState(253); +						expr(12); +						} +						break; +					case 3: +						{ +						_localctx = new ExprContext(_parentctx, _parentState); +						pushNewRecursionContext(_localctx, _startState, RULE_expr); +						setState(254); +						if (!(precpred(_ctx, 10))) throw new FailedPredicateException(this, "precpred(_ctx, 10)"); +						setState(255); +						_la = _input.LA(1); +						if ( !(_la==ADD || _la==MINUS) ) { +						_errHandler.recoverInline(this); +						} +						else { +							if ( _input.LA(1)==Token.EOF ) matchedEOF = true; +							_errHandler.reportMatch(this); +							consume(); +						} +						setState(256); +						expr(11); +						} +						break; +					case 4: +						{ +						_localctx = new ExprContext(_parentctx, _parentState); +						pushNewRecursionContext(_localctx, _startState, RULE_expr); +						setState(257); +						if (!(precpred(_ctx, 9))) throw new FailedPredicateException(this, "precpred(_ctx, 9)"); +						setState(258); +						_la = _input.LA(1); +						if ( !(_la==LEFT_SHIFT || _la==RIGHT_SHIFT) ) { +						_errHandler.recoverInline(this); +						} +						else { +							if ( _input.LA(1)==Token.EOF ) matchedEOF = true; +							_errHandler.reportMatch(this); +							consume(); +						} +						setState(259); +						expr(10); +						} +						break; +					case 5: +						{ +						_localctx = new ExprContext(_parentctx, _parentState); +						pushNewRecursionContext(_localctx, _startState, RULE_expr); +						setState(260); +						if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); +						setState(261); +						match(AND_OP); +						setState(262); +						expr(9); +						} +						break; +					case 6: +						{ +						_localctx = new ExprContext(_parentctx, _parentState); +						pushNewRecursionContext(_localctx, _startState, RULE_expr); +						setState(263); +						if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); +						setState(264); +						match(XOR); +						setState(265); +						expr(8); +						} +						break; +					case 7: +						{ +						_localctx = new ExprContext(_parentctx, _parentState); +						pushNewRecursionContext(_localctx, _startState, RULE_expr); +						setState(266); +						if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); +						setState(267); +						match(OR_OP); +						setState(268); +						expr(7); +						} +						break; +					case 8: +						{ +						_localctx = new ExprContext(_parentctx, _parentState); +						pushNewRecursionContext(_localctx, _startState, RULE_expr); +						setState(269); +						if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)"); +						setState(270); +						comp_op(); +						setState(271); +						expr(5); +						} +						break; +					case 9: +						{ +						_localctx = new ExprContext(_parentctx, _parentState); +						pushNewRecursionContext(_localctx, _startState, RULE_expr); +						setState(273); +						if (!(precpred(_ctx, 3))) throw new FailedPredicateException(this, "precpred(_ctx, 3)"); +						setState(274); +						match(AND); +						setState(275); +						expr(4); +						} +						break; +					case 10: +						{ +						_localctx = new ExprContext(_parentctx, _parentState); +						pushNewRecursionContext(_localctx, _startState, RULE_expr); +						setState(276); +						if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); +						setState(277); +						match(OR); +						setState(278); +						expr(3); +						} +						break; +					case 11: +						{ +						_localctx = new ExprContext(_parentctx, _parentState); +						pushNewRecursionContext(_localctx, _startState, RULE_expr); +						setState(279); +						if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)"); +						setState(280); +						match(IF); +						setState(281); +						expr(0); +						setState(282); +						match(ELSE); +						setState(283); +						expr(2); +						} +						break; +					} +					}  +				} +				setState(289); +				_errHandler.sync(this); +				_alt = getInterpreter().adaptivePredict(_input,30,_ctx); +			} +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			unrollRecursionContexts(_parentctx); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class AtomContext extends ParserRuleContext { +		public TerminalNode OPEN_PAREN() { return getToken(Python3Parser.OPEN_PAREN, 0); } +		public TerminalNode CLOSE_PAREN() { return getToken(Python3Parser.CLOSE_PAREN, 0); } +		public Testlist_compContext testlist_comp() { +			return getRuleContext(Testlist_compContext.class,0); +		} +		public TerminalNode OPEN_BRACK() { return getToken(Python3Parser.OPEN_BRACK, 0); } +		public TerminalNode CLOSE_BRACK() { return getToken(Python3Parser.CLOSE_BRACK, 0); } +		public TerminalNode OPEN_BRACE() { return getToken(Python3Parser.OPEN_BRACE, 0); } +		public TerminalNode CLOSE_BRACE() { return getToken(Python3Parser.CLOSE_BRACE, 0); } +		public TerminalNode NAME() { return getToken(Python3Parser.NAME, 0); } +		public TerminalNode NUMBER() { return getToken(Python3Parser.NUMBER, 0); } +		public List<TerminalNode> STRING() { return getTokens(Python3Parser.STRING); } +		public TerminalNode STRING(int i) { +			return getToken(Python3Parser.STRING, i); +		} +		public TerminalNode ELLIPSIS() { return getToken(Python3Parser.ELLIPSIS, 0); } +		public TerminalNode NONE() { return getToken(Python3Parser.NONE, 0); } +		public TerminalNode TRUE() { return getToken(Python3Parser.TRUE, 0); } +		public TerminalNode FALSE() { return getToken(Python3Parser.FALSE, 0); } +		public AtomContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_atom; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterAtom(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitAtom(this); +		} +	} + +	public final AtomContext atom() throws RecognitionException { +		AtomContext _localctx = new AtomContext(_ctx, getState()); +		enterRule(_localctx, 36, RULE_atom); +		int _la; +		try { +			int _alt; +			setState(316); +			_errHandler.sync(this); +			switch (_input.LA(1)) { +			case OPEN_PAREN: +				enterOuterAlt(_localctx, 1); +				{ +				setState(290); +				match(OPEN_PAREN); +				setState(292); +				_errHandler.sync(this); +				_la = _input.LA(1); +				if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3483530435101720L) != 0)) { +					{ +					setState(291); +					testlist_comp(); +					} +				} + +				setState(294); +				match(CLOSE_PAREN); +				} +				break; +			case OPEN_BRACK: +				enterOuterAlt(_localctx, 2); +				{ +				setState(295); +				match(OPEN_BRACK); +				setState(297); +				_errHandler.sync(this); +				_la = _input.LA(1); +				if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3483530435101720L) != 0)) { +					{ +					setState(296); +					testlist_comp(); +					} +				} + +				setState(299); +				match(CLOSE_BRACK); +				} +				break; +			case OPEN_BRACE: +				enterOuterAlt(_localctx, 3); +				{ +				setState(300); +				match(OPEN_BRACE); +				setState(302); +				_errHandler.sync(this); +				_la = _input.LA(1); +				if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3483530435101720L) != 0)) { +					{ +					setState(301); +					testlist_comp(); +					} +				} + +				setState(304); +				match(CLOSE_BRACE); +				} +				break; +			case NAME: +				enterOuterAlt(_localctx, 4); +				{ +				setState(305); +				match(NAME); +				} +				break; +			case NUMBER: +				enterOuterAlt(_localctx, 5); +				{ +				setState(306); +				match(NUMBER); +				} +				break; +			case STRING: +				enterOuterAlt(_localctx, 6); +				{ +				setState(308);  +				_errHandler.sync(this); +				_alt = 1; +				do { +					switch (_alt) { +					case 1: +						{ +						{ +						setState(307); +						match(STRING); +						} +						} +						break; +					default: +						throw new NoViableAltException(this); +					} +					setState(310);  +					_errHandler.sync(this); +					_alt = getInterpreter().adaptivePredict(_input,34,_ctx); +				} while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ); +				} +				break; +			case ELLIPSIS: +				enterOuterAlt(_localctx, 7); +				{ +				setState(312); +				match(ELLIPSIS); +				} +				break; +			case NONE: +				enterOuterAlt(_localctx, 8); +				{ +				setState(313); +				match(NONE); +				} +				break; +			case TRUE: +				enterOuterAlt(_localctx, 9); +				{ +				setState(314); +				match(TRUE); +				} +				break; +			case FALSE: +				enterOuterAlt(_localctx, 10); +				{ +				setState(315); +				match(FALSE); +				} +				break; +			default: +				throw new NoViableAltException(this); +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class Testlist_compContext extends ParserRuleContext { +		public List<ExprContext> expr() { +			return getRuleContexts(ExprContext.class); +		} +		public ExprContext expr(int i) { +			return getRuleContext(ExprContext.class,i); +		} +		public Comp_forContext comp_for() { +			return getRuleContext(Comp_forContext.class,0); +		} +		public List<TerminalNode> COMMA() { return getTokens(Python3Parser.COMMA); } +		public TerminalNode COMMA(int i) { +			return getToken(Python3Parser.COMMA, i); +		} +		public Testlist_compContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_testlist_comp; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterTestlist_comp(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitTestlist_comp(this); +		} +	} + +	public final Testlist_compContext testlist_comp() throws RecognitionException { +		Testlist_compContext _localctx = new Testlist_compContext(_ctx, getState()); +		enterRule(_localctx, 38, RULE_testlist_comp); +		int _la; +		try { +			int _alt; +			enterOuterAlt(_localctx, 1); +			{ +			setState(318); +			expr(0); +			setState(330); +			_errHandler.sync(this); +			switch (_input.LA(1)) { +			case FOR: +				{ +				setState(319); +				comp_for(); +				} +				break; +			case CLOSE_PAREN: +			case COMMA: +			case CLOSE_BRACK: +			case CLOSE_BRACE: +				{ +				setState(324); +				_errHandler.sync(this); +				_alt = getInterpreter().adaptivePredict(_input,36,_ctx); +				while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { +					if ( _alt==1 ) { +						{ +						{ +						setState(320); +						match(COMMA); +						setState(321); +						expr(0); +						} +						}  +					} +					setState(326); +					_errHandler.sync(this); +					_alt = getInterpreter().adaptivePredict(_input,36,_ctx); +				} +				setState(328); +				_errHandler.sync(this); +				_la = _input.LA(1); +				if (_la==COMMA) { +					{ +					setState(327); +					match(COMMA); +					} +				} + +				} +				break; +			default: +				throw new NoViableAltException(this); +			} +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class TrailerContext extends ParserRuleContext { +		public TerminalNode OPEN_PAREN() { return getToken(Python3Parser.OPEN_PAREN, 0); } +		public TerminalNode CLOSE_PAREN() { return getToken(Python3Parser.CLOSE_PAREN, 0); } +		public ArglistContext arglist() { +			return getRuleContext(ArglistContext.class,0); +		} +		public TerminalNode OPEN_BRACK() { return getToken(Python3Parser.OPEN_BRACK, 0); } +		public List<ExprContext> expr() { +			return getRuleContexts(ExprContext.class); +		} +		public ExprContext expr(int i) { +			return getRuleContext(ExprContext.class,i); +		} +		public TerminalNode CLOSE_BRACK() { return getToken(Python3Parser.CLOSE_BRACK, 0); } +		public List<TerminalNode> COMMA() { return getTokens(Python3Parser.COMMA); } +		public TerminalNode COMMA(int i) { +			return getToken(Python3Parser.COMMA, i); +		} +		public TerminalNode DOT() { return getToken(Python3Parser.DOT, 0); } +		public TerminalNode NAME() { return getToken(Python3Parser.NAME, 0); } +		public List<TerminalNode> COLON() { return getTokens(Python3Parser.COLON); } +		public TerminalNode COLON(int i) { +			return getToken(Python3Parser.COLON, i); +		} +		public TrailerContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_trailer; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterTrailer(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitTrailer(this); +		} +	} + +	public final TrailerContext trailer() throws RecognitionException { +		TrailerContext _localctx = new TrailerContext(_ctx, getState()); +		enterRule(_localctx, 40, RULE_trailer); +		int _la; +		try { +			int _alt; +			setState(368); +			_errHandler.sync(this); +			switch ( getInterpreter().adaptivePredict(_input,46,_ctx) ) { +			case 1: +				enterOuterAlt(_localctx, 1); +				{ +				setState(332); +				match(OPEN_PAREN); +				setState(334); +				_errHandler.sync(this); +				_la = _input.LA(1); +				if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3483530435101720L) != 0)) { +					{ +					setState(333); +					arglist(); +					} +				} + +				setState(336); +				match(CLOSE_PAREN); +				} +				break; +			case 2: +				enterOuterAlt(_localctx, 2); +				{ +				setState(337); +				match(OPEN_BRACK); +				setState(338); +				expr(0); +				setState(343); +				_errHandler.sync(this); +				_alt = getInterpreter().adaptivePredict(_input,40,_ctx); +				while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { +					if ( _alt==1 ) { +						{ +						{ +						setState(339); +						match(COMMA); +						setState(340); +						expr(0); +						} +						}  +					} +					setState(345); +					_errHandler.sync(this); +					_alt = getInterpreter().adaptivePredict(_input,40,_ctx); +				} +				setState(347); +				_errHandler.sync(this); +				_la = _input.LA(1); +				if (_la==COMMA) { +					{ +					setState(346); +					match(COMMA); +					} +				} + +				setState(349); +				match(CLOSE_BRACK); +				} +				break; +			case 3: +				enterOuterAlt(_localctx, 3); +				{ +				setState(351); +				match(DOT); +				setState(352); +				match(NAME); +				} +				break; +			case 4: +				enterOuterAlt(_localctx, 4); +				{ +				setState(353); +				match(OPEN_BRACK); +				setState(355); +				_errHandler.sync(this); +				_la = _input.LA(1); +				if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3483530435101720L) != 0)) { +					{ +					setState(354); +					expr(0); +					} +				} + +				setState(357); +				match(COLON); +				setState(359); +				_errHandler.sync(this); +				_la = _input.LA(1); +				if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3483530435101720L) != 0)) { +					{ +					setState(358); +					expr(0); +					} +				} + +				setState(365); +				_errHandler.sync(this); +				_la = _input.LA(1); +				if (_la==COLON) { +					{ +					setState(361); +					match(COLON); +					setState(363); +					_errHandler.sync(this); +					_la = _input.LA(1); +					if ((((_la) & ~0x3f) == 0 && ((1L << _la) & 3483530435101720L) != 0)) { +						{ +						setState(362); +						expr(0); +						} +					} + +					} +				} + +				setState(367); +				match(CLOSE_BRACK); +				} +				break; +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class ExprlistContext extends ParserRuleContext { +		public List<ExprContext> expr() { +			return getRuleContexts(ExprContext.class); +		} +		public ExprContext expr(int i) { +			return getRuleContext(ExprContext.class,i); +		} +		public List<TerminalNode> COMMA() { return getTokens(Python3Parser.COMMA); } +		public TerminalNode COMMA(int i) { +			return getToken(Python3Parser.COMMA, i); +		} +		public ExprlistContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_exprlist; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterExprlist(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitExprlist(this); +		} +	} + +	public final ExprlistContext exprlist() throws RecognitionException { +		ExprlistContext _localctx = new ExprlistContext(_ctx, getState()); +		enterRule(_localctx, 42, RULE_exprlist); +		int _la; +		try { +			int _alt; +			enterOuterAlt(_localctx, 1); +			{ +			setState(370); +			expr(0); +			setState(375); +			_errHandler.sync(this); +			_alt = getInterpreter().adaptivePredict(_input,47,_ctx); +			while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { +				if ( _alt==1 ) { +					{ +					{ +					setState(371); +					match(COMMA); +					setState(372); +					expr(0); +					} +					}  +				} +				setState(377); +				_errHandler.sync(this); +				_alt = getInterpreter().adaptivePredict(_input,47,_ctx); +			} +			setState(379); +			_errHandler.sync(this); +			_la = _input.LA(1); +			if (_la==COMMA) { +				{ +				setState(378); +				match(COMMA); +				} +			} + +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class ArglistContext extends ParserRuleContext { +		public List<ArgumentContext> argument() { +			return getRuleContexts(ArgumentContext.class); +		} +		public ArgumentContext argument(int i) { +			return getRuleContext(ArgumentContext.class,i); +		} +		public List<TerminalNode> COMMA() { return getTokens(Python3Parser.COMMA); } +		public TerminalNode COMMA(int i) { +			return getToken(Python3Parser.COMMA, i); +		} +		public ArglistContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_arglist; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterArglist(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitArglist(this); +		} +	} + +	public final ArglistContext arglist() throws RecognitionException { +		ArglistContext _localctx = new ArglistContext(_ctx, getState()); +		enterRule(_localctx, 44, RULE_arglist); +		int _la; +		try { +			int _alt; +			enterOuterAlt(_localctx, 1); +			{ +			setState(381); +			argument(); +			setState(386); +			_errHandler.sync(this); +			_alt = getInterpreter().adaptivePredict(_input,49,_ctx); +			while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { +				if ( _alt==1 ) { +					{ +					{ +					setState(382); +					match(COMMA); +					setState(383); +					argument(); +					} +					}  +				} +				setState(388); +				_errHandler.sync(this); +				_alt = getInterpreter().adaptivePredict(_input,49,_ctx); +			} +			setState(390); +			_errHandler.sync(this); +			_la = _input.LA(1); +			if (_la==COMMA) { +				{ +				setState(389); +				match(COMMA); +				} +			} + +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class ArgumentContext extends ParserRuleContext { +		public List<ExprContext> expr() { +			return getRuleContexts(ExprContext.class); +		} +		public ExprContext expr(int i) { +			return getRuleContext(ExprContext.class,i); +		} +		public Comp_forContext comp_for() { +			return getRuleContext(Comp_forContext.class,0); +		} +		public TerminalNode ASSIGN() { return getToken(Python3Parser.ASSIGN, 0); } +		public ArgumentContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_argument; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterArgument(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitArgument(this); +		} +	} + +	public final ArgumentContext argument() throws RecognitionException { +		ArgumentContext _localctx = new ArgumentContext(_ctx, getState()); +		enterRule(_localctx, 46, RULE_argument); +		int _la; +		try { +			setState(400); +			_errHandler.sync(this); +			switch ( getInterpreter().adaptivePredict(_input,52,_ctx) ) { +			case 1: +				enterOuterAlt(_localctx, 1); +				{ +				setState(392); +				expr(0); +				setState(394); +				_errHandler.sync(this); +				_la = _input.LA(1); +				if (_la==FOR) { +					{ +					setState(393); +					comp_for(); +					} +				} + +				} +				break; +			case 2: +				enterOuterAlt(_localctx, 2); +				{ +				setState(396); +				expr(0); +				setState(397); +				match(ASSIGN); +				setState(398); +				expr(0); +				} +				break; +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class Comp_iterContext extends ParserRuleContext { +		public Comp_forContext comp_for() { +			return getRuleContext(Comp_forContext.class,0); +		} +		public Comp_ifContext comp_if() { +			return getRuleContext(Comp_ifContext.class,0); +		} +		public Comp_iterContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_comp_iter; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterComp_iter(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitComp_iter(this); +		} +	} + +	public final Comp_iterContext comp_iter() throws RecognitionException { +		Comp_iterContext _localctx = new Comp_iterContext(_ctx, getState()); +		enterRule(_localctx, 48, RULE_comp_iter); +		try { +			setState(404); +			_errHandler.sync(this); +			switch (_input.LA(1)) { +			case FOR: +				enterOuterAlt(_localctx, 1); +				{ +				setState(402); +				comp_for(); +				} +				break; +			case IF: +				enterOuterAlt(_localctx, 2); +				{ +				setState(403); +				comp_if(); +				} +				break; +			default: +				throw new NoViableAltException(this); +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class Comp_forContext extends ParserRuleContext { +		public TerminalNode FOR() { return getToken(Python3Parser.FOR, 0); } +		public ExprlistContext exprlist() { +			return getRuleContext(ExprlistContext.class,0); +		} +		public TerminalNode IN() { return getToken(Python3Parser.IN, 0); } +		public ExprContext expr() { +			return getRuleContext(ExprContext.class,0); +		} +		public Comp_iterContext comp_iter() { +			return getRuleContext(Comp_iterContext.class,0); +		} +		public Comp_forContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_comp_for; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterComp_for(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitComp_for(this); +		} +	} + +	public final Comp_forContext comp_for() throws RecognitionException { +		Comp_forContext _localctx = new Comp_forContext(_ctx, getState()); +		enterRule(_localctx, 50, RULE_comp_for); +		int _la; +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(406); +			match(FOR); +			setState(407); +			exprlist(); +			setState(408); +			match(IN); +			setState(409); +			expr(0); +			setState(411); +			_errHandler.sync(this); +			_la = _input.LA(1); +			if (_la==FOR || _la==IF) { +				{ +				setState(410); +				comp_iter(); +				} +			} + +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	@SuppressWarnings("CheckReturnValue") +	public static class Comp_ifContext extends ParserRuleContext { +		public TerminalNode IF() { return getToken(Python3Parser.IF, 0); } +		public ExprContext expr() { +			return getRuleContext(ExprContext.class,0); +		} +		public Comp_iterContext comp_iter() { +			return getRuleContext(Comp_iterContext.class,0); +		} +		public Comp_ifContext(ParserRuleContext parent, int invokingState) { +			super(parent, invokingState); +		} +		@Override public int getRuleIndex() { return RULE_comp_if; } +		@Override +		public void enterRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).enterComp_if(this); +		} +		@Override +		public void exitRule(ParseTreeListener listener) { +			if ( listener instanceof Python3ParserListener ) ((Python3ParserListener)listener).exitComp_if(this); +		} +	} + +	public final Comp_ifContext comp_if() throws RecognitionException { +		Comp_ifContext _localctx = new Comp_ifContext(_ctx, getState()); +		enterRule(_localctx, 52, RULE_comp_if); +		int _la; +		try { +			enterOuterAlt(_localctx, 1); +			{ +			setState(413); +			match(IF); +			setState(414); +			expr(0); +			setState(416); +			_errHandler.sync(this); +			_la = _input.LA(1); +			if (_la==FOR || _la==IF) { +				{ +				setState(415); +				comp_iter(); +				} +			} + +			} +		} +		catch (RecognitionException re) { +			_localctx.exception = re; +			_errHandler.reportError(this, re); +			_errHandler.recover(this, re); +		} +		finally { +			exitRule(); +		} +		return _localctx; +	} + +	public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { +		switch (ruleIndex) { +		case 17: +			return expr_sempred((ExprContext)_localctx, predIndex); +		} +		return true; +	} +	private boolean expr_sempred(ExprContext _localctx, int predIndex) { +		switch (predIndex) { +		case 0: +			return precpred(_ctx, 13); +		case 1: +			return precpred(_ctx, 11); +		case 2: +			return precpred(_ctx, 10); +		case 3: +			return precpred(_ctx, 9); +		case 4: +			return precpred(_ctx, 8); +		case 5: +			return precpred(_ctx, 7); +		case 6: +			return precpred(_ctx, 6); +		case 7: +			return precpred(_ctx, 4); +		case 8: +			return precpred(_ctx, 3); +		case 9: +			return precpred(_ctx, 2); +		case 10: +			return precpred(_ctx, 1); +		} +		return true; +	} + +	public static final String _serializedATN = +		"\u0004\u0001L\u01a3\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ +		"\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+ +		"\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007\u0002"+ +		"\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b\u0007\u000b\u0002"+ +		"\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e\u0002\u000f\u0007\u000f"+ +		"\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011\u0002\u0012\u0007\u0012"+ +		"\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014\u0002\u0015\u0007\u0015"+ +		"\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017\u0002\u0018\u0007\u0018"+ +		"\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a\u0001\u0000\u0005\u0000"+ +		"8\b\u0000\n\u0000\f\u0000;\t\u0000\u0001\u0000\u0001\u0000\u0005\u0000"+ +		"?\b\u0000\n\u0000\f\u0000B\t\u0000\u0001\u0000\u0001\u0000\u0001\u0001"+ +		"\u0001\u0001\u0001\u0001\u0005\u0001I\b\u0001\n\u0001\f\u0001L\t\u0001"+ +		"\u0001\u0001\u0003\u0001O\b\u0001\u0001\u0001\u0001\u0001\u0001\u0002"+ +		"\u0001\u0002\u0001\u0002\u0001\u0002\u0003\u0002W\b\u0002\u0001\u0003"+ +		"\u0001\u0003\u0001\u0003\u0001\u0003\u0003\u0003]\b\u0003\u0001\u0004"+ +		"\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0003\u0005"+ +		"e\b\u0005\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0003\u0006"+ +		"k\b\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+ +		"\u0001\u0006\u0005\u0006s\b\u0006\n\u0006\f\u0006v\t\u0006\u0001\u0006"+ +		"\u0003\u0006y\b\u0006\u0003\u0006{\b\u0006\u0001\u0007\u0001\u0007\u0001"+ +		"\u0007\u0005\u0007\u0080\b\u0007\n\u0007\f\u0007\u0083\t\u0007\u0001\b"+ +		"\u0001\b\u0001\b\u0001\b\u0003\b\u0089\b\b\u0001\b\u0001\b\u0001\b\u0001"+ +		"\b\u0001\t\u0001\t\u0001\t\u0003\t\u0092\b\t\u0001\t\u0001\t\u0001\t\u0001"+ +		"\t\u0003\t\u0098\b\t\u0005\t\u009a\b\t\n\t\f\t\u009d\t\t\u0001\n\u0001"+ +		"\n\u0001\n\u0003\n\u00a2\b\n\u0001\u000b\u0001\u000b\u0001\f\u0001\f\u0001"+ +		"\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\f\u0005\f\u00af\b\f\n"+ +		"\f\f\f\u00b2\t\f\u0001\f\u0001\f\u0001\f\u0003\f\u00b7\b\f\u0001\r\u0001"+ +		"\r\u0001\r\u0001\r\u0001\r\u0001\r\u0001\r\u0003\r\u00c0\b\r\u0001\u000e"+ +		"\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e\u0001\u000e"+ +		"\u0003\u000e\u00c9\b\u000e\u0001\u000f\u0001\u000f\u0001\u000f\u0001\u000f"+ +		"\u0001\u000f\u0004\u000f\u00d0\b\u000f\u000b\u000f\f\u000f\u00d1\u0001"+ +		"\u000f\u0001\u000f\u0003\u000f\u00d6\b\u000f\u0001\u0010\u0001\u0010\u0001"+ +		"\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001"+ +		"\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0001\u0010\u0003\u0010\u00e5"+ +		"\b\u0010\u0001\u0011\u0001\u0011\u0001\u0011\u0005\u0011\u00ea\b\u0011"+ +		"\n\u0011\f\u0011\u00ed\t\u0011\u0001\u0011\u0004\u0011\u00f0\b\u0011\u000b"+ +		"\u0011\f\u0011\u00f1\u0001\u0011\u0001\u0011\u0001\u0011\u0003\u0011\u00f7"+ +		"\b\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001"+ +		"\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001"+ +		"\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001"+ +		"\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001"+ +		"\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001"+ +		"\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001\u0011\u0001"+ +		"\u0011\u0001\u0011\u0005\u0011\u011e\b\u0011\n\u0011\f\u0011\u0121\t\u0011"+ +		"\u0001\u0012\u0001\u0012\u0003\u0012\u0125\b\u0012\u0001\u0012\u0001\u0012"+ +		"\u0001\u0012\u0003\u0012\u012a\b\u0012\u0001\u0012\u0001\u0012\u0001\u0012"+ +		"\u0003\u0012\u012f\b\u0012\u0001\u0012\u0001\u0012\u0001\u0012\u0001\u0012"+ +		"\u0004\u0012\u0135\b\u0012\u000b\u0012\f\u0012\u0136\u0001\u0012\u0001"+ +		"\u0012\u0001\u0012\u0001\u0012\u0003\u0012\u013d\b\u0012\u0001\u0013\u0001"+ +		"\u0013\u0001\u0013\u0001\u0013\u0005\u0013\u0143\b\u0013\n\u0013\f\u0013"+ +		"\u0146\t\u0013\u0001\u0013\u0003\u0013\u0149\b\u0013\u0003\u0013\u014b"+ +		"\b\u0013\u0001\u0014\u0001\u0014\u0003\u0014\u014f\b\u0014\u0001\u0014"+ +		"\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0005\u0014\u0156\b\u0014"+ +		"\n\u0014\f\u0014\u0159\t\u0014\u0001\u0014\u0003\u0014\u015c\b\u0014\u0001"+ +		"\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0014\u0003"+ +		"\u0014\u0164\b\u0014\u0001\u0014\u0001\u0014\u0003\u0014\u0168\b\u0014"+ +		"\u0001\u0014\u0001\u0014\u0003\u0014\u016c\b\u0014\u0003\u0014\u016e\b"+ +		"\u0014\u0001\u0014\u0003\u0014\u0171\b\u0014\u0001\u0015\u0001\u0015\u0001"+ +		"\u0015\u0005\u0015\u0176\b\u0015\n\u0015\f\u0015\u0179\t\u0015\u0001\u0015"+ +		"\u0003\u0015\u017c\b\u0015\u0001\u0016\u0001\u0016\u0001\u0016\u0005\u0016"+ +		"\u0181\b\u0016\n\u0016\f\u0016\u0184\t\u0016\u0001\u0016\u0003\u0016\u0187"+ +		"\b\u0016\u0001\u0017\u0001\u0017\u0003\u0017\u018b\b\u0017\u0001\u0017"+ +		"\u0001\u0017\u0001\u0017\u0001\u0017\u0003\u0017\u0191\b\u0017\u0001\u0018"+ +		"\u0001\u0018\u0003\u0018\u0195\b\u0018\u0001\u0019\u0001\u0019\u0001\u0019"+ +		"\u0001\u0019\u0001\u0019\u0003\u0019\u019c\b\u0019\u0001\u001a\u0001\u001a"+ +		"\u0001\u001a\u0003\u001a\u01a1\b\u001a\u0001\u001a\u0000\u0001\"\u001b"+ +		"\u0000\u0002\u0004\u0006\b\n\f\u000e\u0010\u0012\u0014\u0016\u0018\u001a"+ +		"\u001c\u001e \"$&(*,.024\u0000\u0005\u0002\u0000%%>J\u0002\u0000-.22\u0003"+ +		"\u0000\u001e\u001e/1<<\u0001\u0000-.\u0001\u0000+,\u01e0\u00009\u0001"+ +		"\u0000\u0000\u0000\u0002E\u0001\u0000\u0000\u0000\u0004V\u0001\u0000\u0000"+ +		"\u0000\u0006\\\u0001\u0000\u0000\u0000\b^\u0001\u0000\u0000\u0000\nb\u0001"+ +		"\u0000\u0000\u0000\fz\u0001\u0000\u0000\u0000\u000e|\u0001\u0000\u0000"+ +		"\u0000\u0010\u0084\u0001\u0000\u0000\u0000\u0012\u008e\u0001\u0000\u0000"+ +		"\u0000\u0014\u009e\u0001\u0000\u0000\u0000\u0016\u00a3\u0001\u0000\u0000"+ +		"\u0000\u0018\u00a5\u0001\u0000\u0000\u0000\u001a\u00b8\u0001\u0000\u0000"+ +		"\u0000\u001c\u00c1\u0001\u0000\u0000\u0000\u001e\u00d5\u0001\u0000\u0000"+ +		"\u0000 \u00e4\u0001\u0000\u0000\u0000\"\u00f6\u0001\u0000\u0000\u0000"+ +		"$\u013c\u0001\u0000\u0000\u0000&\u013e\u0001\u0000\u0000\u0000(\u0170"+ +		"\u0001\u0000\u0000\u0000*\u0172\u0001\u0000\u0000\u0000,\u017d\u0001\u0000"+ +		"\u0000\u0000.\u0190\u0001\u0000\u0000\u00000\u0194\u0001\u0000\u0000\u0000"+ +		"2\u0196\u0001\u0000\u0000\u00004\u019d\u0001\u0000\u0000\u000068\u0005"+ +		"\u0018\u0000\u000076\u0001\u0000\u0000\u00008;\u0001\u0000\u0000\u0000"+ +		"97\u0001\u0000\u0000\u00009:\u0001\u0000\u0000\u0000:@\u0001\u0000\u0000"+ +		"\u0000;9\u0001\u0000\u0000\u0000<?\u0003\u0002\u0001\u0000=?\u0003\u0004"+ +		"\u0002\u0000><\u0001\u0000\u0000\u0000>=\u0001\u0000\u0000\u0000?B\u0001"+ +		"\u0000\u0000\u0000@>\u0001\u0000\u0000\u0000@A\u0001\u0000\u0000\u0000"+ +		"AC\u0001\u0000\u0000\u0000B@\u0001\u0000\u0000\u0000CD\u0005\u0000\u0000"+ +		"\u0001D\u0001\u0001\u0000\u0000\u0000EJ\u0003\u0006\u0003\u0000FG\u0005"+ +		"#\u0000\u0000GI\u0003\u0006\u0003\u0000HF\u0001\u0000\u0000\u0000IL\u0001"+ +		"\u0000\u0000\u0000JH\u0001\u0000\u0000\u0000JK\u0001\u0000\u0000\u0000"+ +		"KN\u0001\u0000\u0000\u0000LJ\u0001\u0000\u0000\u0000MO\u0005#\u0000\u0000"+ +		"NM\u0001\u0000\u0000\u0000NO\u0001\u0000\u0000\u0000OP\u0001\u0000\u0000"+ +		"\u0000PQ\u0005\u0018\u0000\u0000Q\u0003\u0001\u0000\u0000\u0000RW\u0003"+ +		"\u0018\f\u0000SW\u0003\u001a\r\u0000TW\u0003\u001c\u000e\u0000UW\u0003"+ +		"\u0010\b\u0000VR\u0001\u0000\u0000\u0000VS\u0001\u0000\u0000\u0000VT\u0001"+ +		"\u0000\u0000\u0000VU\u0001\u0000\u0000\u0000W\u0005\u0001\u0000\u0000"+ +		"\u0000X]\u0003\b\u0004\u0000Y]\u0003\"\u0011\u0000Z]\u0003\n\u0005\u0000"+ +		"[]\u0003\f\u0006\u0000\\X\u0001\u0000\u0000\u0000\\Y\u0001\u0000\u0000"+ +		"\u0000\\Z\u0001\u0000\u0000\u0000\\[\u0001\u0000\u0000\u0000]\u0007\u0001"+ +		"\u0000\u0000\u0000^_\u0003*\u0015\u0000_`\u0003\u0016\u000b\u0000`a\u0003"+ +		"*\u0015\u0000a\t\u0001\u0000\u0000\u0000bd\u0005\u0014\u0000\u0000ce\u0003"+ +		"*\u0015\u0000dc\u0001\u0000\u0000\u0000de\u0001\u0000\u0000\u0000e\u000b"+ +		"\u0001\u0000\u0000\u0000fg\u0005\u000e\u0000\u0000gj\u0003\u000e\u0007"+ +		"\u0000hi\u0005\u0006\u0000\u0000ik\u0005\u0019\u0000\u0000jh\u0001\u0000"+ +		"\u0000\u0000jk\u0001\u0000\u0000\u0000k{\u0001\u0000\u0000\u0000lm\u0005"+ +		"\f\u0000\u0000mn\u0003\u000e\u0007\u0000nx\u0005\u000e\u0000\u0000ot\u0005"+ +		"\u0019\u0000\u0000pq\u0005!\u0000\u0000qs\u0005\u0019\u0000\u0000rp\u0001"+ +		"\u0000\u0000\u0000sv\u0001\u0000\u0000\u0000tr\u0001\u0000\u0000\u0000"+ +		"tu\u0001\u0000\u0000\u0000uy\u0001\u0000\u0000\u0000vt\u0001\u0000\u0000"+ +		"\u0000wy\u0005\u001e\u0000\u0000xo\u0001\u0000\u0000\u0000xw\u0001\u0000"+ +		"\u0000\u0000y{\u0001\u0000\u0000\u0000zf\u0001\u0000\u0000\u0000zl\u0001"+ +		"\u0000\u0000\u0000{\r\u0001\u0000\u0000\u0000|\u0081\u0005\u0019\u0000"+ +		"\u0000}~\u0005\u001c\u0000\u0000~\u0080\u0005\u0019\u0000\u0000\u007f"+ +		"}\u0001\u0000\u0000\u0000\u0080\u0083\u0001\u0000\u0000\u0000\u0081\u007f"+ +		"\u0001\u0000\u0000\u0000\u0081\u0082\u0001\u0000\u0000\u0000\u0082\u000f"+ +		"\u0001\u0000\u0000\u0000\u0083\u0081\u0001\u0000\u0000\u0000\u0084\u0085"+ +		"\u0005\u0007\u0000\u0000\u0085\u0086\u0005\u0019\u0000\u0000\u0086\u0088"+ +		"\u0005\u001f\u0000\u0000\u0087\u0089\u0003\u0012\t\u0000\u0088\u0087\u0001"+ +		"\u0000\u0000\u0000\u0088\u0089\u0001\u0000\u0000\u0000\u0089\u008a\u0001"+ +		"\u0000\u0000\u0000\u008a\u008b\u0005 \u0000\u0000\u008b\u008c\u0005\""+ +		"\u0000\u0000\u008c\u008d\u0003\u001e\u000f\u0000\u008d\u0011\u0001\u0000"+ +		"\u0000\u0000\u008e\u0091\u0003\u0014\n\u0000\u008f\u0090\u0005%\u0000"+ +		"\u0000\u0090\u0092\u0003\"\u0011\u0000\u0091\u008f\u0001\u0000\u0000\u0000"+ +		"\u0091\u0092\u0001\u0000\u0000\u0000\u0092\u009b\u0001\u0000\u0000\u0000"+ +		"\u0093\u0094\u0005!\u0000\u0000\u0094\u0097\u0003\u0014\n\u0000\u0095"+ +		"\u0096\u0005%\u0000\u0000\u0096\u0098\u0003\"\u0011\u0000\u0097\u0095"+ +		"\u0001\u0000\u0000\u0000\u0097\u0098\u0001\u0000\u0000\u0000\u0098\u009a"+ +		"\u0001\u0000\u0000\u0000\u0099\u0093\u0001\u0000\u0000\u0000\u009a\u009d"+ +		"\u0001\u0000\u0000\u0000\u009b\u0099\u0001\u0000\u0000\u0000\u009b\u009c"+ +		"\u0001\u0000\u0000\u0000\u009c\u0013\u0001\u0000\u0000\u0000\u009d\u009b"+ +		"\u0001\u0000\u0000\u0000\u009e\u00a1\u0005\u0019\u0000\u0000\u009f\u00a0"+ +		"\u0005\"\u0000\u0000\u00a0\u00a2\u0003\"\u0011\u0000\u00a1\u009f\u0001"+ +		"\u0000\u0000\u0000\u00a1\u00a2\u0001\u0000\u0000\u0000\u00a2\u0015\u0001"+ +		"\u0000\u0000\u0000\u00a3\u00a4\u0007\u0000\u0000\u0000\u00a4\u0017\u0001"+ +		"\u0000\u0000\u0000\u00a5\u00a6\u0005\r\u0000\u0000\u00a6\u00a7\u0003\""+ +		"\u0011\u0000\u00a7\u00a8\u0005\"\u0000\u0000\u00a8\u00b0\u0003\u001e\u000f"+ +		"\u0000\u00a9\u00aa\u0005\b\u0000\u0000\u00aa\u00ab\u0003\"\u0011\u0000"+ +		"\u00ab\u00ac\u0005\"\u0000\u0000\u00ac\u00ad\u0003\u001e\u000f\u0000\u00ad"+ +		"\u00af\u0001\u0000\u0000\u0000\u00ae\u00a9\u0001\u0000\u0000\u0000\u00af"+ +		"\u00b2\u0001\u0000\u0000\u0000\u00b0\u00ae\u0001\u0000\u0000\u0000\u00b0"+ +		"\u00b1\u0001\u0000\u0000\u0000\u00b1\u00b6\u0001\u0000\u0000\u0000\u00b2"+ +		"\u00b0\u0001\u0000\u0000\u0000\u00b3\u00b4\u0005\t\u0000\u0000\u00b4\u00b5"+ +		"\u0005\"\u0000\u0000\u00b5\u00b7\u0003\u001e\u000f\u0000\u00b6\u00b3\u0001"+ +		"\u0000\u0000\u0000\u00b6\u00b7\u0001\u0000\u0000\u0000\u00b7\u0019\u0001"+ +		"\u0000\u0000\u0000\u00b8\u00b9\u0005\u0017\u0000\u0000\u00b9\u00ba\u0003"+ +		"\"\u0011\u0000\u00ba\u00bb\u0005\"\u0000\u0000\u00bb\u00bf\u0003\u001e"+ +		"\u000f\u0000\u00bc\u00bd\u0005\t\u0000\u0000\u00bd\u00be\u0005\"\u0000"+ +		"\u0000\u00be\u00c0\u0003\u001e\u000f\u0000\u00bf\u00bc\u0001\u0000\u0000"+ +		"\u0000\u00bf\u00c0\u0001\u0000\u0000\u0000\u00c0\u001b\u0001\u0000\u0000"+ +		"\u0000\u00c1\u00c2\u0005\u000b\u0000\u0000\u00c2\u00c3\u0003*\u0015\u0000"+ +		"\u00c3\u00c4\u0005\"\u0000\u0000\u00c4\u00c8\u0003\u001e\u000f\u0000\u00c5"+ +		"\u00c6\u0005\t\u0000\u0000\u00c6\u00c7\u0005\"\u0000\u0000\u00c7\u00c9"+ +		"\u0003\u001e\u000f\u0000\u00c8\u00c5\u0001\u0000\u0000\u0000\u00c8\u00c9"+ +		"\u0001\u0000\u0000\u0000\u00c9\u001d\u0001\u0000\u0000\u0000\u00ca\u00d6"+ +		"\u0003\u0002\u0001\u0000\u00cb\u00cc\u0005\u0018\u0000\u0000\u00cc\u00cf"+ +		"\u0005\u0001\u0000\u0000\u00cd\u00d0\u0003\u0002\u0001\u0000\u00ce\u00d0"+ +		"\u0003\u0004\u0002\u0000\u00cf\u00cd\u0001\u0000\u0000\u0000\u00cf\u00ce"+ +		"\u0001\u0000\u0000\u0000\u00d0\u00d1\u0001\u0000\u0000\u0000\u00d1\u00cf"+ +		"\u0001\u0000\u0000\u0000\u00d1\u00d2\u0001\u0000\u0000\u0000\u00d2\u00d3"+ +		"\u0001\u0000\u0000\u0000\u00d3\u00d4\u0005\u0002\u0000\u0000\u00d4\u00d6"+ +		"\u0001\u0000\u0000\u0000\u00d5\u00ca\u0001\u0000\u0000\u0000\u00d5\u00cb"+ +		"\u0001\u0000\u0000\u0000\u00d6\u001f\u0001\u0000\u0000\u0000\u00d7\u00e5"+ +		"\u00055\u0000\u0000\u00d8\u00e5\u00056\u0000\u0000\u00d9\u00e5\u00057"+ +		"\u0000\u0000\u00da\u00e5\u00058\u0000\u0000\u00db\u00e5\u00059\u0000\u0000"+ +		"\u00dc\u00e5\u0005:\u0000\u0000\u00dd\u00e5\u0005;\u0000\u0000\u00de\u00e5"+ +		"\u0005\u000f\u0000\u0000\u00df\u00e0\u0005\u0012\u0000\u0000\u00e0\u00e5"+ +		"\u0005\u000f\u0000\u0000\u00e1\u00e5\u0005\u0010\u0000\u0000\u00e2\u00e3"+ +		"\u0005\u0010\u0000\u0000\u00e3\u00e5\u0005\u0012\u0000\u0000\u00e4\u00d7"+ +		"\u0001\u0000\u0000\u0000\u00e4\u00d8\u0001\u0000\u0000\u0000\u00e4\u00d9"+ +		"\u0001\u0000\u0000\u0000\u00e4\u00da\u0001\u0000\u0000\u0000\u00e4\u00db"+ +		"\u0001\u0000\u0000\u0000\u00e4\u00dc\u0001\u0000\u0000\u0000\u00e4\u00dd"+ +		"\u0001\u0000\u0000\u0000\u00e4\u00de\u0001\u0000\u0000\u0000\u00e4\u00df"+ +		"\u0001\u0000\u0000\u0000\u00e4\u00e1\u0001\u0000\u0000\u0000\u00e4\u00e2"+ +		"\u0001\u0000\u0000\u0000\u00e5!\u0001\u0000\u0000\u0000\u00e6\u00e7\u0006"+ +		"\u0011\uffff\uffff\u0000\u00e7\u00eb\u0003$\u0012\u0000\u00e8\u00ea\u0003"+ +		"(\u0014\u0000\u00e9\u00e8\u0001\u0000\u0000\u0000\u00ea\u00ed\u0001\u0000"+ +		"\u0000\u0000\u00eb\u00e9\u0001\u0000\u0000\u0000\u00eb\u00ec\u0001\u0000"+ +		"\u0000\u0000\u00ec\u00f7\u0001\u0000\u0000\u0000\u00ed\u00eb\u0001\u0000"+ +		"\u0000\u0000\u00ee\u00f0\u0007\u0001\u0000\u0000\u00ef\u00ee\u0001\u0000"+ +		"\u0000\u0000\u00f0\u00f1\u0001\u0000\u0000\u0000\u00f1\u00ef\u0001\u0000"+ +		"\u0000\u0000\u00f1\u00f2\u0001\u0000\u0000\u0000\u00f2\u00f3\u0001\u0000"+ +		"\u0000\u0000\u00f3\u00f7\u0003\"\u0011\f\u00f4\u00f5\u0005\u0012\u0000"+ +		"\u0000\u00f5\u00f7\u0003\"\u0011\u0005\u00f6\u00e6\u0001\u0000\u0000\u0000"+ +		"\u00f6\u00ef\u0001\u0000\u0000\u0000\u00f6\u00f4\u0001\u0000\u0000\u0000"+ +		"\u00f7\u011f\u0001\u0000\u0000\u0000\u00f8\u00f9\n\r\u0000\u0000\u00f9"+ +		"\u00fa\u0005$\u0000\u0000\u00fa\u011e\u0003\"\u0011\u000e\u00fb\u00fc"+ +		"\n\u000b\u0000\u0000\u00fc\u00fd\u0007\u0002\u0000\u0000\u00fd\u011e\u0003"+ +		"\"\u0011\f\u00fe\u00ff\n\n\u0000\u0000\u00ff\u0100\u0007\u0003\u0000\u0000"+ +		"\u0100\u011e\u0003\"\u0011\u000b\u0101\u0102\n\t\u0000\u0000\u0102\u0103"+ +		"\u0007\u0004\u0000\u0000\u0103\u011e\u0003\"\u0011\n\u0104\u0105\n\b\u0000"+ +		"\u0000\u0105\u0106\u0005*\u0000\u0000\u0106\u011e\u0003\"\u0011\t\u0107"+ +		"\u0108\n\u0007\u0000\u0000\u0108\u0109\u0005)\u0000\u0000\u0109\u011e"+ +		"\u0003\"\u0011\b\u010a\u010b\n\u0006\u0000\u0000\u010b\u010c\u0005(\u0000"+ +		"\u0000\u010c\u011e\u0003\"\u0011\u0007\u010d\u010e\n\u0004\u0000\u0000"+ +		"\u010e\u010f\u0003 \u0010\u0000\u010f\u0110\u0003\"\u0011\u0005\u0110"+ +		"\u011e\u0001\u0000\u0000\u0000\u0111\u0112\n\u0003\u0000\u0000\u0112\u0113"+ +		"\u0005\u0005\u0000\u0000\u0113\u011e\u0003\"\u0011\u0004\u0114\u0115\n"+ +		"\u0002\u0000\u0000\u0115\u0116\u0005\u0013\u0000\u0000\u0116\u011e\u0003"+ +		"\"\u0011\u0003\u0117\u0118\n\u0001\u0000\u0000\u0118\u0119\u0005\r\u0000"+ +		"\u0000\u0119\u011a\u0003\"\u0011\u0000\u011a\u011b\u0005\t\u0000\u0000"+ +		"\u011b\u011c\u0003\"\u0011\u0002\u011c\u011e\u0001\u0000\u0000\u0000\u011d"+ +		"\u00f8\u0001\u0000\u0000\u0000\u011d\u00fb\u0001\u0000\u0000\u0000\u011d"+ +		"\u00fe\u0001\u0000\u0000\u0000\u011d\u0101\u0001\u0000\u0000\u0000\u011d"+ +		"\u0104\u0001\u0000\u0000\u0000\u011d\u0107\u0001\u0000\u0000\u0000\u011d"+ +		"\u010a\u0001\u0000\u0000\u0000\u011d\u010d\u0001\u0000\u0000\u0000\u011d"+ +		"\u0111\u0001\u0000\u0000\u0000\u011d\u0114\u0001\u0000\u0000\u0000\u011d"+ +		"\u0117\u0001\u0000\u0000\u0000\u011e\u0121\u0001\u0000\u0000\u0000\u011f"+ +		"\u011d\u0001\u0000\u0000\u0000\u011f\u0120\u0001\u0000\u0000\u0000\u0120"+ +		"#\u0001\u0000\u0000\u0000\u0121\u011f\u0001\u0000\u0000\u0000\u0122\u0124"+ +		"\u0005\u001f\u0000\u0000\u0123\u0125\u0003&\u0013\u0000\u0124\u0123\u0001"+ +		"\u0000\u0000\u0000\u0124\u0125\u0001\u0000\u0000\u0000\u0125\u0126\u0001"+ +		"\u0000\u0000\u0000\u0126\u013d\u0005 \u0000\u0000\u0127\u0129\u0005&\u0000"+ +		"\u0000\u0128\u012a\u0003&\u0013\u0000\u0129\u0128\u0001\u0000\u0000\u0000"+ +		"\u0129\u012a\u0001\u0000\u0000\u0000\u012a\u012b\u0001\u0000\u0000\u0000"+ +		"\u012b\u013d\u0005\'\u0000\u0000\u012c\u012e\u00053\u0000\u0000\u012d"+ +		"\u012f\u0003&\u0013\u0000\u012e\u012d\u0001\u0000\u0000\u0000\u012e\u012f"+ +		"\u0001\u0000\u0000\u0000\u012f\u0130\u0001\u0000\u0000\u0000\u0130\u013d"+ +		"\u00054\u0000\u0000\u0131\u013d\u0005\u0019\u0000\u0000\u0132\u013d\u0005"+ +		"\u0004\u0000\u0000\u0133\u0135\u0005\u0003\u0000\u0000\u0134\u0133\u0001"+ +		"\u0000\u0000\u0000\u0135\u0136\u0001\u0000\u0000\u0000\u0136\u0134\u0001"+ +		"\u0000\u0000\u0000\u0136\u0137\u0001\u0000\u0000\u0000\u0137\u013d\u0001"+ +		"\u0000\u0000\u0000\u0138\u013d\u0005\u001d\u0000\u0000\u0139\u013d\u0005"+ +		"\u0011\u0000\u0000\u013a\u013d\u0005\u0015\u0000\u0000\u013b\u013d\u0005"+ +		"\n\u0000\u0000\u013c\u0122\u0001\u0000\u0000\u0000\u013c\u0127\u0001\u0000"+ +		"\u0000\u0000\u013c\u012c\u0001\u0000\u0000\u0000\u013c\u0131\u0001\u0000"+ +		"\u0000\u0000\u013c\u0132\u0001\u0000\u0000\u0000\u013c\u0134\u0001\u0000"+ +		"\u0000\u0000\u013c\u0138\u0001\u0000\u0000\u0000\u013c\u0139\u0001\u0000"+ +		"\u0000\u0000\u013c\u013a\u0001\u0000\u0000\u0000\u013c\u013b\u0001\u0000"+ +		"\u0000\u0000\u013d%\u0001\u0000\u0000\u0000\u013e\u014a\u0003\"\u0011"+ +		"\u0000\u013f\u014b\u00032\u0019\u0000\u0140\u0141\u0005!\u0000\u0000\u0141"+ +		"\u0143\u0003\"\u0011\u0000\u0142\u0140\u0001\u0000\u0000\u0000\u0143\u0146"+ +		"\u0001\u0000\u0000\u0000\u0144\u0142\u0001\u0000\u0000\u0000\u0144\u0145"+ +		"\u0001\u0000\u0000\u0000\u0145\u0148\u0001\u0000\u0000\u0000\u0146\u0144"+ +		"\u0001\u0000\u0000\u0000\u0147\u0149\u0005!\u0000\u0000\u0148\u0147\u0001"+ +		"\u0000\u0000\u0000\u0148\u0149\u0001\u0000\u0000\u0000\u0149\u014b\u0001"+ +		"\u0000\u0000\u0000\u014a\u013f\u0001\u0000\u0000\u0000\u014a\u0144\u0001"+ +		"\u0000\u0000\u0000\u014b\'\u0001\u0000\u0000\u0000\u014c\u014e\u0005\u001f"+ +		"\u0000\u0000\u014d\u014f\u0003,\u0016\u0000\u014e\u014d\u0001\u0000\u0000"+ +		"\u0000\u014e\u014f\u0001\u0000\u0000\u0000\u014f\u0150\u0001\u0000\u0000"+ +		"\u0000\u0150\u0171\u0005 \u0000\u0000\u0151\u0152\u0005&\u0000\u0000\u0152"+ +		"\u0157\u0003\"\u0011\u0000\u0153\u0154\u0005!\u0000\u0000\u0154\u0156"+ +		"\u0003\"\u0011\u0000\u0155\u0153\u0001\u0000\u0000\u0000\u0156\u0159\u0001"+ +		"\u0000\u0000\u0000\u0157\u0155\u0001\u0000\u0000\u0000\u0157\u0158\u0001"+ +		"\u0000\u0000\u0000\u0158\u015b\u0001\u0000\u0000\u0000\u0159\u0157\u0001"+ +		"\u0000\u0000\u0000\u015a\u015c\u0005!\u0000\u0000\u015b\u015a\u0001\u0000"+ +		"\u0000\u0000\u015b\u015c\u0001\u0000\u0000\u0000\u015c\u015d\u0001\u0000"+ +		"\u0000\u0000\u015d\u015e\u0005\'\u0000\u0000\u015e\u0171\u0001\u0000\u0000"+ +		"\u0000\u015f\u0160\u0005\u001c\u0000\u0000\u0160\u0171\u0005\u0019\u0000"+ +		"\u0000\u0161\u0163\u0005&\u0000\u0000\u0162\u0164\u0003\"\u0011\u0000"+ +		"\u0163\u0162\u0001\u0000\u0000\u0000\u0163\u0164\u0001\u0000\u0000\u0000"+ +		"\u0164\u0165\u0001\u0000\u0000\u0000\u0165\u0167\u0005\"\u0000\u0000\u0166"+ +		"\u0168\u0003\"\u0011\u0000\u0167\u0166\u0001\u0000\u0000\u0000\u0167\u0168"+ +		"\u0001\u0000\u0000\u0000\u0168\u016d\u0001\u0000\u0000\u0000\u0169\u016b"+ +		"\u0005\"\u0000\u0000\u016a\u016c\u0003\"\u0011\u0000\u016b\u016a\u0001"+ +		"\u0000\u0000\u0000\u016b\u016c\u0001\u0000\u0000\u0000\u016c\u016e\u0001"+ +		"\u0000\u0000\u0000\u016d\u0169\u0001\u0000\u0000\u0000\u016d\u016e\u0001"+ +		"\u0000\u0000\u0000\u016e\u016f\u0001\u0000\u0000\u0000\u016f\u0171\u0005"+ +		"\'\u0000\u0000\u0170\u014c\u0001\u0000\u0000\u0000\u0170\u0151\u0001\u0000"+ +		"\u0000\u0000\u0170\u015f\u0001\u0000\u0000\u0000\u0170\u0161\u0001\u0000"+ +		"\u0000\u0000\u0171)\u0001\u0000\u0000\u0000\u0172\u0177\u0003\"\u0011"+ +		"\u0000\u0173\u0174\u0005!\u0000\u0000\u0174\u0176\u0003\"\u0011\u0000"+ +		"\u0175\u0173\u0001\u0000\u0000\u0000\u0176\u0179\u0001\u0000\u0000\u0000"+ +		"\u0177\u0175\u0001\u0000\u0000\u0000\u0177\u0178\u0001\u0000\u0000\u0000"+ +		"\u0178\u017b\u0001\u0000\u0000\u0000\u0179\u0177\u0001\u0000\u0000\u0000"+ +		"\u017a\u017c\u0005!\u0000\u0000\u017b\u017a\u0001\u0000\u0000\u0000\u017b"+ +		"\u017c\u0001\u0000\u0000\u0000\u017c+\u0001\u0000\u0000\u0000\u017d\u0182"+ +		"\u0003.\u0017\u0000\u017e\u017f\u0005!\u0000\u0000\u017f\u0181\u0003."+ +		"\u0017\u0000\u0180\u017e\u0001\u0000\u0000\u0000\u0181\u0184\u0001\u0000"+ +		"\u0000\u0000\u0182\u0180\u0001\u0000\u0000\u0000\u0182\u0183\u0001\u0000"+ +		"\u0000\u0000\u0183\u0186\u0001\u0000\u0000\u0000\u0184\u0182\u0001\u0000"+ +		"\u0000\u0000\u0185\u0187\u0005!\u0000\u0000\u0186\u0185\u0001\u0000\u0000"+ +		"\u0000\u0186\u0187\u0001\u0000\u0000\u0000\u0187-\u0001\u0000\u0000\u0000"+ +		"\u0188\u018a\u0003\"\u0011\u0000\u0189\u018b\u00032\u0019\u0000\u018a"+ +		"\u0189\u0001\u0000\u0000\u0000\u018a\u018b\u0001\u0000\u0000\u0000\u018b"+ +		"\u0191\u0001\u0000\u0000\u0000\u018c\u018d\u0003\"\u0011\u0000\u018d\u018e"+ +		"\u0005%\u0000\u0000\u018e\u018f\u0003\"\u0011\u0000\u018f\u0191\u0001"+ +		"\u0000\u0000\u0000\u0190\u0188\u0001\u0000\u0000\u0000\u0190\u018c\u0001"+ +		"\u0000\u0000\u0000\u0191/\u0001\u0000\u0000\u0000\u0192\u0195\u00032\u0019"+ +		"\u0000\u0193\u0195\u00034\u001a\u0000\u0194\u0192\u0001\u0000\u0000\u0000"+ +		"\u0194\u0193\u0001\u0000\u0000\u0000\u01951\u0001\u0000\u0000\u0000\u0196"+ +		"\u0197\u0005\u000b\u0000\u0000\u0197\u0198\u0003*\u0015\u0000\u0198\u0199"+ +		"\u0005\u000f\u0000\u0000\u0199\u019b\u0003\"\u0011\u0000\u019a\u019c\u0003"+ +		"0\u0018\u0000\u019b\u019a\u0001\u0000\u0000\u0000\u019b\u019c\u0001\u0000"+ +		"\u0000\u0000\u019c3\u0001\u0000\u0000\u0000\u019d\u019e\u0005\r\u0000"+ +		"\u0000\u019e\u01a0\u0003\"\u0011\u0000\u019f\u01a1\u00030\u0018\u0000"+ +		"\u01a0\u019f\u0001\u0000\u0000\u0000\u01a0\u01a1\u0001\u0000\u0000\u0000"+ +		"\u01a15\u0001\u0000\u0000\u000089>@JNV\\djtxz\u0081\u0088\u0091\u0097"+ +		"\u009b\u00a1\u00b0\u00b6\u00bf\u00c8\u00cf\u00d1\u00d5\u00e4\u00eb\u00f1"+ +		"\u00f6\u011d\u011f\u0124\u0129\u012e\u0136\u013c\u0144\u0148\u014a\u014e"+ +		"\u0157\u015b\u0163\u0167\u016b\u016d\u0170\u0177\u017b\u0182\u0186\u018a"+ +		"\u0190\u0194\u019b\u01a0"; +	public static final ATN _ATN = +		new ATNDeserializer().deserialize(_serializedATN.toCharArray()); +	static { +		_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; +		for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { +			_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); +		} +	} +}
\ No newline at end of file diff --git a/src/Python3Parser.tokens b/src/Python3Parser.tokens new file mode 100644 index 0000000..0f817cc --- /dev/null +++ b/src/Python3Parser.tokens @@ -0,0 +1,142 @@ +INDENT=1 +DEDENT=2 +STRING=3 +NUMBER=4 +AND=5 +AS=6 +DEF=7 +ELIF=8 +ELSE=9 +FALSE=10 +FOR=11 +FROM=12 +IF=13 +IMPORT=14 +IN=15 +IS=16 +NONE=17 +NOT=18 +OR=19 +RETURN=20 +TRUE=21 +UNDERSCORE=22 +WHILE=23 +NEWLINE=24 +NAME=25 +DECIMAL_INTEGER=26 +FLOAT_NUMBER=27 +DOT=28 +ELLIPSIS=29 +STAR=30 +OPEN_PAREN=31 +CLOSE_PAREN=32 +COMMA=33 +COLON=34 +SEMI_COLON=35 +POWER=36 +ASSIGN=37 +OPEN_BRACK=38 +CLOSE_BRACK=39 +OR_OP=40 +XOR=41 +AND_OP=42 +LEFT_SHIFT=43 +RIGHT_SHIFT=44 +ADD=45 +MINUS=46 +DIV=47 +MOD=48 +IDIV=49 +NOT_OP=50 +OPEN_BRACE=51 +CLOSE_BRACE=52 +LESS_THAN=53 +GREATER_THAN=54 +EQUALS=55 +GT_EQ=56 +LT_EQ=57 +NOT_EQ_1=58 +NOT_EQ_2=59 +AT=60 +ARROW=61 +ADD_ASSIGN=62 +SUB_ASSIGN=63 +MULT_ASSIGN=64 +AT_ASSIGN=65 +DIV_ASSIGN=66 +MOD_ASSIGN=67 +AND_ASSIGN=68 +OR_ASSIGN=69 +XOR_ASSIGN=70 +LEFT_SHIFT_ASSIGN=71 +RIGHT_SHIFT_ASSIGN=72 +POWER_ASSIGN=73 +IDIV_ASSIGN=74 +SKIP_=75 +UNKNOWN_CHAR=76 +'and'=5 +'as'=6 +'def'=7 +'elif'=8 +'else'=9 +'False'=10 +'for'=11 +'from'=12 +'if'=13 +'import'=14 +'in'=15 +'is'=16 +'None'=17 +'not'=18 +'or'=19 +'return'=20 +'True'=21 +'_'=22 +'while'=23 +'.'=28 +'...'=29 +'*'=30 +'('=31 +')'=32 +','=33 +':'=34 +';'=35 +'**'=36 +'='=37 +'['=38 +']'=39 +'|'=40 +'^'=41 +'&'=42 +'<<'=43 +'>>'=44 +'+'=45 +'-'=46 +'/'=47 +'%'=48 +'//'=49 +'~'=50 +'{'=51 +'}'=52 +'<'=53 +'>'=54 +'=='=55 +'>='=56 +'<='=57 +'<>'=58 +'!='=59 +'@'=60 +'->'=61 +'+='=62 +'-='=63 +'*='=64 +'@='=65 +'/='=66 +'%='=67 +'&='=68 +'|='=69 +'^='=70 +'<<='=71 +'>>='=72 +'**='=73 +'//='=74 diff --git a/src/Python3ParserBase.java b/src/Python3ParserBase.java new file mode 100644 index 0000000..be28f2b --- /dev/null +++ b/src/Python3ParserBase.java @@ -0,0 +1,19 @@ +import org.antlr.v4.runtime.*; + +public abstract class Python3ParserBase extends Parser +{ +    protected Python3ParserBase(TokenStream input) +    { +        super(input); +    } + +    public boolean CannotBePlusMinus() +    { +        return true; +    } + +    public boolean CannotBeDotLpEq() +    { +        return true; +    } +}
\ No newline at end of file diff --git a/src/Python3ParserBaseListener.java b/src/Python3ParserBaseListener.java new file mode 100644 index 0000000..9cfc8be --- /dev/null +++ b/src/Python3ParserBaseListener.java @@ -0,0 +1,363 @@ +// Generated from src/Python3Parser.g4 by ANTLR 4.13.1 + +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.tree.ErrorNode; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * This class provides an empty implementation of {@link Python3ParserListener}, + * which can be extended to create a listener which only needs to handle a subset + * of the available methods. + */ +@SuppressWarnings("CheckReturnValue") +public class Python3ParserBaseListener implements Python3ParserListener { +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterRoot(Python3Parser.RootContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitRoot(Python3Parser.RootContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterSimple_stmts(Python3Parser.Simple_stmtsContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitSimple_stmts(Python3Parser.Simple_stmtsContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterCompound_stmt(Python3Parser.Compound_stmtContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitCompound_stmt(Python3Parser.Compound_stmtContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterSimple_stmt(Python3Parser.Simple_stmtContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitSimple_stmt(Python3Parser.Simple_stmtContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterAssignment(Python3Parser.AssignmentContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitAssignment(Python3Parser.AssignmentContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterReturn_stmt(Python3Parser.Return_stmtContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitReturn_stmt(Python3Parser.Return_stmtContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterImport_stm(Python3Parser.Import_stmContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitImport_stm(Python3Parser.Import_stmContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterDotted_name(Python3Parser.Dotted_nameContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitDotted_name(Python3Parser.Dotted_nameContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterFuncdef(Python3Parser.FuncdefContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitFuncdef(Python3Parser.FuncdefContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterParamlist(Python3Parser.ParamlistContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitParamlist(Python3Parser.ParamlistContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterParamdef(Python3Parser.ParamdefContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitParamdef(Python3Parser.ParamdefContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterAugassign(Python3Parser.AugassignContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitAugassign(Python3Parser.AugassignContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterIf_stmt(Python3Parser.If_stmtContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitIf_stmt(Python3Parser.If_stmtContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterWhile_stmt(Python3Parser.While_stmtContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitWhile_stmt(Python3Parser.While_stmtContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterFor_stmt(Python3Parser.For_stmtContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitFor_stmt(Python3Parser.For_stmtContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterBlock(Python3Parser.BlockContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitBlock(Python3Parser.BlockContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterComp_op(Python3Parser.Comp_opContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitComp_op(Python3Parser.Comp_opContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterExpr(Python3Parser.ExprContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitExpr(Python3Parser.ExprContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterAtom(Python3Parser.AtomContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitAtom(Python3Parser.AtomContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterTestlist_comp(Python3Parser.Testlist_compContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitTestlist_comp(Python3Parser.Testlist_compContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterTrailer(Python3Parser.TrailerContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitTrailer(Python3Parser.TrailerContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterExprlist(Python3Parser.ExprlistContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitExprlist(Python3Parser.ExprlistContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterArglist(Python3Parser.ArglistContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitArglist(Python3Parser.ArglistContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterArgument(Python3Parser.ArgumentContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitArgument(Python3Parser.ArgumentContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterComp_iter(Python3Parser.Comp_iterContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitComp_iter(Python3Parser.Comp_iterContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterComp_for(Python3Parser.Comp_forContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitComp_for(Python3Parser.Comp_forContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterComp_if(Python3Parser.Comp_ifContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitComp_if(Python3Parser.Comp_ifContext ctx) { } + +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void enterEveryRule(ParserRuleContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void exitEveryRule(ParserRuleContext ctx) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void visitTerminal(TerminalNode node) { } +	/** +	 * {@inheritDoc} +	 * +	 * <p>The default implementation does nothing.</p> +	 */ +	@Override public void visitErrorNode(ErrorNode node) { } +}
\ No newline at end of file diff --git a/src/Python3ParserListener.java b/src/Python3ParserListener.java new file mode 100644 index 0000000..8cfb1a4 --- /dev/null +++ b/src/Python3ParserListener.java @@ -0,0 +1,279 @@ +// Generated from src/Python3Parser.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.tree.ParseTreeListener; + +/** + * This interface defines a complete listener for a parse tree produced by + * {@link Python3Parser}. + */ +public interface Python3ParserListener extends ParseTreeListener { +	/** +	 * Enter a parse tree produced by {@link Python3Parser#root}. +	 * @param ctx the parse tree +	 */ +	void enterRoot(Python3Parser.RootContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#root}. +	 * @param ctx the parse tree +	 */ +	void exitRoot(Python3Parser.RootContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#simple_stmts}. +	 * @param ctx the parse tree +	 */ +	void enterSimple_stmts(Python3Parser.Simple_stmtsContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#simple_stmts}. +	 * @param ctx the parse tree +	 */ +	void exitSimple_stmts(Python3Parser.Simple_stmtsContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#compound_stmt}. +	 * @param ctx the parse tree +	 */ +	void enterCompound_stmt(Python3Parser.Compound_stmtContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#compound_stmt}. +	 * @param ctx the parse tree +	 */ +	void exitCompound_stmt(Python3Parser.Compound_stmtContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#simple_stmt}. +	 * @param ctx the parse tree +	 */ +	void enterSimple_stmt(Python3Parser.Simple_stmtContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#simple_stmt}. +	 * @param ctx the parse tree +	 */ +	void exitSimple_stmt(Python3Parser.Simple_stmtContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#assignment}. +	 * @param ctx the parse tree +	 */ +	void enterAssignment(Python3Parser.AssignmentContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#assignment}. +	 * @param ctx the parse tree +	 */ +	void exitAssignment(Python3Parser.AssignmentContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#return_stmt}. +	 * @param ctx the parse tree +	 */ +	void enterReturn_stmt(Python3Parser.Return_stmtContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#return_stmt}. +	 * @param ctx the parse tree +	 */ +	void exitReturn_stmt(Python3Parser.Return_stmtContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#import_stm}. +	 * @param ctx the parse tree +	 */ +	void enterImport_stm(Python3Parser.Import_stmContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#import_stm}. +	 * @param ctx the parse tree +	 */ +	void exitImport_stm(Python3Parser.Import_stmContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#dotted_name}. +	 * @param ctx the parse tree +	 */ +	void enterDotted_name(Python3Parser.Dotted_nameContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#dotted_name}. +	 * @param ctx the parse tree +	 */ +	void exitDotted_name(Python3Parser.Dotted_nameContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#funcdef}. +	 * @param ctx the parse tree +	 */ +	void enterFuncdef(Python3Parser.FuncdefContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#funcdef}. +	 * @param ctx the parse tree +	 */ +	void exitFuncdef(Python3Parser.FuncdefContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#paramlist}. +	 * @param ctx the parse tree +	 */ +	void enterParamlist(Python3Parser.ParamlistContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#paramlist}. +	 * @param ctx the parse tree +	 */ +	void exitParamlist(Python3Parser.ParamlistContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#paramdef}. +	 * @param ctx the parse tree +	 */ +	void enterParamdef(Python3Parser.ParamdefContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#paramdef}. +	 * @param ctx the parse tree +	 */ +	void exitParamdef(Python3Parser.ParamdefContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#augassign}. +	 * @param ctx the parse tree +	 */ +	void enterAugassign(Python3Parser.AugassignContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#augassign}. +	 * @param ctx the parse tree +	 */ +	void exitAugassign(Python3Parser.AugassignContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#if_stmt}. +	 * @param ctx the parse tree +	 */ +	void enterIf_stmt(Python3Parser.If_stmtContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#if_stmt}. +	 * @param ctx the parse tree +	 */ +	void exitIf_stmt(Python3Parser.If_stmtContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#while_stmt}. +	 * @param ctx the parse tree +	 */ +	void enterWhile_stmt(Python3Parser.While_stmtContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#while_stmt}. +	 * @param ctx the parse tree +	 */ +	void exitWhile_stmt(Python3Parser.While_stmtContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#for_stmt}. +	 * @param ctx the parse tree +	 */ +	void enterFor_stmt(Python3Parser.For_stmtContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#for_stmt}. +	 * @param ctx the parse tree +	 */ +	void exitFor_stmt(Python3Parser.For_stmtContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#block}. +	 * @param ctx the parse tree +	 */ +	void enterBlock(Python3Parser.BlockContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#block}. +	 * @param ctx the parse tree +	 */ +	void exitBlock(Python3Parser.BlockContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#comp_op}. +	 * @param ctx the parse tree +	 */ +	void enterComp_op(Python3Parser.Comp_opContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#comp_op}. +	 * @param ctx the parse tree +	 */ +	void exitComp_op(Python3Parser.Comp_opContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#expr}. +	 * @param ctx the parse tree +	 */ +	void enterExpr(Python3Parser.ExprContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#expr}. +	 * @param ctx the parse tree +	 */ +	void exitExpr(Python3Parser.ExprContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#atom}. +	 * @param ctx the parse tree +	 */ +	void enterAtom(Python3Parser.AtomContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#atom}. +	 * @param ctx the parse tree +	 */ +	void exitAtom(Python3Parser.AtomContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#testlist_comp}. +	 * @param ctx the parse tree +	 */ +	void enterTestlist_comp(Python3Parser.Testlist_compContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#testlist_comp}. +	 * @param ctx the parse tree +	 */ +	void exitTestlist_comp(Python3Parser.Testlist_compContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#trailer}. +	 * @param ctx the parse tree +	 */ +	void enterTrailer(Python3Parser.TrailerContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#trailer}. +	 * @param ctx the parse tree +	 */ +	void exitTrailer(Python3Parser.TrailerContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#exprlist}. +	 * @param ctx the parse tree +	 */ +	void enterExprlist(Python3Parser.ExprlistContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#exprlist}. +	 * @param ctx the parse tree +	 */ +	void exitExprlist(Python3Parser.ExprlistContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#arglist}. +	 * @param ctx the parse tree +	 */ +	void enterArglist(Python3Parser.ArglistContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#arglist}. +	 * @param ctx the parse tree +	 */ +	void exitArglist(Python3Parser.ArglistContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#argument}. +	 * @param ctx the parse tree +	 */ +	void enterArgument(Python3Parser.ArgumentContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#argument}. +	 * @param ctx the parse tree +	 */ +	void exitArgument(Python3Parser.ArgumentContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#comp_iter}. +	 * @param ctx the parse tree +	 */ +	void enterComp_iter(Python3Parser.Comp_iterContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#comp_iter}. +	 * @param ctx the parse tree +	 */ +	void exitComp_iter(Python3Parser.Comp_iterContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#comp_for}. +	 * @param ctx the parse tree +	 */ +	void enterComp_for(Python3Parser.Comp_forContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#comp_for}. +	 * @param ctx the parse tree +	 */ +	void exitComp_for(Python3Parser.Comp_forContext ctx); +	/** +	 * Enter a parse tree produced by {@link Python3Parser#comp_if}. +	 * @param ctx the parse tree +	 */ +	void enterComp_if(Python3Parser.Comp_ifContext ctx); +	/** +	 * Exit a parse tree produced by {@link Python3Parser#comp_if}. +	 * @param ctx the parse tree +	 */ +	void exitComp_if(Python3Parser.Comp_ifContext ctx); +}
\ No newline at end of file  |