diff --git a/Check_Odd_Even.py b/Check_Odd_Even.py deleted file mode 100644 index 87c2d8d..0000000 --- a/Check_Odd_Even.py +++ /dev/null @@ -1,10 +0,0 @@ -# ------------------------------------- -# create by: Nguyen Tien Dung - -# Date: 10:11 PM 30/8/2021 - -# ------------------------------------ - -numbe = int(input()) -if numbe % 2 == 0: - print("CHAN") -else : - print("LE") \ No newline at end of file diff --git a/Decode.py b/Decode.py deleted file mode 100644 index 06dc7c3..0000000 --- a/Decode.py +++ /dev/null @@ -1,17 +0,0 @@ -# ------------------------------------- -# create by: Nguyen Tien Dung - -# Date: 11:23 PM 30/8/2021 - -# ------------------------------------- -#hehelo bebe -T = int(input()) -while T>0: - str = input() - for index in range(len(str)): - if index % 2 == 1: - k = int(str[index]) - # print(str[index]) - while k > 0: - print(str[index-1],end="") - k = k-1 - T = T-1 - print("\n") \ No newline at end of file diff --git a/Decode_1.py b/Decode_1.py new file mode 100644 index 0000000..9c40aad --- /dev/null +++ b/Decode_1.py @@ -0,0 +1,21 @@ +T = int(input()) +while T > 0: + s = "" + st = str(input()) + cnt = 1 + k = len(st) + for i in range(0,k-1,1): + if st[i] == st[i+1]: + cnt = cnt+1 + else: + sTmp = str(cnt) + st[i] + s = s+sTmp + cnt = 1 + if st[k-1] != st[k-2]: + sTmp = '1' + st[k-1] + s = s+sTmp + else: + sTmp = str(cnt) + st[k-1] + s= s+sTmp + print(s) + T = T - 1 \ No newline at end of file diff --git a/Even_Odd.py b/Even_Odd.py new file mode 100644 index 0000000..08709e5 --- /dev/null +++ b/Even_Odd.py @@ -0,0 +1,23 @@ +T = int(input()) +while T>0: + str = input() + sum = 0 + check = 1 + # t = abs(int(str[0]) - int(str[1])) + # print(type(t)) + for index in range(len(str)-1): + if abs(int(str[index]) - int(str[index+1])) == 2: + sum = sum + int(str[index]) + else: + check = 0 + break + if(check == 0): + print("NO") + else: + sum = sum + int(str[len(str)-1]) + if sum % 10 == 0: + print("YES") + else: + print("NO") + # print(sum) + T = T-1 diff --git a/First_Last.py b/First_Last.py new file mode 100644 index 0000000..4497372 --- /dev/null +++ b/First_Last.py @@ -0,0 +1,12 @@ +# ------------------------------------- +# create by: Nguyen Tien Dung - +# Date: 11:20 PM 31/8/2021 - +# ------------------------------------- +T = int(input()) +while T > 0: + str = input() + if str[0] == str[len(str)-2] and str[1] == str[len(str)-1]: + print("YES") + else: + print("NO") + T = T - 1 diff --git a/Insert_Comma.py b/Insert_Comma.py new file mode 100644 index 0000000..6f3178d --- /dev/null +++ b/Insert_Comma.py @@ -0,0 +1,9 @@ +# for i in range(5,-1,-1): +# print(i) +# systax +# str = str1[:index] + str2 + str1[index:] +str = input() +# print(len(str)) +for i in range(len(str)-3,0,-3): + str = str[:i] + "," + str[i:] +print(str) \ No newline at end of file diff --git a/Insert_String.py b/Insert_String.py new file mode 100644 index 0000000..652e68b --- /dev/null +++ b/Insert_String.py @@ -0,0 +1,7 @@ +str1 = input() +str2 = input() +index = int(input()) +index = index-1 +# def insert_sequence(str1, str2, index): +str = str1[:index] + str2 + str1[index:] +print(str) \ No newline at end of file diff --git a/Inversion_Pair.py b/Inversion_Pair.py new file mode 100644 index 0000000..f8cbd38 --- /dev/null +++ b/Inversion_Pair.py @@ -0,0 +1,25 @@ +# create by: Nguyen Tien Dung - +# Date: 10:35 PM 31/8/2021 - +# ------------------------------------- +# import array as arr +# +# a = arr.array('i', []) +# +# k = int(input("Enter size of array:")) +# for i in range(0, k): +# num = int(input()) +# a.append(num) +# cnt = 0 +# for i in range(0,k-1): +# for j in range(i,k): +# if a[i] > a[j]: +# cnt = cnt + 1 +# print(cnt) +T = int(input()) +str = [int(x) for x in input().split()] +cnt = 0 +for i in range(len(str)-1): + for j in range(i+1,len(str)): + if int(str[i]) > int(str[j]): + cnt = cnt + 1 +print(cnt) \ No newline at end of file diff --git a/Lucky_Number.py b/Lucky_Number.py new file mode 100644 index 0000000..0c66e8f --- /dev/null +++ b/Lucky_Number.py @@ -0,0 +1,13 @@ +# ------------------------------------- +# create by: Nguyen Tien Dung - +# Date: 11:24 PM 30/8/2021 - +# ------------------------------------- +T = int(input()) +while T>0: + str = input() + k = len(str) + if(str[k-1] == '6' and str[k-2] == '8'): + print("YES") + else: + print("NO") + T = T-1 diff --git a/Lucky_Number_1.py b/Lucky_Number_1.py new file mode 100644 index 0000000..eb764ac --- /dev/null +++ b/Lucky_Number_1.py @@ -0,0 +1,9 @@ +str = input() +cnt = 0 +for i in range(len(str)): + if str[i] == '4' or str[i] == '7': + cnt = cnt+1 +if cnt == 4 or cnt == 7: + print("YES") +else: + print("NO") \ No newline at end of file diff --git a/Lucky_Number_2.py b/Lucky_Number_2.py new file mode 100644 index 0000000..ad59dac --- /dev/null +++ b/Lucky_Number_2.py @@ -0,0 +1,13 @@ +T = int(input()) +while T>0: + check = 0 + str = input() + for i in range(len(str)): + if str[i] != '4' and str[i] != '7': + check = 1 + break + if check == 0: + print("YES") + else: + print("NO") + T = T - 1 \ No newline at end of file diff --git a/Matching_Number.py b/Matching_Number.py new file mode 100644 index 0000000..37368fd --- /dev/null +++ b/Matching_Number.py @@ -0,0 +1,18 @@ +T = int(input()) +while T>0: + n = int(input()) + str1 = [int(x) for x in input().split()] + str2 = [int(x) for x in input().split()] + str1.sort() + str2.sort() + check = 0 + for i in range(0,n,1): + if str1[i] > str2[i]: + check = 1 + break + + if check == 1: + print("NO") + else: + print("YES") + T = T - 1 \ No newline at end of file diff --git a/MostFrequent.py b/MostFrequent.py new file mode 100644 index 0000000..6da921b --- /dev/null +++ b/MostFrequent.py @@ -0,0 +1,33 @@ +# T = int(input()) +# while T > 0: +# n = int(input()) +# str = input() +# str = str.replace(" ","") +# maxi = 0 +# for i in range(0,len(str),1): +# d[str[i]] = d[str[i]] + 1 +# if d[str[i]] > maxi: +# maxi = d[str[i]] +# T = T - 1 +# print(maxi) +# TLE +T = int(input()) +while T>0: + n = int(input()) + str = input() + str = str.split() + list_1 = [] + list_1[:0] = str + dict = {} + count,itm = 0,'' + for item in reversed(list_1): + dict[item] = dict.get(item,0)+1 + if dict[item] >= count: + count,itm = dict[item],item + + k = list_1.count(itm) + if k > len(str)//2: + print(itm) + else: + print("NO") + T = T - 1 diff --git a/No_Decrease.py b/No_Decrease.py new file mode 100644 index 0000000..e9c3ade --- /dev/null +++ b/No_Decrease.py @@ -0,0 +1,18 @@ +# ------------------------------------- +# create by: Nguyen Tien Dung - +# Date: 10:30 PM 30/8/2021 - +# ------------------------------------- +T = int(input()) +while T>0: + str = input() + check = 0 + for index in range(len(str)-1): + if int(str[index]) > int(str[index+1]): + check = 1 + break + if check == 0: + print("YES") + else: + print("NO") + T = T-1 + print("\n") diff --git a/Prime.py b/Prime.py new file mode 100644 index 0000000..3eb7284 --- /dev/null +++ b/Prime.py @@ -0,0 +1,16 @@ +import math + +T = int(input()) + +while T>0: + n = int(input()) + check = 0 + for i in range(2,int(math.sqrt(n))+1,1): + if n%i == 0: + check = 1 + break + if check == 0: + print("YES") + else: + print("NO") + T = T - 1 \ No newline at end of file diff --git a/Prime_1.py b/Prime_1.py new file mode 100644 index 0000000..f36528f --- /dev/null +++ b/Prime_1.py @@ -0,0 +1,34 @@ +import math + +def Sieve(h): + prime = [True for x in range(h + 1)] + p = 2 + while p * p <= h: + if prime[p]: + for j in range(p * p, h + 1, p): + prime[j] = False + p += 1 + prime[0] = False + prime[1] = False + cnt = 0 + for j in range(2, h + 1): + if prime[j]: + cnt += 1 + return cnt +#hello bebe +T = int(input()) +while T > 0: + n = int(input()) + k = Sieve(n) + flag = True + if k < 2: + flag = False + for i in range(2, int(math.sqrt(k)) + 1, 1): + if k % i == 0: + flag = False + break + if flag: + print("YES") + else: + print("NO") + T -= 1 diff --git a/Sum_Number.py b/Sum_Number.py new file mode 100644 index 0000000..c81d730 --- /dev/null +++ b/Sum_Number.py @@ -0,0 +1,18 @@ +T = int(input()) +while T>0: + s = input() + n = len(s) + sum = 0 + s1 = "" + for i in range(n): + if s[i].isnumeric() == True: + sum += int(s[i]) + for i in range(n): + if s[i].isnumeric() != False: + continue + else: + s1 = s1 + s[i] + s2 = sorted(s1) + s1 = "".join(s2) + print(s1+str(sum)) + T -= 1 \ No newline at end of file diff --git a/Summation.py b/Summation.py new file mode 100644 index 0000000..f817723 --- /dev/null +++ b/Summation.py @@ -0,0 +1,10 @@ +# ------------------------------------- +# create by: Nguyen Tien Dung - +# Date: 10:23 PM 30/8/2021 - +# ------------------------------------ +str = input() +if int(str[0]) + int(str[4]) == int(str[8]): + print("YES") +else: + print("NO") + diff --git a/Test.py b/Test.py new file mode 100644 index 0000000..fb8d067 --- /dev/null +++ b/Test.py @@ -0,0 +1,4 @@ +ar = [int(x) for x in input().split()] +n = len(ar) +for i in range(n): + print(i) \ No newline at end of file diff --git a/Transform_Number.py b/Transform_Number.py new file mode 100644 index 0000000..4eaba0c --- /dev/null +++ b/Transform_Number.py @@ -0,0 +1,38 @@ +k = 10 +while k > 0: + ar = [int(x) for x in input().split()] + n = len(ar) + ch = True + for i in range(n): + if ar[i] != 0: + ch = False + if ch == True: + break + cnt = 0 + t = 5 + check = 0 + while t>0: + x = ar[0] + for i in range(n-1): + ar[i] = abs(ar[i] - ar[i+1]) + + ar[n-1] = abs(ar[n-1] - x) + cnt += 1 + ok = True + for i in range(n): + if ar[i] != 0: + ok = False + break + if ok == True: + t = 0 + # print(cnt) + print(cnt-1) + +# //1 3 5 9 +# //2 2 4 8 +# //0 2 4 6 +# //2 2 2 6 +# //0 0 4 4 +# //0 4 0 4 +# //4 4 4 4 +# //0 0 0 0 \ No newline at end of file diff --git a/Upper_Lower.py b/Upper_Lower.py new file mode 100644 index 0000000..eaba532 --- /dev/null +++ b/Upper_Lower.py @@ -0,0 +1,17 @@ +# ------------------------------------- +# create by: Nguyen Tien Dung - +# Date: 11:42 PM 30/8/2021 - +# ------------------------------------- +str = input() +up,lo = 0,0 +for index in range(len(str)): + if str[index] >= 'a': + lo = lo + 1 + else: + up = up + 1 +if up > lo: + print(str.upper()) +elif lo >= up: + print(str.lower()) + + diff --git a/WelcomeToPython.py b/WelcomeToPython.py new file mode 100644 index 0000000..791401a --- /dev/null +++ b/WelcomeToPython.py @@ -0,0 +1,7 @@ +# ------------------------------------- +# create by: Nguyen Tien Dung - +# Date: 11:44 PM 30/8/2021 - +# ------------------------------------- + +str = input() +print("Hello "+str+"!") \ No newline at end of file diff --git a/Word_Separation.py b/Word_Separation.py new file mode 100644 index 0000000..afb64c8 --- /dev/null +++ b/Word_Separation.py @@ -0,0 +1,10 @@ +# ------------------------------------- +# create by: Nguyen Tien Dung - +# Date: 10:30 PM 30/8/2021 - +# ------------------------------------- + +str = input() +str = str.split() +for index in str: + print(index); + print("\n") \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..b9d1800 --- /dev/null +++ b/main.py @@ -0,0 +1,15 @@ +# message = "Hello Python " +# print(message) +# message = "Anh yeu em" +# print(message) +# message_1 = "co chac yeu la day" +# print(message_1.title()) +# print(message_1.upper()) +# message_2 = "THAI BINH MO HOI ROI" +# print(message_2.lower()) +# ------------------------------------- +# create by: Nguyen Tien Dung - +# Date: 9:11 PM 30/8/2021 - +# ------------------------------------- +message = input() +print(message.upper())