-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Python programs for Codeforces questions were added
- Loading branch information
Showing
17 changed files
with
215 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
n=int(input()) | ||
count=0 | ||
while (n): | ||
|
||
cat=str(input()) | ||
if (cat=="Tetrahedron"): | ||
count=count+4 | ||
elif (cat=="Cube"): | ||
count=count+6 | ||
elif (cat=="Octahedron"): | ||
count=count+8 | ||
elif (cat=="Dodecahedron"): | ||
count=count+12 | ||
elif (cat=="Icosahedron"): | ||
count=count+20 | ||
n=n-1 | ||
print(count) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
n=input() | ||
print(len(set(n))-4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
test=int(input()) | ||
while(test>0): | ||
n=int(input()) | ||
arr=[] | ||
if n%2==0: | ||
for i in range(n-2,1,-1): | ||
arr.append(i) | ||
arr.append(1) | ||
arr.append(n-1) | ||
arr.append(n) | ||
for i in range(len(arr)): | ||
print(arr[i],end=" ") | ||
else: | ||
for i in range(n-2,1,-1): | ||
arr.append(i) | ||
for i in range(len(arr)-1): | ||
temp=arr[i] | ||
arr[i]=arr[i+1] | ||
arr[i+1]=temp | ||
arr.append(1) | ||
arr.append(n-1) | ||
arr.append(n) | ||
for i in range(len(arr)): | ||
print(arr[i],end=" ") | ||
|
||
test=test-1 | ||
print("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
test=int(input()) | ||
while(test>0): | ||
m=int(input()) | ||
k=list(map(int,input().split())) | ||
l=max(k) | ||
print(k.index(l)+1) | ||
|
||
test=test-1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
t=int(input()) | ||
while (t>0): | ||
n=int(input()) | ||
code=input() | ||
res="" | ||
while code: | ||
if code[-1] != '0': | ||
res = chr(96 + int(code[-1])) + res | ||
code = code[:-1] | ||
else: | ||
res = chr(96 + int(code[-3:-1])) + res | ||
code = code[:-3] | ||
print(res) | ||
t-=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
n=int(input()) | ||
list1=list(map(int,input().split())) | ||
k=0.0 | ||
for i in range(n): | ||
k=k+float(list1[i]/n) | ||
print(k) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
l=[] | ||
for i in range(3): | ||
l.append(int(input())) | ||
|
||
a=l[0] | ||
b=l[1] | ||
c=l[2] | ||
print(max((a*b*c),(a+b+c),((a+b)*c), a*(b+c))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
n=int(input()) | ||
l1=list(map(int,input().split())) | ||
l2=list(map(int,input().split())) | ||
flag=0 | ||
for i in (l1): | ||
if i==n: | ||
flag=1 | ||
for j in (l2): | ||
if j==n: | ||
flag=1 | ||
if (flag==1): | ||
print("I become the guy.") | ||
else: | ||
print("Oh, my keyboard!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import math | ||
for i in range(int(input())): | ||
k=int(input()) | ||
f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
n=int(input()) | ||
x=list(map(int,input().split())) | ||
l=[] | ||
for i in range(1,n+1): | ||
l.append(x.index(i)+1) | ||
|
||
print (*l) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
test=int(input()) | ||
|
||
|
||
while (test>0): | ||
count=0 | ||
n,k=map(int,input().split()) | ||
l1=list(map(int,input().split())) | ||
for i in range(k): | ||
if l1[i]> k: | ||
count=count+1 | ||
|
||
|
||
print(count) | ||
|
||
test=test-1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
n=int(input()) | ||
k=[] | ||
for i in range(n): | ||
x=list(map(int,input().split())) | ||
k.append(x) | ||
sum1=0 | ||
sum2=0 | ||
sum3=0 | ||
for j in range(len(k)): | ||
m=0 | ||
sum1=sum1+ k[j][m] | ||
|
||
for j in range(len(k)): | ||
m=1 | ||
sum2=sum2+k[j][m] | ||
for j in range(len(k)): | ||
m=2 | ||
sum3=sum3+k[j][m] | ||
if sum1==0 and sum2==0 and sum3==0: | ||
print("YES") | ||
else: | ||
print("NO") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
st='' | ||
count=0 | ||
name=str(input()) | ||
for i in name: | ||
if i not in st: | ||
count=count+1 | ||
st=st+i | ||
else: | ||
continue | ||
if (count%2==0): | ||
print("CHAT WITH HER!") | ||
else: | ||
print("IGNORE HIM!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
test=int(input()) | ||
while (test>0): | ||
count=0 | ||
n=int(input()) | ||
l1=list(map(int,input().split())) | ||
l2=[] | ||
for i in range(n-1): | ||
for j in range(n): | ||
if l1[j] in l2: | ||
l1[j]=0 | ||
continue | ||
elif l1[i]>= l1[j] and l1[i]!=0: | ||
l2.append(l1[i]) | ||
l1[i]=0 | ||
count=count+1 | ||
|
||
|
||
test=test-1 | ||
print(count) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
n=str(input()) | ||
sum=0 | ||
max_sum=0 | ||
for i in range(len(n)-1): | ||
if (n[i]==n[i+1]): | ||
sum=sum+1 | ||
else: | ||
sum=0 | ||
max_sum=max(max_sum,sum+1) | ||
if max_sum>=7: | ||
print("YES") | ||
else: | ||
print("NO") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from collections import Counter | ||
n=int(input()) | ||
|
||
arr=[] | ||
for i in range(n): | ||
k=str(input()) | ||
arr.append(k) | ||
l=Counter(arr) | ||
k1=1 | ||
|
||
m=max(l, key=l.get) | ||
print(m) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
st=str(input()) | ||
vowel=["a","e","i","o","u","A","E","I","O","U","y","Y"] | ||
s='' | ||
for i in st: | ||
if i not in vowel: | ||
s=s+"."+i.lower() | ||
print(s) |